[llvm-commits] [llvm-gcc-4.2] r43913 [64/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...

Bill Wendling isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007


Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_Hant.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_Hant.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_Hant.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_Hant.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,845 @@
+# LocaleInformation_zh_Hant.properties --
+# Copyright (C) 1991-2005 Unicode, Inc.
+# All rights reserved. Distributed under the Terms of Use
+# in http://www.unicode.org/copyright.html.
+#
+# This file was automatically generated by gnu.localegen from CLDR.
+
+currenciesDisplayName.YDD=\u8449\u9580\u7b2c\u7d0d\u723e
+currenciesDisplayName.TWD=\u65b0\u81fa\u5e63
+currenciesDisplayName.KES=\u80af\u5c3c\u4e9e\u5148\u4ee4
+currenciesDisplayName.BYB=\u767d\u4fc4\u7f85\u65af\u65b0\u76e7\u5e03 (1994-1999)
+currenciesDisplayName.LKR=\u65af\u91cc\u862d\u5361\u76e7\u5e03
+currenciesDisplayName.RWF=\u76e7\u5b89\u9054\u6cd5\u90ce
+currenciesDisplayName.TJS=\u5854\u5409\u514b\u65af\u5766 \u7d22\u83ab\u5c3c
+currenciesDisplayName.SDP=\u8607\u4e39\u938a
+currenciesDisplayName.TJR=\u5854\u5409\u514b\u65af\u5766\u76e7\u5e03
+currenciesDisplayName.ERN=\u5384\u7acb\u7279\u91cc\u4e9e\u7d0d\u514b\u6cd5
+currenciesDisplayName.GRD=\u5e0c\u81d8\u5fb7\u62c9\u514b\u99ac
+currenciesDisplayName.IEP=\u611b\u723e\u862d\u938a
+currenciesDisplayName.ARS=\u963f\u6839\u5ef7\u62ab\u7d22
+currenciesDisplayName.SDD=\u8607\u4e39\u7b2c\u7d0d\u723e
+currenciesDisplayName.ARP=\u963f\u6839\u5ef7\u62ab\u7d22(1983-1985)
+currenciesDisplayName.GEL=\u55ac\u6cbb\u62c9\u91cc
+currenciesDisplayName.GEK=\u55ac\u6cbb \u5eab\u65c1 \u62c9\u91cc
+currenciesDisplayName.CRC=\u54e5\u65af\u5927\u9ece\u52a0\u79d1\u90ce
+currenciesDisplayName.FKP=\u798f\u514b\u862d\u7fa4\u5cf6\u938a
+currenciesDisplayName.EEK=\u611b\u6c99\u5c3c\u4e9e\u514b\u6717
+currenciesDisplayName.MDL=\u6469\u675c\u96f2\u5217\u4f0a
+currenciesDisplayName.ARA=\u963f\u6839\u5ef7\u5967\u65af\u7279\u7d0d\u723e
+currenciesDisplayName.IQD=\u4f0a\u62c9\u514b\u7b2c\u7d0d\u723e
+currenciesDisplayName.SCR=\u585e\u820c\u723e\u7fa4\u5cf6\u76e7\u5e03
+currenciesDisplayName.VUV=\u842c\u90a3\u675c\u842c\u675c
+currenciesDisplayName.DKK=\u4e39\u9ea5\u514b\u7f85\u7d0d
+currenciesDisplayName.KPW=\u5317\u671d\u9bae\u5e63
+currenciesDisplayName.GQE=\u8d64\u9053\u5e7e\u5167\u4e9e\u57c3\u594e\u52d2
+currenciesDisplayName.IDR=\u5370\u5c3c - \u76e7\u5e03
+currenciesDisplayName.LVR=\u62c9\u812b\u7dad\u4e9e\u76e7\u5e03
+currenciesDisplayName.SOS=\u7d22\u99ac\u5229\u4e9e\u5148\u4ee4
+currenciesDisplayName.AED=\u963f\u62c9\u4f2f\u806f\u5408\u5927\u516c\u570b\u8fea\u723e\u6c57
+currenciesDisplayName.BWP=\u6ce2\u672d\u90a3 - \u666e\u62c9
+currenciesDisplayName.LVL=\u62c9\u812b\u7dad\u4e9e\u62c9\u7279\u9280\u5e63
+currenciesDisplayName.RUR=\u4fc4\u7f85\u65af\u76e7\u5e03 (1991-1998)
+currenciesDisplayName.NIO=\u5c3c\u52a0\u62c9\u74dc \u91d1\u54e5\u591a\u83ef
+currenciesDisplayName.ADP=\u5b89\u9053\u723e\u966a\u58eb\u7279
+currenciesDisplayName.FJD=\u6590\u6fdf\u5143
+currenciesDisplayName.MOP=\u6fb3\u9580\u5143
+currenciesDisplayName.RUB=\u4fc4\u7f85\u65af\u76e7\u5e03
+currenciesDisplayName.CDF=\u525b\u679c\u6cd5\u90ce
+currenciesDisplayName.DJF=\u5409\u5e03\u5730\u6cd5\u90ce
+currenciesDisplayName.ECV=\u5384\u74dc\u591a\u723e\u7531\u91cc\u9054\u74e6\u5eb7\u65af\u5766 (UVC)
+currenciesDisplayName.SBD=\u7d22\u7f85\u9580\u7fa4\u5cf6\u5143
+currenciesDisplayName.UZS=\u70cf\u8332\u5225\u514b\u65af\u5766 \u85a9\u6728
+currenciesDisplayName.ECS=\u5384\u74dc\u591a\u8607\u514b\u96f7
+currenciesDisplayName.PHP=\u83f2\u5f8b\u8cd3\u62ab\u7d22
+currenciesDisplayName.THB=\u6cf0\u9296
+currenciesDisplayName.LUF=\u76e7\u68ee\u5821\u6cd5\u90ce
+currenciesDisplayName.FIM=\u82ac\u862d\u99ac\u514b
+currenciesDisplayName.TTD=\u5343\u91cc\u9054\u53ca\u6258\u5df4\u54e5r
+currenciesDisplayName.SZL=\u65af\u5a01\u58eb\u862d \u91cc\u90ce
+currenciesDisplayName.MNT=\u8499\u53e4\u5716\u683c\u91cc\u514b
+currenciesDisplayName.SAR=\u6c99\u70cf\u5730\u91cc\u96c5
+currenciesDisplayName.UAK=\u70cf\u514b\u862d \u5361\u672c\u74e6\u90a3\u8332
+currenciesDisplayName.UAH=\u70cf\u514b\u862d\u683c\u91cc\u592b\u90a3
+currenciesDisplayName.HUF=\u5308\u7259\u5229 - \u798f\u6797
+currenciesDisplayName.COP=\u54e5\u502b\u6bd4\u4e9e\u62ab\u7d22
+currenciesDisplayName.QAR=\u5361\u9054\u723e\u91cc\u4e9e\u723e
+currenciesDisplayName.LTT=\u7acb\u9676\u5b9b\u7279\u7f85
+currenciesDisplayName.PTE=\u8461\u8404\u7259\u57c3\u65af\u5eab\u591a
+currenciesDisplayName.AOR=\u5b89\u54e5\u62c9\u65b0\u5bec\u624e Reajustado (1995-1999)
+currenciesDisplayName.UYU=\u70cf\u62c9\u572d\u62ab\u7d22
+currenciesDisplayName.GBP=\u82f1\u938a
+currenciesDisplayName.BIF=\u84b2\u9686\u5730\u6cd5\u90ce
+currenciesDisplayName.INR=\u5370\u5ea6\u76e7\u5e03
+currenciesDisplayName.ZRZ=\u624e\u4f0a\u723e\u624e\u4f0a\u723e
+currenciesDisplayName.AON=\u5b89\u54e5\u62c9\u65b0\u5bec\u624e (1990-2000)
+currenciesDisplayName.LTL=\u7acb\u9676\u5b9b\u91cc\u5854
+currenciesDisplayName.XFU=\u6cd5\u570b UIC \u6cd5\u90ce
+currenciesDisplayName.KZT=\u5361\u624e\u514b\u65af\u5766\u5766\u5409
+currenciesDisplayName.MZM=\u83ab\u4e09\u6bd4\u514b\u6885\u8482\u5361\u723e
+currenciesDisplayName.UYP=\u70cf\u62c9\u572d\u62ab\u7d22 (1975-1993)
+currenciesDisplayName.AOK=\u5b89\u54e5\u62c9\u5bec\u624e(1977-1990)
+currenciesDisplayName.BUK=\u7dec\u7538\u5143
+currenciesDisplayName.GNS=\u5e7e\u5167\u4e9e\u897f\u91cc
+currenciesDisplayName.XFO=\u6cd5\u570b\u91d1\u6cd5\u90ce
+currenciesDisplayName.PGK=\u5df4\u5e03\u4e9e\u7d10\u5e7e\u5167\u4e9e\u57fa\u90a3
+currenciesDisplayName.SYP=\u6558\u5229\u4e9e\u938a
+currenciesDisplayName.MZE=\u83ab\u6851\u6bd4\u514b\u57c3\u65af\u5eab\u591a
+currenciesDisplayName.OMR=\u963f\u66fc\u91cc\u5967
+currenciesDisplayName.NGN=\u5948\u53ca\u5229\u4e9e\u5948\u62c9
+currenciesDisplayName.ZRN=\u85a9\u4f0a\u624e\u65b0\u4f0a\u723e
+currenciesDisplayName.AOA=\u5b89\u54e5\u62c9\u5bec\u624e
+currenciesDisplayName.CNY=\u4eba\u6c11\u5e63
+currenciesDisplayName.GNF=\u5e7e\u5167\u4e9e\u6cd5\u90ce
+currenciesDisplayName.MMK=\u7dec\u7538\u5143
+currenciesDisplayName.MYR=\u99ac\u4f86\u897f\u4e9e - \u6797\u5409\u7279
+currenciesDisplayName.LSL=\u8cf4\u7d22\u6258\u7f85\u8482
+currenciesDisplayName.XEU=\u6b50\u6d32\u8ca8\u5e63\u55ae\u4f4d
+currenciesDisplayName.BHD=\u5df4\u6797\u7b2c\u7d0d\u723e
+currenciesDisplayName.SLL=\u7345\u5b50\u5c71\u5229\u6602
+currenciesDisplayName.KMF=\u79d1\u6469\u7f85\u6cd5\u90ce
+currenciesDisplayName.ANG=\u8377\u862d \u5b89\u68af\u862d \u76fe
+currenciesDisplayName.CZK=\u6377\u514b\u514b\u6717
+currenciesDisplayName.AZM=\u963f\u585e\u62dc\u5f4a\u99ac\u7279\u7d0d
+currenciesDisplayName.KYD=\u958b\u66fc\u7fa4\u5cf6\u7f8e\u5143
+currenciesDisplayName.GMD=\u7518\u6bd4\u4e9e\u9054\u62c9\u897f
+currenciesDisplayName.BGN=\u4fdd\u52a0\u5229\u4e9e\u65b0\u5217\u5f17
+currenciesDisplayName.CAD=\u52a0\u5e63
+currenciesDisplayName.MXV=\u58a8\u897f\u54e5\u6cd5\u5f8b\u53cd\u8f49(UDI)
+currenciesDisplayName.BGL=\u4fdd\u52a0\u5229\u4e9e\u786c\u5217\u5f17
+currenciesDisplayName.VEB=\u59d4\u5167\u745e\u62c9\u535a\u5229\u74e6
+currenciesDisplayName.MLF=\u99ac\u91cc\u6cd5\u90ce
+currenciesDisplayName.ILS=\u4ee5\u8272\u5217\u65b0\u8b1d\u514b\u723e
+currenciesDisplayName.MXP=\u58a8\u897f\u54e5\u9280\u62ab\u7d22 (1861-1992)
+currenciesDisplayName.PES=\u79d8\u9b6f\u592a\u967d\u5e63
+currenciesDisplayName.GYD=\u572d\u4e9e\u90a3\u5143
+currenciesDisplayName.MXN=\u58a8\u897f\u54e5 - \u62ab\u7d22
+currenciesDisplayName.ILP=\u4ee5\u8272\u5217\u938a
+currenciesDisplayName.SKK=\u65af\u6d1b\u4f10\u514b\u514b\u6717
+currenciesDisplayName.CYP=\u8cfd\u6d66\u8def\u65af\u938a
+currenciesDisplayName.XDR=\u7279\u6b8a\u63d0\u6b3e\u6b0a
+currenciesDisplayName.PEN=\u79d8\u9b6f\u65b0\u592a\u967d\u5e63
+currenciesDisplayName.LRD=\u8cf4\u6bd4\u745e\u4e9e\u5143
+currenciesDisplayName.PEI=\u7955\u9b6f\u56e0\u8482
+currenciesDisplayName.AMD=\u4e9e\u7f8e\u5c3c\u4e9e\u5fb7\u62c9\u59c6
+currenciesDisplayName.BSD=\u5df4\u54c8\u99ac\u5143
+currenciesDisplayName.HRK=\u514b\u7f85\u5730\u4e9e\u5eab\u7d0d
+currenciesDisplayName.CLP=\u667a\u5229\u62ab\u7d22
+currenciesDisplayName.HRD=\u514b\u7f85\u5730\u4e9e\u7b2c\u7d0d\u723e
+currenciesDisplayName.XPF=CFP \u6cd5\u90ce
+currenciesDisplayName.FRF=\u6cd5\u570b\u6cd5\u90ce
+currenciesDisplayName.BRR=\u5df4\u897f\u514b\u9b6f\u8cfd\u7f85
+currenciesDisplayName.MKD=\u99ac\u5176\u9813\u7b2c\u7d0d\u723e
+currenciesDisplayName.CLF=\u5361\u6797\u6cb9\u9054\u4f5b\u66fc\u8dce
+currenciesDisplayName.ALL=\u963f\u723e\u5df4\u5c3c\u4e9e\u5217\u514b
+currenciesDisplayName.BRN=\u5df4\u897f \u514b\u5982\u723e\u9054 \u8fb2\u74e6
+currenciesDisplayName.MWK=\u99ac\u62c9\u7dad\u514b\u74e6\u67e5
+currenciesDisplayName.BRL=\u5df4\u897f\u91cc\u62c9
+currenciesDisplayName.TPE=\u5e1d\u6c76 \u57c3\u65af\u5eab\u591a
+currenciesDisplayName.BRE=\u5df4\u897f\u514b\u9b6f\u8cfd\u7f85 (1990-1993)
+currenciesDisplayName.BRC=\u5df4\u897f\u514b\u9b6f\u8cfd\u7f85 (1986-1989)
+currenciesDisplayName.BRB=\u5df4\u897f\u514b\u9b6f\u85a9\u591a \u8fb2\u74e6 (1967-1986)
+currenciesDisplayName.DEM=\u5fb7\u570b\u99ac\u514b
+currenciesDisplayName.KWD=\u79d1\u5a01\u7279\u7b2c\u7d0d\u723e
+currenciesDisplayName.XCD=\u683c\u745e\u90a3\u9054\u5143
+currenciesDisplayName.NPR=\u5c3c\u6cca\u723e\u76e7\u5e03
+currenciesDisplayName.GWP=\u5e7e\u5167\u4e9e\u62ab\u7d22\u62ab\u7d22
+currenciesDisplayName.YUN=\u5357\u65af\u62c9\u592b \u53ef\u8f49\u63db\u7b2c\u7d0d\u723e
+currenciesDisplayName.SVC=\u611b\u723e \u85a9\u723e\u74e6\u591a\u79d1\u90ce
+currenciesDisplayName.YUM=\u5357\u65af\u62c9\u592b\u632a\u5a01\u4e9e\u7b2c\u7d0d\u723e
+currenciesDisplayName.BEL=\u6bd4\u5229\u6642\u6cd5\u90ce \uff08\u91d1\u878d\uff09
+currenciesDisplayName.SIT=\u65af\u6d1b\u7dad\u5c3c\u4e9e\u6258\u52d2
+currenciesDisplayName.JPY=\u65e5\u5713
+currenciesDisplayName.XOF=\u897f\u975e \u6cd5\u90ce BCEAO
+currenciesDisplayName.MVR=\u99ac\u723e\u5730\u592b\u6d77\u5cf6\u76e7\u975e\u4e9e
+currenciesDisplayName.GWE=\u8461\u5c6c\u5e7e\u5167\u4e9e\u57c3\u65af\u5eab\u591a
+currenciesDisplayName.BEF=\u6bd4\u5229\u6642\u6cd5\u90ce
+currenciesDisplayName.TOP=\u6771\u52a0\u6f58\u52a0
+currenciesDisplayName.YUD=\u5357\u65af\u62c9\u592b\u7b2c\u7d0d\u723e\u786c\u5e63
+currenciesDisplayName.BEC=\u6bd4\u5229\u6642\u6cd5\u90ce \uff08\u53ef\u8f49\u63db\uff09
+currenciesDisplayName.SUR=\u8607\u806f\u76e7\u5e03
+currenciesDisplayName.ROL=\u7f85\u99ac\u5c3c\u4e9e\u5217\u4f0a
+currenciesDisplayName.DDM=\u6771\u5fb7\u6771\u5fb7\u99ac\u514b
+currenciesDisplayName.BDT=\u5b5f\u52a0\u62c9\u5854\u5361
+currenciesDisplayName.XBD=\u6b50\u6d32\u6703\u8a08\u55ae\u4f4d(XBD)
+currenciesDisplayName.AWG=\u963f\u9b6f\u5df4\u76fe
+currenciesDisplayName.XBC=\u6b50\u6d32\u6703\u8a08\u55ae\u4f4d(XBC)
+currenciesDisplayName.XBB=\u6b50\u6d32\u8ca8\u5e63\u55ae\u4f4d
+currenciesDisplayName.XBA=\u6b50\u6d32\u7d9c\u5408\u55ae\u4f4d
+currenciesDisplayName.NOK=\u632a\u5a01\u514b\u7f85\u7d0d
+currenciesDisplayName.MUR=\u6a21\u91cc\u897f\u65af\u76e7\u5e03
+currenciesDisplayName.ZAR=\u5357\u975e\u862d\u7279
+currenciesDisplayName.SHP=\u8056\u8d6b\u52d2\u62ff \u938a
+currenciesDisplayName.XAU=\u9ec3\u91d1
+currenciesDisplayName.ZAL=\u5357\u975e - \u862d\u7279 (\u91d1\u878d)
+currenciesDisplayName.TZS=\u5766\u6851\u5c3c\u4e9e \u5148\u4ee4
+currenciesDisplayName.GIP=\u76f4\u5e03\u7f85\u9640\u938a
+currenciesDisplayName.TND=\u7a81\u5c3c\u897f\u4e9e\u7b2c\u7d0d\u723e
+currenciesDisplayName.CVE=\u7dad\u5fb7\u89d2\u57c3\u65af\u5eab\u591a
+currenciesDisplayName.UGX=\u70cf\u5e72\u9054\u5148\u4ee4
+currenciesDisplayName.ZMK=\u5c1a\u6bd4\u4e9e\u514b\u74e6\u67e5
+currenciesDisplayName.JOD=\u7d04\u65e6\u7b2c\u7d0d\u723e
+currenciesDisplayName.XAF=\u897f\u975e \u6cd5\u90ce BEAC
+currenciesDisplayName.LBP=\u9ece\u5df4\u5ae9\u938a
+currenciesDisplayName.UGS=\u70cf\u5e72\u9054\u5148\u4ee4 (1966-1987)
+currenciesDisplayName.STD=\u8056\u591a\u7f8e\u5cf6\u548c\u666e\u6797\u897f\u6bd4\u5cf6\u591a\u5e03\u62c9
+currenciesDisplayName.WST=\u897f\u85a9\u6469\u4e9e\u5854\u62c9
+currenciesDisplayName.KHR=\u67ec\u57d4\u5be8\u745e\u723e
+currenciesDisplayName.EUR=\u6b50\u5143
+currenciesDisplayName.DOP=\u591a\u660e\u5c3c\u52a0\u62ab\u7d22
+currenciesDisplayName.BOV=\u73bb\u5229\u7dad\u4e9e \u5e55\u591a
+currenciesDisplayName.MTP=\u99ac\u723e\u4ed6\u938a
+currenciesDisplayName.BOP=\u73bb\u5229\u7dad\u4e9e\u62ab\u7d22
+currenciesDisplayName.MTL=\u99ac\u723e\u4ed6\u91cc\u62c9
+currenciesDisplayName.CUP=\u53e4\u5df4\u62ab\u7d22
+currenciesDisplayName.TMM=\u571f\u5eab\u66fc\u99ac\u7d0d\u7279
+currenciesDisplayName.USN=\u7f8e\u5143 (\u7b2c\u4e8c\u5929)
+currenciesDisplayName.SGD=\u65b0\u52a0\u5761\u5e63
+currenciesDisplayName.NZD=\u7d10\u897f\u862d\u5e63
+currenciesDisplayName.HNL=\u6d2a\u90fd\u62c9\u65af\u502b\u76ae\u62c9
+currenciesDisplayName.BOB=\u73bb\u5229\u7dad\u4e9e\u8ca8\u5e63\u55ae\u4f4d
+currenciesDisplayName.ITL=\u7fa9\u5927\u5229\u91cc\u62c9
+currenciesDisplayName.PAB=\u5df4\u62ff\u99ac\u5df4\u6ce2\u4e9e
+currenciesDisplayName.GTQ=\u74dc\u5730\u99ac\u62c9\u683c\u67e5\u723e
+currenciesDisplayName.LAK=\u8001\u64be \u958b\u666e
+currenciesDisplayName.GHC=\u8fe6\u7d0d\u4ed9\u8515
+currenciesDisplayName.AUD=\u6fb3\u5e63
+currenciesDisplayName.NAD=\u7d0d\u7c73\u6bd4\u4e9e\u5143
+currenciesDisplayName.KGS=\u5409\u723e\u5409\u65af\u7d22\u99ac
+currenciesDisplayName.MGF=\u99ac\u9054\u52a0\u65af\u52a0\u6cd5\u90ce
+currenciesDisplayName.BBD=\u5df4\u8c9d\u591a\u5143
+currenciesDisplayName.MGA=\u99ac\u9054\u52a0\u65af\u52a0\u827e\u745e\u723e
+currenciesDisplayName.PYG=\u5df4\u62c9\u572d\u74dc\u62c9\u5c3c
+currenciesDisplayName.PLZ=\u6ce2\u862d\u8332\u7f85\u63d0 (1950-1995)
+currenciesDisplayName.YER=\u4e5f\u9580\u91cc\u4e9e\u723e
+currenciesDisplayName.ATS=\u5967\u5730\u5229\u5148\u4ee4
+currenciesDisplayName.ETB=\u8863\u7d22\u6bd4\u4e9e\u6bd4\u723e
+currenciesDisplayName.BND=\u6c76\u840a\u5143
+currenciesDisplayName.JMD=\u7259\u8cb7\u52a0\u5143
+currenciesDisplayName.EGP=\u57c3\u53ca\u938a
+currenciesDisplayName.PLN=\u6ce2\u862d\u8332\u7f85\u63d0
+currenciesDisplayName.DZD=\u963f\u723e\u53ca\u5229\u4e9e\u7b2c\u7d0d\u723e
+currenciesDisplayName.ISK=\u51b0\u5cf6\u514b\u6717
+currenciesDisplayName.SRG=\u8607\u91cc\u5357\u76fe
+currenciesDisplayName.LYD=\u5229\u6bd4\u4e9e\u7b2c\u7d0d\u723e
+currenciesDisplayName.BZD=\u4f2f\u5229\u8332\u5143
+currenciesDisplayName.BAM=\u6ce2\u58eb\u5c3c\u4e9e-\u9ed1\u585e\u54e5\u7dad\u90a3\u53ef\u8f49\u63db\u99ac\u514b
+currenciesDisplayName.ESP=\u897f\u73ed\u7259\u966a\u58eb\u7279
+currenciesDisplayName.KRW=\u97d3\u570b\u571c
+currenciesDisplayName.NLG=\u8377\u862d\u76fe
+currenciesDisplayName.MRO=\u8305\u5229\u5854\u5c3c\u4e9e\u70cf\u5409\u4e9e
+currenciesDisplayName.BAD=\u6ce2\u58eb\u5c3c\u4e9e-\u9ed1\u585e\u54e5\u7dad\u90a3\u7b2c\u7d0d\u723e
+currenciesDisplayName.ZWD=\u8f9b\u5df4\u5a01\u5143
+currenciesDisplayName.SEK=\u745e\u5178\u514b\u7f85\u7d0d
+currenciesDisplayName.CSK=\u6377\u514b\u65af\u6d1b\u4f10\u514b\u786c\u514b\u6717
+currenciesDisplayName.BYR=\u767d\u4fc4\u7f85\u65af\u76e7\u5e03
+currenciesDisplayName.IRR=\u4f0a\u6717\u91cc\u4e9e\u723e
+currenciesDisplayName.PKR=\u5df4\u57fa\u65af\u5766\u76e7\u5e03
+currenciesDisplayName.BMD=\u767e\u6155\u9054\u5e63
+currenciesSymbol.MOP=MOP
+currenciesSymbol.SGD=SGD
+currenciesSymbol.KRW=KRW
+currenciesSymbol.NZD=$NZ
+currenciesSymbol.EUR=EUR
+currenciesSymbol.GBP=GBP
+shortDateFormat=yyyy/M/d
+mediumDateFormat=yyyy/M/d
+longDateFormat=yyyy'\u5e74'M'\u6708'd'\u65e5'
+fullDateFormat=yyyy'\u5e74'M'\u6708'd'\u65e5'EEEE
+shortTimeFormat=a h:mm
+mediumTimeFormat=a h:mm:ss
+longTimeFormat=ahh'\u6642'mm'\u5206'ss'\u79d2'
+fullTimeFormat=ahh'\u6642'mm'\u5206'ss'\u79d2' z
+zoneStrings=America/Halifax®\u5927\u897f\u6d0b\u6a19\u6e96\u6642\u9593®\u5927\u897f\u6d0b\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©America/Indianapolis®\u6771\u90e8\u6a19\u6e96\u6642\u9593®\u6771\u90e8\u6a19\u6e96\u6642\u9593®©Europe/Paris®\u4e2d\u6b50\u6a19\u6e96\u6642\u9593®\u4e2d\u6b50\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©America/Phoenix®\u5c71\u5340\u6a19\u6e96\u6642\u9593®\u5c71\u5340\u6a19\u6e96\u6642\u9593®©America/Los_Angeles®\u592a\u5e73\u6d0b\u6a19\u6e96\u6642\u9593®\u592a\u5e73\u6d0b\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©Pacific/Honolulu®\u590f\u5a01\u5937\u6a19\u6e96\u6642\u9593®\u590f\u5a01\u5937\u6a19\u6e96\u6642\u9593®©America/Denver®\u5c71\u5340\u6a19\u6e96\u6642\u9593®\u5c71\u5340\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©Europe/Bucharest®\u6771\u6b50\u6a19\u6e96\u6642\u9593®\u6771\u6b50\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©America/New_York®\u6771\u90e8\u6a19\u6e96\u6642\u9593®\u6771\u90e8\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©Asia/!
 Tokyo®\u65e5\u672c\u6a19\u6e96\u6642\u9593®\u65e5\u672c\u6a19\u6e96\u6642\u9593®©America/Anchorage®\u963f\u62c9\u65af\u52a0\u6a19\u6e96\u6642\u9593®\u963f\u62c9\u65af\u52a0\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©Asia/Shanghai®\u4e2d\u570b\u6a19\u6e96\u6642\u9593®\u4e2d\u570b\u6a19\u6e96\u6642\u9593®©America/Chicago®\u4e2d\u90e8\u6a19\u6e96\u6642\u9593®\u4e2d\u90e8\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©Africa/Casablanca®\u683c\u6797\u5a01\u6cbb\u6a19\u6e96\u6642\u9593®\u683c\u6797\u5a01\u6cbb\u6a19\u6e96\u6642\u9593®©America/St_Johns®\u7d10\u82ac\u862d\u6a19\u6e96\u6642\u9593®\u7d10\u82ac\u862d\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©Asia/Jerusalem®\u4ee5\u8272\u5217\u6a19\u6e96\u6642\u9593®\u4ee5\u8272\u5217\u65e5\u5149\u7bc0\u7d04\u6642\u9593®©
+territories.TL=\u6771\u5e1d\u6587
+territories.TK=\u6258\u514b\u52de\u7fa4\u5cf6
+territories.TJ=\u5854\u5409\u514b
+territories.TH=\u6cf0\u570b
+territories.TG=\u591a\u54e5\u5171\u548c\u570b
+territories.TF=\u6cd5\u570b\u5357\u5c6c\u5730
+territories.GY=\u84cb\u4e9e\u7d0d
+territories.TD=\u67e5\u5fb7
+territories.TC=\u571f\u514b\u65af\u53ca\u958b\u79d1\u65af\u7fa4\u5cf6
+territories.GW=\u5e7e\u5167\u4e9e\u6bd4\u7d22
+territories.GU=\u95dc\u5cf6
+territories.GT=\u74dc\u5730\u99ac\u62c9
+territories.GS=\u5357\u55ac\u6cbb\u4e9e\u8207\u5357\u4e09\u660e\u6cbb\u7fa4\u5cf6
+territories.GR=\u5e0c\u81d8
+territories.GQ=\u8d64\u9053\u5e7e\u5167\u4e9e
+territories.GP=\u54e5\u5fb7\u666e\u6d1b
+territories.SZ=\u53f2\u74e6\u6fdf\u862d
+territories.SY=\u6558\u5229\u4e9e
+territories.GN=\u5e7e\u5167\u4e9e
+territories.GM=\u7518\u6bd4\u4e9e
+territories.GL=\u683c\u9675\u862d
+territories.SV=\u85a9\u723e\u74e6\u591a
+territories.062=\u4e2d\u5357\u4e9e
+territories.ST=\u8056\u591a\u7f8e\u53ca\u666e\u6797\u897f\u6bd4
+territories.061=\u73bb\u91cc\u5c3c\u897f\u4e9e
+territories.GI=\u76f4\u5e03\u7f85\u9640
+territories.GH=\u8fe6\u7d0d
+territories.SR=\u8607\u5229\u5357
+territories.GF=\u6cd5\u5c6c\u572d\u4e9e\u90a3
+territories.GE=\u55ac\u6cbb\u4e9e\u5171\u548c\u570b
+territories.SO=\u7d22\u99ac\u5229\u4e9e
+territories.GD=\u683c\u745e\u7d0d\u9054
+territories.SN=\u585e\u5167\u52a0\u723e
+territories.SM=\u8056\u99ac\u5229\u8afe
+territories.GB=\u82f1\u570b
+territories.SL=\u7345\u5b50\u5c71
+territories.GA=\u52a0\u5f6d
+territories.SJ=\u51b7\u5cb8\u53ca\u592e\u9ea5\u6069\u7fa4\u5cf6
+territories.SI=\u65af\u6d1b\u7dad\u5c3c\u4e9e
+territories.SH=\u8056\u8d6b\u52d2\u62ff\u5cf6
+territories.SD=\u8607\u4e39
+territories.SC=\u585e\u5e2d\u723e
+territories.SB=\u7d22\u7f85\u9580\u7fa4\u5cf6
+territories.SA=\u6c99\u70cf\u5730\u963f\u62c9\u4f2f
+territories.FR=\u6cd5\u570b
+territories.057=\u5bc6\u514b\u7f85\u5c3c\u897f\u4e9e
+territories.FO=\u6cd5\u7f85\u7fa4\u5cf6
+territories.FM=\u5bc6\u514b\u7f85\u5c3c\u897f\u4e9e\u7fa4\u5cf6
+territories.RW=\u76e7\u5b89\u9054
+territories.054=\u7f8e\u62c9\u5c3c\u897f\u4e9e
+territories.053=\u6fb3\u6d32\u8207\u7d10\u897f\u862d
+territories.FK=\u798f\u514b\u862d\u7fa4\u5cf6
+territories.RU=\u4fc4\u7f85\u65af
+territories.FJ=\u6590\u6fdf
+territories.FI=\u82ac\u862d
+territories.RO=\u7f85\u99ac\u5c3c\u4e9e
+territories.RE=\u7559\u5c3c\u65fa
+territories.ET=\u8863\u7d22\u6bd4\u4e9e
+territories.ER=\u5384\u5229\u5782\u4e9e
+territories.833=\u66fc\u5cf6
+territories.830=\u6d77\u5cfd\u7fa4\u5cf6
+territories.EE=\u611b\u6c99\u5c3c\u4e9e
+territories.QO=\u5927\u6d0b\u6d32\u908a\u7586\u7fa4\u5cf6
+territories.EC=\u5384\u74dc\u591a\u723e
+territories.DZ=\u963f\u723e\u53ca\u5229\u4e9e
+territories.QA=\u5361\u9054
+territories.039=\u5357\u6b50
+territories.DO=\u591a\u660e\u5c3c\u52a0\u5171\u548c\u570b
+territories.035=\u6771\u5357\u4e9e
+territories.DM=\u591a\u660e\u5c3c\u52a0
+territories.PW=\u5e1b\u7409
+territories.DK=\u4e39\u9ea5
+territories.DJ=\u5409\u5e03\u5730
+territories.PS=\u5df4\u52d2\u65af\u5766
+territories.030=\u6771\u4e9e
+territories.PR=\u73bb\u591a\u9ece\u514b
+territories.DE=\u5fb7\u570b
+territories.PN=\u76ae\u7279\u5eb7
+territories.PM=\u8056\u5f7c\u5fb7\u8207\u5bc6\u555f\u5d19
+territories.PL=\u6ce2\u862d
+territories.PH=\u83f2\u5f8b\u8cd3
+territories.PG=\u5df4\u5e03\u4e9e\u7d10\u5e7e\u5167\u4e9e
+territories.PF=\u6cd5\u5c6c\u73bb\u91cc\u5c3c\u897f\u4e9e
+territories.CZ=\u6377\u514b\u5171\u548c\u570b
+territories.PE=\u79d8\u9b6f
+territories.CY=\u8cfd\u666e\u52d2\u65af
+territories.CX=\u8056\u8a95\u5cf6
+territories.CV=\u7dad\u5fb7\u89d2
+territories.PA=\u5df4\u62ff\u99ac
+territories.CS=\u585e\u723e\u7dad\u4e9e\u548c\u8499\u7279\u5c3c\u54e5\u7f85
+territories.CR=\u54e5\u65af\u5927\u9ece\u52a0
+territories.CO=\u54e5\u502b\u6bd4\u4e9e
+territories.CN=\u4e2d\u83ef\u4eba\u6c11\u5171\u548c\u570b
+territories.CM=\u5580\u9ea5\u9686
+territories.CK=\u5eab\u514b\u7fa4\u5cf6
+territories.CI=\u79d1\u7279\u8fea\u74e6
+territories.CG=\u525b\u679c
+territories.CF=\u4e2d\u975e\u5171\u548c\u570b
+territories.CD=\u525b\u679c\u6c11\u4e3b\u5171\u548c\u570b
+territories.CC=\u53ef\u53ef\u65af\u7fa4\u5cf6
+territories.OM=\u963f\u66fc\u738b\u570b
+territories.BZ=\u8c9d\u91cc\u65af
+territories.BY=\u767d\u4fc4\u7f85\u65af
+territories.BW=\u6ce2\u672d\u90a3
+territories.BV=\u5e03\u5a01\u5cf6
+territories.BS=\u5df4\u54c8\u99ac
+territories.NZ=\u7d10\u897f\u862d
+territories.BO=\u73bb\u5229\u7dad\u4e9e
+territories.BN=\u6c76\u840a
+territories.BM=\u767e\u6155\u9054
+territories.014=\u6771\u975e
+territories.NU=\u7d10\u5a01\u5cf6
+territories.BJ=\u8c9d\u5357
+territories.BI=\u6d66\u9686\u5730
+territories.NR=\u8afe\u9b6f
+territories.BG=\u4fdd\u52a0\u5229\u4e9e
+territories.BF=\u5e03\u57fa\u7d0d\u6cd5\u7d22
+territories.NP=\u5c3c\u6cca\u723e
+territories.BE=\u6bd4\u5229\u6642
+territories.BD=\u5b5f\u52a0\u62c9
+territories.BB=\u5df4\u8c9d\u591a
+territories.ZW=\u8f9b\u5df4\u5a01
+territories.NL=\u8377\u862d
+territories.BA=\u6ce2\u58eb\u5c3c\u4e9e\u8207\u8d6b\u585e\u683c\u7dad\u7d0d
+territories.NG=\u5948\u53ca\u5229\u4e9e
+territories.NF=\u8afe\u798f\u514b\u5cf6
+territories.AZ=\u4e9e\u585e\u62dc\u7136
+territories.NE=\u5c3c\u65e5
+territories.AX=\u4e9e\u862d\u7fa4\u5cf6
+territories.NC=\u65b0\u5580\u91cc\u591a\u5c3c\u4e9e\u7fa4\u5cf6
+territories.AW=\u963f\u8def\u5df4
+territories.ZM=\u5c1a\u6bd4\u4e9e
+territories.NA=\u7d0d\u7c73\u6bd4\u4e9e
+territories.AU=\u6fb3\u6d32
+territories.AT=\u5967\u5730\u5229
+territories.AS=\u7f8e\u5c6c\u85a9\u6469\u4e9e\u7fa4\u5cf6
+territories.AQ=\u5357\u6975\u6d32
+territories.MZ=\u83ab\u4e09\u6bd4\u514b
+territories.AN=\u8377\u5c6c\u5b89\u5730\u5217\u65af
+territories.MY=\u99ac\u4f86\u897f\u4e9e
+territories.AM=\u4e9e\u7f8e\u5c3c\u4e9e
+territories.AL=\u963f\u723e\u5df4\u5c3c\u4e9e
+territories.MW=\u99ac\u62c9\u5a01
+territories.MV=\u99ac\u723e\u5730\u592b
+territories.MU=\u6a21\u91cc\u897f\u65af
+territories.AI=\u5b89\u572d\u62c9\u5cf6
+territories.MT=\u99ac\u723e\u4ed6
+territories.MS=\u8499\u7279\u8272\u62c9\u7279\u5cf6
+territories.AG=\u5b89\u5730\u5361\u53ca\u5df4\u5e03\u9054
+territories.MR=\u8305\u5229\u5854\u5c3c\u4e9e
+territories.MQ=\u99ac\u4e01\u5c3c\u514b\u5cf6
+territories.AE=\u963f\u62c9\u4f2f\u806f\u5408\u5927\u516c\u570b
+territories.MP=\u5317\u99ac\u91cc\u5b89\u7d0d
+territories.AD=\u5b89\u9053\u723e
+territories.MO=\u4e2d\u83ef\u4eba\u6c11\u5171\u548c\u570b\u6fb3\u9580\u7279\u5225\u884c\u653f\u5340
+territories.MM=\u7dec\u7538
+territories.ML=\u99ac\u5229
+territories.MK=\u99ac\u5176\u9813
+territories.YT=\u99ac\u7d04\u7279
+territories.MH=\u99ac\u7d39\u723e\u7fa4\u5cf6
+territories.MG=\u99ac\u9054\u52a0\u65af\u52a0
+territories.MD=\u6469\u723e\u591a\u74e6
+territories.MC=\u6469\u7d0d\u54e5
+territories.YE=\u8449\u9580
+territories.LY=\u5229\u6bd4\u4e9e
+territories.155=\u897f\u6b50
+territories.LV=\u62c9\u812b\u7dad\u4e9e
+territories.154=\u5317\u6b50
+territories.LU=\u76e7\u68ee\u5821
+territories.LS=\u8cf4\u7d22\u6265
+territories.151=\u6771\u6b50
+territories.LR=\u8cf4\u6bd4\u745e\u4e9e
+territories.150=\u6b50\u6d32
+territories.LK=\u65af\u91cc\u862d\u5361
+territories.LI=\u5217\u652f\u6566\u65af\u767b
+territories.LC=\u8056\u9732\u897f\u4e9e
+territories.LA=\u5bee\u570b
+territories.KZ=\u54c8\u85a9\u514b
+territories.KY=\u958b\u66fc\u7fa4\u5cf6
+territories.145=\u897f\u4e9e
+territories.142=\u4e9e\u6d32
+territories.KR=\u5357\u97d3
+territories.KP=\u5317\u97d3
+territories.KN=\u8056\u514b\u91cc\u65af\u591a\u798f\u53ca\u5c3c\u7dad\u65af
+territories.KM=\u79d1\u6469\u7f85\u7fa4\u5cf6
+territories.KI=\u5409\u91cc\u5df4\u65af
+territories.WS=\u85a9\u6469\u4e9e\u7fa4\u5cf6
+territories.KH=\u9ad8\u68c9
+territories.KG=\u5409\u723e\u5409\u65af
+territories.KE=\u80af\u4e9e
+territories.WF=\u74e6\u5229\u65af\u548c\u798f\u675c\u7d0d\u7fa4\u5cf6
+territories.JO=\u7d04\u65e6
+territories.JM=\u7259\u8cb7\u52a0
+territories.VU=\u842c\u90a3\u675c
+territories.VI=\u7f8e\u5c6c\u7dad\u723e\u4eac\u7fa4\u5cf6
+territories.VG=\u82f1\u5c6c\u7dad\u723e\u4eac\u7fa4\u5cf6
+territories.VE=\u59d4\u5167\u745e\u62c9
+territories.VC=\u8056\u6587\u68ee\u53ca\u683c\u745e\u90a3\u4e01
+territories.VA=\u68b5\u5e1d\u5ca1
+territories.IT=\u7fa9\u5927\u5229
+territories.IS=\u51b0\u5cf6
+territories.UZ=\u70cf\u8332\u5225\u514b
+territories.IO=\u82f1\u5c6c\u5370\u5ea6\u6d0b\u9818\u571f
+territories.UY=\u70cf\u62c9\u572d
+territories.US=\u7f8e\u570b
+territories.IE=\u611b\u723e\u862d
+territories.ID=\u5370\u5c3c
+territories.UM=\u7f8e\u5c6c\u908a\u7586\u7fa4\u5cf6
+territories.UG=\u70cf\u5e72\u9054
+territories.UA=\u70cf\u514b\u862d
+territories.HR=\u514b\u7f85\u57c3\u897f\u4e9e
+territories.TZ=\u5766\u5c1a\u5c3c\u4e9e
+territories.HN=\u5b8f\u90fd\u62c9\u65af
+territories.HM=\u8d6b\u5fb7\u8207\u9ea5\u514b\u7576\u8afe\u7fa4\u5cf6
+territories.TW=\u81fa\u7063
+territories.TV=\u5410\u74e6\u9b6f
+territories.HK=\u4e2d\u83ef\u4eba\u6c11\u5171\u548c\u570b\u9999\u6e2f\u7279\u5225\u884c\u653f\u5340
+territories.TT=\u5343\u91cc\u9054\u53ca\u6258\u5df4\u54e5
+territories.TO=\u6771\u52a0
+territories.TN=\u7a81\u5c3c\u897f\u4e9e
+territories.TM=\u571f\u5eab\u66fc
+languages.gwi=\u572d\u5951\u6587
+languages.eka=\u827e\u5361\u6731\u514b\u6587
+languages.ijo=\u4f0a\u55ac\u6587
+languages.xh=\u73ed\u5716\u6587
+languages.sux=\u8607\u7f8e\u6587
+languages.sus=\u8607\u8607\u6587
+languages.mis=\u5176\u4ed6\u8a9e\u8a00
+languages.loz=\u6d1b\u9f4a\u6587
+languages.tog=\u6e6f\u52a0\u6587(\u5c3c\u4e9e\u85a9\u6587)
+languages.pon=\u6ce2\u90a3\u8c9d\u6587
+languages.min=\u7c73\u5357\u5361\u5821\u6587
+languages.suk=\u8607\u5eab\u99ac\u6587
+languages.wo=\u6c83\u723e\u592b\u6587
+languages.kut=\u5eab\u7279\u5948\u6587
+languages.mic=\u7c73\u514b\u99ac\u514b\u6587
+languages.wa=\u74e6\u9686\u6587
+languages.kum=\u5eab\u5bc6\u514b\u6587
+languages.zap=\u85a9\u6ce2\u7279\u514b\u6587
+languages.cus=\u5eab\u65bd\u7279\u8a9e\u7cfb\uff08\u5176\u4ed6\uff09
+languages.doi=\u591a\u683c\u4f86\u6587
+languages.jbo=\u908f\u8f2f\u6587
+languages.oto=\u5967\u6258\u7c73\u6587
+languages.vai=\u8d8a\u5357\u6587
+languages.rar=\u62c9\u7f85\u901a\u52a0\u6587
+languages.ve=\u6eab\u9054\u6587
+languages.rap=\u5fa9\u6d3b\u5cf6\u6587
+languages.raj=\u62c9\u8cc8\u65af\u5766\u8af8\u6587
+languages.nzi=\u5c3c\u8332\u99ac\u6587
+languages.ota=\u9102\u5716\u66fc\u571f\u8033\u5176\u6587 (1500-1928)
+languages.uz=\u70cf\u8332\u5225\u514b\u6587
+languages.uga=\u70cf\u52a0\u5217\u6587
+languages.tmh=\u5854\u99ac\u5947\u514b\u6587
+languages.nai=\u5176\u4ed6\u5317\u7f8e\u5370\u5730\u5b89\u6587
+languages.nah=\u7d0d\u74e6\u7279\u6587
+languages.ur=\u70cf\u723e\u90fd\u6587
+languages.uk=\u70cf\u514b\u862d\u6587
+languages.egy=\u53e4\u57c3\u53ca\u6587)
+languages.ug=\u7dad\u543e\u723e\u6587
+languages.fan=\u82b3\u65cf\u6587
+languages.ssa=\u975e\u6d32\u6492\u54c8\u62c9\u6c99\u6f20\u908a\u7de3\u5730\u5e36\u6587
+languages.bat=\u6ce2\u7f85\u7684\u6587\uff08\u5176\u4ed6\uff09
+languages.mga=\u611b\u723e\u862d\u6587\uff0c\u4e2d\u53e4 (900-1200)
+languages.bas=\u5df4\u85a9\u6587
+languages.nyo=\u5c3c\u5967\u56c9\u6587
+languages.nyn=\u5c3c\u63da\u79d1\u840a\u6587
+languages.nym=\u5c3c\u63da\u97cb\u9f4a\u6587
+languages.hmn=\u5b5f\u6587
+languages.ban=\u5df4\u5398\u6587
+languages.osa=\u6b50\u585e\u5947\u6587
+languages.ty=\u5927\u6eaa\u5730\u6587
+languages.tw=\u7e41\u9ad4\u4e2d\u6587
+languages.srr=\u585e\u96f7\u723e\u6587
+languages.tli=\u7279\u6797\u57fa\u7279\u6587
+languages.tt=\u97c3\u977c\u6587
+languages.bad=\u73ed\u9054\u6587
+languages.to=\u6771\u52a0\u6587
+languages.tn=\u7a81\u5c3c\u897f\u4e9e\u6587
+languages.tk=\u571f\u5eab\u66fc\u6587
+languages.ti=\u63d0\u683c\u5229\u5c3c\u4e9e\u6587
+languages.kru=\u5eab\u9b6f\u79d1\u6587
+languages.te=\u6cf0\u76e7\u56fa\u6587
+languages.csb=\u5361\u8212\u5e03\u6587
+languages.kro=\u514b\u9b6f\u6587
+languages.ta=\u5766\u7c73\u723e\u6587
+languages.tkl=\u6258\u514b\u52de\u6587
+languages.efi=\u57c3\u83f2\u514b\u6587
+languages.sw=\u53f2\u74e6\u5e0c\u91cc\u6587
+languages.su=\u8607\u4e39\u6587
+languages.krc=\u5361\u62c9\u67f4-\u5305\u723e\u5361\u723e\u6587
+languages.sr=\u585e\u723e\u7dad\u4e9e\u6587
+languages.sq=\u963f\u723e\u5df4\u5c3c\u4e9e\u6587
+languages.men=\u9580\u5fb7\u6587
+languages.crp=\u514b\u91cc\u5967\u723e\u6587\u548c\u76ae\u6b3d\u6587
+languages.so=\u7d22\u99ac\u5229\u6587
+languages.sn=\u585e\u5167\u52a0\u723e\u6587
+languages.sm=\u85a9\u6469\u4e9e\u6587
+languages.sl=\u65af\u6d1b\u7dad\u5c3c\u4e9e\u6587
+languages.grc=\u53e4\u5e0c\u81d8\u6587 (\u81f3 1453)
+languages.grb=\u54e5\u535a\u8a9e
+languages.si=\u50e7\u4f3d\u7f85\u6587
+languages.sh=\u585e\u723e\u7dad\u4e9e\u514b\u7f85\u57c3\u897f\u4e9e\u6587
+languages.afa=\u975e\u9583\u65cf\u53ca\u975e\u4e9e\u8a9e\u8a00
+languages.crh=\u514b\u91cc\u7c73\u4e9e\u534a\u5cf6\u7684\u571f\u8033\u5176\u6587\uff1b\u514b\u91cc\u7c73\u4e9e\u534a\u5cf6\u7684\u5854\u5854\u723e\u6587
+languages.se=\u5317\u65b9\u85a9\u7c73\u6587
+languages.sd=\u8607\u4e39\u6587
+languages.udm=\u6c83\u8482\u827e\u514b\u6587
+languages.sc=\u6492\u4e01\u6587
+languages.rw=\u76e7\u5b89\u9054\u6587
+languages.mdr=\u66fc\u9054\u6587
+languages.ro=\u7f85\u99ac\u5c3c\u4e9e\u6587
+languages.rm=\u91cc\u6258\u7f85\u66fc\u65af\u6587
+languages.tiv=\u63d0\u592b\u6587
+languages.ady=\u963f\u8fea\u5404\u6587
+languages.zun=\u7956\u5c3c\u6587
+languages.qu=\u84cb\u4e18\u4e9e\u6587
+languages.tig=\u8482\u683c\u96f7\u6587
+languages.cpp=\u6b50\u6d32\u8154\u8abf\u548c\u6d0b\u6d87\u6ff1\uff0c\u6e90\u81ea\u8461\u8404\u7259\u6587\u7684(\u5176\u4ed6)
+languages.sog=\u7d22\u683c\u5e95\u4e9e\u7d0d\u6587
+languages.ada=\u963f\u7576\u83ab\u6587
+languages.cpf=\u6b50\u6d32\u8154\u8abf\u548c\u6d0b\u6d87\u6ff1\uff0c\u6e90\u81ea\u6cd5\u6587\u7684(\u5176\u4ed6)
+languages.hit=\u8d6b\u68af\u6587
+languages.kos=\u79d1\u65af\u96f7\u6069\u6587
+languages.cpe=\u6b50\u6d32\u8154\u8abf\u548c\u6d0b\u6d87\u6ff1\uff0c\u6e90\u81ea\u82f1\u6587\u7684(\u5176\u4ed6)
+languages.him=\u8d6b\u99ac\u67e5\u5229\u6587
+languages.got=\u54e5\u7279\u6587
+languages.hil=\u5e0c\u5229\u84cb\u8fb2\u6587
+languages.kok=\u8ca2\u6839\u6587
+languages.gor=\u79d1\u9686\u9054\u7f85\u6587
+languages.gon=\u5ca1\u5fb7\u6587
+languages.nub=\u52aa\u6bd4\u4e9e\u6587
+languages.ps=\u666e\u4ec0\u5716\u6587
+languages.phn=\u8153\u5c3c\u57fa\u6587
+languages.goh=\u5fb7\u6587,\u4e0a\u53e4\u5168\u76db\u6642\u671f (ca.750-1050)
+languages.ach=\u963f\u50d1\u5229\u6587
+languages.yao=\u7464\u6587
+languages.phi=\u5176\u4ed6\u83f2\u5f8b\u8cd3\u6587
+languages.pl=\u6ce2\u862d\u6587
+languages.ace=\u4e9e\u9f4a\u6587
+languages.pi=\u5df4\u5229\u6587
+languages.bug=\u5e03\u5409\u65af\u6587
+languages.sms=\u65af\u79d1\u7279\u85a9\u7c73\u6587
+languages.bua=\u5e03\u91cc\u963f\u7279\u6587
+languages.mas=\u99ac\u8cfd\u6587
+languages.smn=\u4f0a\u7d0d\u88e1\u85a9\u7c73\u6587
+languages.os=\u5967\u585e\u63d0\u6587
+languages.map=\u5357\u5cf6\u6587
+languages.or=\u6b50\u91cc\u4e9e\u6587
+languages.smj=\u9b6f\u52d2\u85a9\u7c73\u6587
+languages.smi=\u5176\u4ed6\u85a9\u7c73\u6587
+languages.mak=\u671b\u52a0\u932b\u6587
+languages.mai=\u9081\u8482\u5229\u6587
+languages.oj=\u5967\u6770\u5e03\u74e6\u6587
+languages.mag=\u99ac\u52a0\u4f0a\u6587
+languages.mad=\u99ac\u90fd\u62c9\u6587
+languages.sma=\u5357\u85a9\u7c73\u6587
+languages.oc=\u5967\u897f\u5766\u6587
+languages.myv=\u5384\u723e\u8332\u4e9e\u6587
+languages.dgr=\u591a\u683c\u91cc\u5e03\u6587
+languages.ny=\u5c3c\u63da\u8cc8\u6587
+languages.myn=\u99ac\u96c5\u6587
+languages.nv=\u7d0d\u74e6\u7d04\u6587
+languages.nr=\u5357\u5730\u7562\u5217\u6587
+languages.gmh=\u5fb7\u6587, \u4e2d\u53e4\u5168\u76db\u6642\u671f (ca.1050-1500)
+languages.nn=\u65b0\u632a\u5a01\u6587
+languages.nl=\u8377\u862d\u6587
+languages.ng=\u6069\u6771\u52a0\u6587
+languages.sla=\u5176\u4ed6\u65af\u62c9\u592b\u6587
+languages.ne=\u5c3c\u6cca\u723e\u6587
+languages.nd=\u5317\u5730\u7562\u5217\u6587
+languages.tet=\u6cf0\u9813\u6587
+languages.nb=\u632a\u5a01\u6ce2\u514b\u9ed8\u723e\u6587
+languages.na=\u8afe\u9b6f\u6587
+languages.ter=\u6cf0\u96f7\u8afe\u6587
+languages.tem=\u63d0\u59c6\u6587
+languages.my=\u7dec\u7538\u6587
+languages.lez=\u7acb\u9676\u5b9b\u6587
+languages.mt=\u99ac\u723e\u4ed6\u6587
+languages.ms=\u99ac\u4f86\u6587
+languages.peo=\u53e4\u6ce2\u65af\u6587 (ca.600-400 B.C.)
+languages.mr=\u99ac\u62c9\u5730\u6587
+languages.mo=\u6469\u723e\u591a\u74e6\u6587
+languages.ml=\u99ac\u4f86\u4e9e\u62c9\u59c6\u6587
+languages.jrb=\u7336\u592a\u6559-\u963f\u62c9\u4f2f\u6587
+languages.mk=\u99ac\u5176\u9813\u6587
+languages.mh=\u99ac\u7d39\u723e\u6587
+languages.mg=\u99ac\u723e\u52a0\u4ec0\u6587
+languages.mwr=\u99ac\u723e\u5c3c\u88e1\u6587
+languages.den=\u65af\u62c9\u592b
+languages.lu=\u9b6f\u5df4\u52a0\u4e39\u52a0\u6587
+languages.del=\u5fb7\u62c9\u74e6
+languages.lo=\u5bee\u570b\u6587
+languages.li=\u6797\u5821\u6587
+languages.ewo=\u4f9d\u6c6a\u90fd\u6587
+languages.lg=\u5e72\u9054\u6587
+languages.lb=\u76e7\u68ee\u5821\u6587
+languages.jpr=\u7336\u592a\u6559-\u6ce2\u65af\u6587
+languages.sit=\u5176\u4ed6\u6f22\u85cf\u6587
+languages.ky=\u5409\u723e\u5409\u65af\u6587
+languages.kw=\u5eb7\u74e6\u8033\u6587
+languages.ku=\u5eab\u723e\u5fb7\u6587
+languages.sio=\u5927\u8607\u6587
+languages.ks=\u514b\u4ec0\u7c73\u723e\u6587
+languages.kr=\u5361\u52aa\u88e1\u6587
+languages.ko=\u97d3\u6587
+languages.kn=\u574e\u90a3\u9054\u6587
+languages.km=\u9ad8\u68c9\u6587
+languages.kl=\u683c\u9675\u862d\u6587
+languages.kk=\u54c8\u85a9\u514b\u6587
+languages.rom=\u5409\u666e\u8cfd\u6587
+languages.kj=\u5ee3\u4e9e\u99ac\u6587
+languages.sid=\u5e0c\u9054\u6469\u6587
+languages.ki=\u5409\u5eab\u5c24\u4eba
+languages.kg=\u525b\u679c\u6587
+languages.non=\u53e4\u8afe\u723e\u65af\u6587
+languages.ka=\u55ac\u6cbb\u4e9e\u6587
+languages.mus=\u514b\u91cc\u514b\u6587
+languages.roa=\u5176\u4ed6\u7f85\u66fc\u6587
+languages.nog=\u8afe\u84cb\u6587
+languages.mun=\u8499\u9054\u6587
+languages.mul=\u591a\u7a2e\u8a9e\u8a00
+languages.gil=\u5409\u723e\u4f2f\u7279\u7fa4\u5cf6\u6587
+languages.znd=\u8d0a\u5fb7\u6587
+languages.shn=\u64a3\u6587
+languages.fon=\u8c50\u6587
+languages.xal=\u5361\u723e\u6885\u514b\u6587
+languages.aus=\u6fb3\u6d32\u82f1\u6587
+languages.kho=\u548c\u95d0[\u8207\u95d0]\u6587
+languages.chy=\u6c99\u4f0a\u5b89\u6587
+languages.pau=\u5e1b\u7409\u6587
+languages.iu=\u56e0\u7d10\u7279\u6587
+languages.pap=\u5e15\u76ae\u963f\u9580\u6258\u6587
+languages.it=\u7fa9\u5927\u5229\u6587
+languages.sgn=\u624b\u8a9e
+languages.is=\u51b0\u5cf6\u6587
+languages.chr=\u67f4\u7f85\u57fa\u6587
+languages.pam=\u6f58\u5e15\u5609\u6587
+languages.chp=\u5947\u4f69\u74e6\u63da\u6587
+languages.pal=\u5df4\u5217\u7dad\u6587
+languages.cho=\u55ac\u514b\u6258\u6587
+languages.io=\u4f0a\u6717\u6587
+languages.chn=\u5951\u5974\u514b\u6587
+languages.chm=\u99ac\u91cc\u6587
+languages.tyv=\u571f\u51e1\u6587
+languages.bnt=\u73ed\u5716\u6587
+languages.chk=\u8655\u5947\u65af\u6587
+languages.pag=\u6f58\u52a0\u8f9b\u6587
+languages.ik=\u4f9d\u5974\u76ae\u7dad\u514b\u6587
+languages.ii=\u56db\u5ddd\u8a71
+languages.lam=\u862d\u5df4\u6587
+languages.ig=\u4f0a\u5e03\u6587
+languages.sga=\u53e4\u611b\u723e\u862d\u6587\uff08\u81f3 900\uff09
+languages.paa=\u5176\u4ed6\u5df4\u5e03\u4e9e\u8af8\u8a9e\u8a00
+languages.ie=\u62c9\u4e01\u570b\u969b\u6587
+languages.id=\u5370\u5c3c\u6587
+languages.lah=\u62c9\u4ea8\u9054\u6587
+languages.chb=\u5947\u5e03\u67e5\u6587
+languages.day=\u8fea\u96c5\u514b\u6587
+languages.ia=\u62c9\u4e01\u570b\u969b\u6587
+languages.lad=\u62c9\u8fea\u8afe\u6587
+languages.dar=\u9054\u723e\u683c\u74e6\u6587
+languages.hai=\u6d77\u9054\u6587
+languages.hz=\u8d6b\u96f7\u7f85\u6587
+languages.hy=\u4e9e\u7f8e\u5c3c\u4e9e\u6587
+languages.ath=\u963f\u85a9\u5df4\u65af\u5361\u6587
+languages.ht=\u6d77\u5730\u6587
+languages.dak=\u9054\u79d1\u4ed6\u6587
+languages.hr=\u514b\u7f85\u57c3\u897f\u4e9e\u6587
+languages.ho=\u897f\u91cc\u83ab\u5716\u571f\u6587
+languages.hi=\u5317\u5370\u5ea6\u6587
+languages.he=\u5e0c\u4f2f\u4f86\u6587
+languages.ast=\u963f\u65af\u5716\u91cc\u4e9e\u6587
+languages.wen=\u6587\u5fb7\u6587
+languages.gv=\u66fc\u5cf6\u6587
+languages.gu=\u5409\u4e9e\u62c9\u5854\u6587
+languages.sem=\u5176\u4ed6\u9583\u65cf\u8a9e\u8a00
+languages.sel=\u745f\u723e\u5361\u666e\u6587
+languages.iro=\u6613\u6d1b\u9b41\u6587
+languages.gl=\u52a0\u91cc\u897f\u4e9e\u6587
+languages.gd=\u8607\u683c\u862d - \u84cb\u723e\u6587
+languages.art=\u5176\u4ed6\u4eba\u5de5\u8a9e\u8a00
+languages.gez=\u5409\u8332\u6587
+languages.ira=\u4f0a\u82b3\u6717\u6587
+languages.ga=\u611b\u723e\u862d\u6587
+languages.arn=\u963f\u52de\u574e\u6587
+languages.fy=\u5f17\u91cc\u65af\u862d\u6587
+languages.bla=\u932b\u514b\u932b\u5361\u6587
+languages.gem=\u5fb7\u570b\u6587(\u5176\u4ed6)
+languages.ypk=\u611b\u65af\u57fa\u6469\u6587
+languages.fo=\u6cd5\u7f85\u6587
+languages.cel=\u514b\u723e\u7279\u6587\uff08\u5176\u4ed6\uff09
+languages.fj=\u6590\u6fdf\u6587
+languages.fi=\u82ac\u862d\u6587
+languages.ff=\u5bcc\u62c9\u6587
+languages.tvl=\u5410\u74e6\u9b6f\u6587
+languages.ceb=\u5bbf\u52d9\u65cf\u6587
+languages.et=\u611b\u6c99\u5c3c\u4e9e\u6587
+languages.eo=\u4e16\u754c\u8a9e
+languages.el=\u5e0c\u81d8\u6587
+languages.tut=\u5176\u4ed6\u963f\u723e\u6cf0\u8af8\u6587
+languages.niu=\u7d10\u57c3\u6587
+languages.tup=\u5716\u76ae\u6587
+languages.ee=\u57c3\u7def\u6587
+languages.tum=\u5716\u59c6\u5e03\u5361\u6587
+languages.dv=\u8fea\u7dad\u897f\u6587
+languages.fiu=\u82ac\u862d-\u70cf\u6208\u723e\u65cf\u6587(\u5176\u4ed6)
+languages.lus=\u76e7\u6652\u6587
+languages.nic=\u5176\u4ed6\u5c3c\u65e5\u525b\u679c\u8a9e\u7cfb
+languages.nia=\u5c3c\u4e9e\u65af\u6587
+languages.moh=\u83ab\u970d\u514b\u6587
+languages.luo=\u76e7\u5967\u6587
+languages.lun=\u76e7\u6069\u9054\u6587
+languages.apa=\u963f\u5e15\u5947\u8a9e\u8a00
+languages.lui=\u8def\u6613\u585e\u8afe\u6587
+languages.lua=\u9b6f\u5df4\u9b6f\u9b6f\u4e9e\u6587
+languages.bik=\u6bd4\u79d1\u723e\u6587
+languages.was=\u74e6\u7d39\u6587
+languages.und=\u672a\u78ba\u5b9a\u7684
+languages.war=\u74e6\u745e\u6587
+languages.da=\u4e39\u9ea5\u6587
+languages.dum=\u8377\u862d\uff0c\u4e2d\u53e4 (ca. 1050-1350)
+languages.mno=\u99ac\u8afe\u6ce2\u6587
+languages.wak=\u5938\u57fa\u6b66\u7279\u6587
+languages.cy=\u5a01\u723e\u58eb\u6587
+languages.sat=\u6563\u5854\u5229\u6587
+languages.sas=\u6492\u6492\u514b\u6587
+languages.cv=\u695a\u74e6\u751a\u6587
+languages.kbd=\u5361\u5df4\u723e\u9054\u6587
+languages.mni=\u66fc\u5c3c\u666e\u88e1\u6587
+languages.cr=\u514b\u88e1\u6587
+languages.sam=\u85a9\u746a\u5229\u4e9e\u963f\u62c9\u59c6\u6587
+languages.dua=\u675c\u4e9e\u62c9\u6587
+languages.sal=\u85a9\u5229\u751a\u6587
+languages.mnc=\u6eff\u65cf\u6587
+languages.sah=\u96c5\u5eab\u7279\u6587
+languages.gba=\u845b\u5df4\u4e9e\u6587
+languages.sad=\u6851\u9054\u97cb\u6587
+languages.ch=\u67e5\u83ab\u6d1b\u6587
+languages.bho=\u535a\u5091\u666e\u723e\u6587
+languages.ine=\u5370\u6b50\u8a9e\u7cfb\uff08\u5176\u4ed6\uff09
+languages.enm=\u82f1\u6587\uff0c\u4e2d\u4e16\u7d00 (1100-1500)
+languages.ce=\u8eca\u81e3\u6587
+languages.inc=\u5370\u5ea6\u8a9e\u7cfb\uff08\u5176\u4ed6\uff09
+languages.kar=\u514b\u502b\u6587
+languages.gay=\u52a0\u7d04\u6587
+languages.ca=\u52a0\u6cf0\u7f85\u5c3c\u4e9e\u6587
+languages.umb=\u59c6\u672c\u675c\u6587
+languages.syr=\u53e4\u6558\u5229\u4e9e\u6587
+languages.tsi=\u6b3d\u897f\u5b89\u6587
+languages.ang=\u53e4\u82f1\u6587 (ca.450-1100)
+languages.cau=\u9ad8\u52a0\u7d22\u6587\uff08\u5176\u4ed6\uff09
+languages.kab=\u5361\u6bd4\u723e\u6587
+languages.bs=\u6ce2\u58eb\u5c3c\u4e9e\u6587
+languages.kaa=\u5361\u62c9\u5361\u723e\u5e15\u514b\u6587
+languages.bo=\u85cf\u6587
+languages.gaa=\u52a0\u65cf\u6587
+languages.bi=\u6bd4\u65af\u62c9\u99ac\u6587
+languages.cai=\u4e2d\u7f8e\u5370\u7b2c\u5b89\u6587\uff08\u5176\u4ed6\uff09
+languages.bh=\u6bd4\u54c8\u723e\u6587
+languages.bg=\u4fdd\u52a0\u5229\u4e9e\u6587
+languages.be=\u767d\u4fc4\u7f85\u65af\u6587
+languages.ba=\u5df4\u4ec0\u5ba2\u723e\u6587
+languages.zu=\u7956\u9b6f\u6587
+languages.zen=\u6fa4\u7d0d\u52a0\u6587
+languages.pro=\u666e\u7f85\u6587\u65af\u6587 (to 1500)
+languages.az=\u4e9e\u585e\u62dc\u7136\u6587
+languages.ay=\u827e\u99ac\u62c9\u6587
+languages.av=\u963f\u6cd5\u6587
+languages.as=\u963f\u85a9\u59c6\u6587
+languages.dsb=\u4e0b\u7d22\u5e03\u6587
+languages.elx=\u57c3\u862d\u6587
+languages.ilo=\u4f0a\u6d1b\u95ca\u6587
+languages.an=\u963f\u62c9\u8ca2\u6587
+languages.pra=\u5370\u5ea6\u53e4\u4ee3\u53ca\u4e2d\u4e16\u7d00\u4e4b\u4e2d\u90e8\u53ca\u5317\u90e8\u65b9\u8a00
+languages.ak=\u963f\u574e\u6587
+languages.new=\u5c3c\u74e6\u723e\u6587
+languages.za=\u58ef\u6587
+languages.af=\u5357\u975e\u8377\u862d\u6587
+languages.ae=\u963f\u7def\u65af\u9640\u6587
+languages.ab=\u963f\u5e03\u54c8\u897f\u4e9e\u6587
+languages.yo=\u7d04\u9b6f\u5df4\u6587
+languages.alg=\u963f\u723e\u5ca1\u6606\u6587
+languages.ale=\u963f\u7559\u7533\u6587
+languages.mkh=\u5176\u4ed6\u9ad8\u68c9\u8a9e\u7cfb
+languages.yi=\u610f\u7b2c\u7dd2\u6587
+languages.dra=\u5fb7\u62c9\u5a01\u6587\uff08\u5176\u4ed6\uff09
+languages.ber=\u67cf\u67cf\u723e\u6587
+languages.nds=\u5fb7\u570b\u5317\u90e8\u7684\u5fb7\u6587; \u85a9\u514b\u905c\u6587
+languages.bem=\u5225\u59c6\u5df4\u6587
+languages.bej=\u8c9d\u624e\u6587
+languages.tpi=\u6258\u6bd4\u8f9b\u6587
+variants.REVISED=\u5df2\u4fee\u8a02

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_MO_Hant.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_MO_Hant.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_MO_Hant.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_MO_Hant.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,16 @@
+# LocaleInformation_zh_MO_Hant.properties --
+# Copyright (C) 1991-2005 Unicode, Inc.
+# All rights reserved. Distributed under the Terms of Use
+# in http://www.unicode.org/copyright.html.
+#
+# This file was automatically generated by gnu.localegen from CLDR.
+
+currencyFormat=\u00a4#,##0.00;(\u00a4#,##0.00)
+shortMonths=1\u6708®2\u6708®3\u6708®4\u6708®5\u6708®6\u6708®7\u6708®8\u6708®9\u6708®10\u6708®11\u6708®12\u6708®®
+shortDateFormat=yy'\u5e74'M'\u6708'd'\u65e5'
+mediumDateFormat=yyyy'\u5e74'M'\u6708'd'\u65e5'
+longDateFormat=yyyy'\u5e74'MM'\u6708'dd'\u65e5'
+fullDateFormat=yyyy'\u5e74'MM'\u6708'dd'\u65e5' EEEE
+shortTimeFormat=ah:mm
+mediumTimeFormat=ahh:mm:ss
+territories.MO=\u6fb3\u9580\u7279\u5225\u884c\u653f\u5340

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_SG_Hans.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_SG_Hans.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_SG_Hans.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_SG_Hans.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,25 @@
+# LocaleInformation_zh_SG_Hans.properties --
+# Copyright (C) 1991-2005 Unicode, Inc.
+# All rights reserved. Distributed under the Terms of Use
+# in http://www.unicode.org/copyright.html.
+#
+# This file was automatically generated by gnu.localegen from CLDR.
+
+currencyFormat=\u00a4#,##0.00;-\u00a4#,##0.00
+shortDateFormat=dd/MM/yy
+mediumDateFormat=dd-MMM-yy
+longDateFormat=dd MMM yyyy
+fullDateFormat=dd MMMM yyyy
+shortTimeFormat=a hh:mm
+mediumTimeFormat=a hh:mm
+longTimeFormat=a hh:mm:ss
+fullTimeFormat=a hh:mm:ss
+territories.ID=\u5370\u5c3c
+territories.AU=\u6fb3\u6d32
+territories.SA=\u6c99\u5730\u963f\u62c9\u4f2f
+territories.MK=\u9a6c\u5176\u987f
+territories.KR=\u5357\u97e9
+territories.NZ=\u7ebd\u897f\u5170
+territories.CZ=\u6377\u514b
+languages.root=\u6839 \u6e90
+languages.sh=\u585e\u5c14\u7ef4\u4e9a\u514b\u7f57\u5730\u4e9a\u6587

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_TW_Hant.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_TW_Hant.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_TW_Hant.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/locale/LocaleInformation_zh_TW_Hant.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,8 @@
+# LocaleInformation_zh_TW_Hant.properties --
+# Copyright (C) 1991-2005 Unicode, Inc.
+# All rights reserved. Distributed under the Terms of Use
+# in http://www.unicode.org/copyright.html.
+#
+# This file was automatically generated by gnu.localegen from CLDR.
+
+currencyFormat=\u00a4#,##0.00;-\u00a4#,##0.00

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,22 @@
+# Localized error messages for gnu.regexp
+
+# Prefix for REException messages
+error.prefix=At position {0} in regular expression pattern:
+
+# REException (parse error) messages
+repeat.assertion=repeated token is zero-width assertion
+repeat.chained=attempted to repeat a token that is already repeated
+repeat.no.token=quantifier (?*+{}) without preceding token
+repeat.empty.token=repeated token may be empty
+unmatched.brace=unmatched brace
+unmatched.bracket=unmatched bracket
+unmatched.paren=unmatched parenthesis
+interval.no.end=unexpected end of interval
+class.no.end=unexpected end of character class
+subexpr.no.end=unexpected end of subexpression
+interval.order=an interval''s minimum is greater than its maximum
+interval.error=an interval is empty * or contains illegal characters
+ends.with.backslash=backslash at end of pattern
+
+# RESyntax message
+syntax.final=Syntax has been declared final and cannot be modified

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_fr.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,22 @@
+# Localized error messages for gnu.regexp
+
+# Prefix for REException messages
+error.prefix=A l''index {0} dans le modèle d''expression régulière:
+
+# REException (parse error) messages
+repeat.assertion=l''élément répété est de largeur zéro
+repeat.chained=tentative de répétition d''un élément déjà répété
+repeat.no.token=quantifieur (?*+{}) sans élément précédent
+repeat.empty.token=l''élément répété peut être vide
+unmatched.brace=accolade inégalée
+unmatched.bracket=crochet inégalé
+unmatched.paren=parenthèse inégalée
+interval.no.end=fin d''interval non attendue
+class.no.end=fin de classe de caractères non attendue
+subexpr.no.end=fin de sous-expression non attendue
+interval.order=l''interval minimum est supérieur à l''interval maximum
+interval.error=l''interval est vide ou contient des caractères illégaux
+ends.with.backslash=antislash à la fin du modèle
+
+# RESyntax message
+syntax.final=La syntaxe a été déclarée finale et ne peut pas être modifiée

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/java/util/regex/MessagesBundle_it.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,31 @@
+# Localized error messages for gnu.regexp, in Italian.
+# $Id: MessagesBundle_it.properties,v 1.1 2006/07/19 19:47:07 rabbit78 Exp $
+# Messaggi italiani per gnu.regexp.
+#
+# Attenzione: Questa traduzione fu scritto da un italo-americano.
+#	Per favore correggete l'italiano bestemmiato e mandate i patch
+#	al listo <classpath at gnu dot org>.
+#
+# @author Steven Augart <steve at watson dot ibm dot com>, <steve at augart dot com>
+
+# Prefix for REException messages
+error.prefix=Al indice {0} nel modello dell''espressione regulare:
+
+# REException (parse error) messages
+repeat.assertion=l''elemento ripetuto ha larghezza zero
+repeat.chained=prova di ripetere un elemento già ripetuto
+repeat.no.token=quantificatore (?*+{}) senza elemento precedente
+repeat.empty.token=l''elemento ripetuto può essere vuoto
+unmatched.brace=parentesi quadra senza corrispondente
+unmatched.bracket=graffa senza corrispondente
+unmatched.paren=parentesi senza corrispondente
+interval.no.end=la fine d''intervallo è imprevista 
+class.no.end=la fine della classe di caratteri è imprevista
+subexpr.no.end=la fine del sub-espressione è imprevista
+interval.order=il valore minimo d''intervallo è piú grande del suo valore massimo
+interval.error=l''intervallo è vuoto o contiene caratteri impermessibili
+#  Non so come si dice "backslash" in italiano.
+ends.with.backslash=il modello finisce con un backslash (il carattere "\")
+
+# RESyntax message
+syntax.final=La sintassi è dichiarata "final" (finale) e non si può modificarla

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/print/PrinterDialog.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/print/PrinterDialog.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/print/PrinterDialog.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/print/PrinterDialog.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,93 @@
+# PrinterDialog.properties -- Default property file for PrinterDialog
+# 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.
+#
+rbt.onesided=Onesided
+rbt.calendar=Calendar
+rbt.duplex=Duplex
+rbt.blackwhite=Black&White
+rbt.color=Color
+rbt.low=Low
+rbt.normal=Normal
+rbt.high=High
+rbt.all=All
+rbt.pages=Pages
+rbt.portrait=Portrait
+rbt.landscape=Landscape
+rbt.revportrait=Reversed Portrait
+rbt.revlandscape=Reversed Landscape
+cb.cover=Cover page
+cb.sort=Sort
+cb.output=Redirect output in file
+lb.size=Size:
+lb.source=Source:
+lb.left=left (mm)
+lb.right=right (mm)
+lb.top=top (mm)
+lb.bottom=bottom (mm)
+lb.name=Name:
+lb.status=Status:
+lb.typ=Typ:
+lb.info=Info:
+lb.to=to
+lb.copies=Number of copies:
+lb.jobname=Job name:
+lb.username=User name:
+lb.priority=Priority:
+lb.acceptingjobs=Printer is accepting jobs
+lb.notacceptingjobs=Printer is not accepting jobs
+lb.automatically=Automatically Select
+bt.attributes=Attributes...
+bt.print=Print
+bt.OK=OK
+bt.cancel=Cancel
+# names of the panel titles
+title.medias=Medias
+title.printservice=Printservice
+title.orientation=Orientation
+title.color=Color
+title.sides=Sides
+title.copies=Copies
+title.quality=Quality
+title.jobattributes=Job-Attributes
+title.margins=Margins
+title.printdialog=Printing
+title.pagedialog=Printing
+title.printrange=Printrange
+# names of the main tabs
+tab.general=General
+tab.pagesetup=Page setup
+tab.appearance=Appearance

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/print/PrinterDialog_de.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/print/PrinterDialog_de.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/print/PrinterDialog_de.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/print/PrinterDialog_de.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,91 @@
+# PrinterDialog_de.properties -- German property file for PrinterDialog
+# 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.
+#
+rbt.onesided=Einseitig
+rbt.calendar=Kalenderdruck
+rbt.duplex=Duplex
+rbt.blackwhite=Schwarzweiß
+rbt.color=Farbe
+rbt.low=Entwurf
+rbt.normal=Normal
+rbt.high=Hoch
+rbt.all=Alle
+rbt.pages=Seiten
+rbt.portrait=Hochformat
+rbt.landscape=Querformat
+rbt.revportrait=Umgekehrtes Hochformat
+rbt.revlandscape=Umgekehrtes Querformat
+cb.cover=Deckblatt
+cb.sort=Sortieren
+cb.output=Ausgabe in Datei umleiten
+lb.size=Größe:
+lb.source=Quelle:
+lb.left=links (mm)
+lb.right=rechts (mm)
+lb.top=oben (mm)
+lb.bottom=unten (mm)
+lb.name=Name:
+lb.status=Status:
+lb.typ=Typ:
+lb.info=Info:
+lb.to=Bis
+lb.copies=Anzahl der Kopien:
+lb.jobname=Job-name:
+lb.username=Benutzername:
+lb.priority=Priorität:
+lb.acceptingjobs=Drucker nimmt Aufträge an
+lb.notacceptingjobs=Drucker nimmt keine Aufträge an
+lb.automatically=Automatische Auswahl
+bt.attributes=Eigenschaften...
+bt.print=Drucken
+bt.OK=OK
+bt.cancel=Abbrechen
+title.medias=Medien
+title.printservice=Druckdienst
+title.orientation=Ausrichtung
+title.color=Farbdarstellung
+title.sides=Seiten
+title.copies=Kopien
+title.quality=Qualität
+title.jobattributes=Job-Attribute
+title.margins=Ränder
+title.printdialog=Drucken
+title.pagedialog=Seite einrichten
+title.printrange=Druckbereich
+tab.general=Allgemein
+tab.pagesetup=Seite einrichten
+tab.appearance=Aussehen

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/security/auth/callback/MessagesBundle.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/security/auth/callback/MessagesBundle.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/security/auth/callback/MessagesBundle.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/gnu/javax/security/auth/callback/MessagesBundle.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+# MessagesBundle.properties -- Default messages bundle.
+# Copyright (C) 2005  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., 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.
+
+callback.yesNo=(yes or no)\ 
+callback.yesNoCancel=(yes, no, cancel)\ 
+callback.okCancel=(ok or cancel)\ 
+callback.language=Choose your language:\ 
+
+callback.yes=Yes
+callback.shortYes=y
+callback.no=No
+callback.shortNo=n
+callback.cancel=Cancel
+callback.ok=Okay
+
+callback.error=Error
+callback.information=Information
+callback.warning=Warning

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/java/security/classpath.security
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/java/security/classpath.security?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/java/security/classpath.security (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/java/security/classpath.security Thu Nov  8 16:56:19 2007
@@ -0,0 +1,51 @@
+# classpath.security
+#    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.
+
+# Note that the settings and ordering here are mirrored in Security.
+security.provider.1=gnu.java.security.provider.Gnu
+security.provider.2=gnu.javax.crypto.jce.GnuCrypto
+security.provider.3=gnu.javax.crypto.jce.GnuSasl
+security.provider.4=gnu.javax.net.ssl.provider.Jessie
+security.provider.5=gnu.javax.security.auth.callback.GnuCallbacks
+
+# The VM-wide default callback handler class name.  MUST be a subclass of
+# javax.security.auth.callback.CallbackHandler
+auth.login.defaultCallbackHandler=gnu.javax.security.auth.callback.DefaultCallbackHandler
+
+# If this file isn't found we fall back to generating entropy through
+# "battling threads".
+securerandom.source=file:///dev/urandom

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/java/util/iso4217.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/java/util/iso4217.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/java/util/iso4217.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/java/util/iso4217.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,466 @@
+# This document is automatically generated by gnu.currencygen
+
+AD.currency=EUR,ESP,FRF,ADP
+AD.fractionDigits=2
+AE.currency=AED
+AE.fractionDigits=2
+AF.currency=AFN
+AF.fractionDigits=2
+AG.currency=XCD
+AG.fractionDigits=2
+AI.currency=XCD
+AI.fractionDigits=2
+AL.currency=ALL
+AL.fractionDigits=2
+AM.currency=AMD
+AM.fractionDigits=2
+AN.currency=ANG
+AN.fractionDigits=2
+AO.currency=AOA
+AO.fractionDigits=2
+AQ.currency=
+AQ.fractionDigits=2
+AR.currency=ARS
+AR.fractionDigits=2
+AS.currency=USD
+AS.fractionDigits=2
+AT.currency=EUR,ATS
+AT.fractionDigits=2
+AU.currency=AUD
+AU.fractionDigits=2
+AW.currency=AWG
+AW.fractionDigits=2
+AZ.currency=AZM
+AZ.fractionDigits=2
+BA.currency=BAM
+BA.fractionDigits=2
+BB.currency=BBD
+BB.fractionDigits=2
+BD.currency=BDT
+BD.fractionDigits=2
+BE.currency=EUR,BEF
+BE.fractionDigits=2
+BF.currency=XOF
+BF.fractionDigits=0
+BG.currency=BGN
+BG.fractionDigits=2
+BH.currency=BHD
+BH.fractionDigits=3
+BI.currency=BIF
+BI.fractionDigits=0
+BJ.currency=XOF
+BJ.fractionDigits=0
+BM.currency=BMD
+BM.fractionDigits=2
+BN.currency=BND
+BN.fractionDigits=2
+BO.currency=BOB
+BO.fractionDigits=2
+BR.currency=BRL
+BR.fractionDigits=2
+BS.currency=BSD
+BS.fractionDigits=2
+BV.currency=NOK
+BV.fractionDigits=2
+BW.currency=BWP
+BW.fractionDigits=2
+BY.currency=BYR
+BY.fractionDigits=0
+BZ.currency=BZD
+BZ.fractionDigits=2
+CA.currency=CAD
+CA.fractionDigits=2
+CC.currency=AUD
+CC.fractionDigits=2
+CD.currency=CDF
+CD.fractionDigits=2
+CF.currency=XAF
+CF.fractionDigits=0
+CG.currency=XAF
+CG.fractionDigits=0
+CH.currency=CHF
+CH.fractionDigits=2
+CI.currency=XOF
+CI.fractionDigits=0
+CK.currency=NZD
+CK.fractionDigits=2
+CL.currency=CLP
+CL.fractionDigits=0
+CM.currency=XAF
+CM.fractionDigits=0
+CN.currency=CNY
+CN.fractionDigits=2
+CO.currency=COP
+CO.fractionDigits=2
+CR.currency=CRC
+CR.fractionDigits=2
+CU.currency=CUP
+CU.fractionDigits=2
+CV.currency=CVE
+CV.fractionDigits=2
+CX.currency=AUD
+CX.fractionDigits=2
+CY.currency=CYP
+CY.fractionDigits=2
+CZ.currency=CZK
+CZ.fractionDigits=2
+DE.currency=EUR,DEM
+DE.fractionDigits=2
+DJ.currency=DJF
+DJ.fractionDigits=0
+DK.currency=DKK
+DK.fractionDigits=2
+DM.currency=XCD
+DM.fractionDigits=2
+DO.currency=DOP
+DO.fractionDigits=2
+DZ.currency=DZD
+DZ.fractionDigits=2
+EC.currency=USD
+EC.fractionDigits=2
+EE.currency=EEK
+EE.fractionDigits=2
+EG.currency=EGP
+EG.fractionDigits=2
+EH.currency=MAD
+EH.fractionDigits=2
+ER.currency=ERN
+ER.fractionDigits=2
+ES.currency=EUR,ESP
+ES.fractionDigits=2
+ET.currency=ETB
+ET.fractionDigits=2
+FI.currency=EUR,FIM
+FI.fractionDigits=2
+FJ.currency=FJD
+FJ.fractionDigits=2
+FK.currency=FKP
+FK.fractionDigits=2
+FM.currency=USD
+FM.fractionDigits=2
+FO.currency=DKK
+FO.fractionDigits=2
+FR.currency=EUR,FRF
+FR.fractionDigits=2
+GA.currency=XAF
+GA.fractionDigits=0
+GB.currency=GBP
+GB.fractionDigits=2
+GD.currency=XCD
+GD.fractionDigits=2
+GE.currency=GEL
+GE.fractionDigits=2
+GF.currency=EUR
+GF.fractionDigits=2
+GH.currency=GHC
+GH.fractionDigits=2
+GI.currency=GIP
+GI.fractionDigits=2
+GL.currency=DKK
+GL.fractionDigits=2
+GM.currency=GMD
+GM.fractionDigits=2
+GN.currency=GNF
+GN.fractionDigits=0
+GP.currency=EUR
+GP.fractionDigits=2
+GQ.currency=XAF
+GQ.fractionDigits=0
+GR.currency=EUR,GRD
+GR.fractionDigits=2
+GT.currency=GTQ
+GT.fractionDigits=2
+GU.currency=USD
+GU.fractionDigits=2
+GY.currency=GYD
+GY.fractionDigits=2
+HK.currency=HKD
+HK.fractionDigits=2
+HM.currency=AUD
+HM.fractionDigits=2
+HN.currency=HNL
+HN.fractionDigits=2
+HR.currency=HRK
+HR.fractionDigits=2
+HU.currency=HUF
+HU.fractionDigits=2
+ID.currency=IDR
+ID.fractionDigits=2
+IE.currency=EUR,IEP
+IE.fractionDigits=2
+IL.currency=ILS
+IL.fractionDigits=2
+IN.currency=INR
+IN.fractionDigits=2
+IO.currency=USD
+IO.fractionDigits=2
+IQ.currency=IQD
+IQ.fractionDigits=3
+IR.currency=IRR
+IR.fractionDigits=2
+IS.currency=ISK
+IS.fractionDigits=2
+IT.currency=EUR,ITL
+IT.fractionDigits=2
+JM.currency=JMD
+JM.fractionDigits=2
+JO.currency=JOD
+JO.fractionDigits=3
+JP.currency=JPY
+JP.fractionDigits=0
+KE.currency=KES
+KE.fractionDigits=2
+KG.currency=KGS
+KG.fractionDigits=2
+KH.currency=KHR
+KH.fractionDigits=2
+KI.currency=AUD
+KI.fractionDigits=2
+KM.currency=KMF
+KM.fractionDigits=0
+KN.currency=XCD
+KN.fractionDigits=2
+KP.currency=KPW
+KP.fractionDigits=2
+KR.currency=KRW
+KR.fractionDigits=0
+KW.currency=KWD
+KW.fractionDigits=3
+KY.currency=KYD
+KY.fractionDigits=2
+KZ.currency=KZT
+KZ.fractionDigits=2
+LA.currency=LAK
+LA.fractionDigits=2
+LB.currency=LBP
+LB.fractionDigits=2
+LC.currency=XCD
+LC.fractionDigits=2
+LI.currency=CHF
+LI.fractionDigits=2
+LK.currency=LKR
+LK.fractionDigits=2
+LR.currency=LRD
+LR.fractionDigits=2
+LT.currency=LTL
+LT.fractionDigits=2
+LU.currency=EUR,LUF
+LU.fractionDigits=2
+LV.currency=LVL
+LV.fractionDigits=2
+LY.currency=LYD
+LY.fractionDigits=3
+MA.currency=MAD
+MA.fractionDigits=2
+MC.currency=EUR
+MC.fractionDigits=2
+MD.currency=MDL
+MD.fractionDigits=2
+MG.currency=MGF
+MG.fractionDigits=0
+MH.currency=USD
+MH.fractionDigits=2
+MK.currency=MKD
+MK.fractionDigits=2
+ML.currency=XOF
+ML.fractionDigits=0
+MM.currency=MMK
+MM.fractionDigits=2
+MN.currency=MNT
+MN.fractionDigits=2
+MO.currency=MOP
+MO.fractionDigits=2
+MP.currency=USD
+MP.fractionDigits=2
+MQ.currency=EUR
+MQ.fractionDigits=2
+MR.currency=MRO
+MR.fractionDigits=2
+MS.currency=XCD
+MS.fractionDigits=2
+MT.currency=MTL
+MT.fractionDigits=2
+MU.currency=MUR
+MU.fractionDigits=2
+MV.currency=MVR
+MV.fractionDigits=2
+MW.currency=MWK
+MW.fractionDigits=2
+MX.currency=MXN
+MX.fractionDigits=2
+MY.currency=MYR
+MY.fractionDigits=2
+MZ.currency=MZM
+MZ.fractionDigits=2
+NC.currency=XPF
+NC.fractionDigits=0
+NE.currency=XOF
+NE.fractionDigits=0
+NF.currency=AUD
+NF.fractionDigits=2
+NG.currency=NGN
+NG.fractionDigits=2
+NI.currency=NIO
+NI.fractionDigits=2
+NL.currency=EUR,NLG
+NL.fractionDigits=2
+NO.currency=NOK
+NO.fractionDigits=2
+NP.currency=NPR
+NP.fractionDigits=2
+NR.currency=AUD
+NR.fractionDigits=2
+NU.currency=NZD
+NU.fractionDigits=2
+NZ.currency=NZD
+NZ.fractionDigits=2
+OM.currency=OMR
+OM.fractionDigits=3
+PA.currency=PAB
+PA.fractionDigits=2
+PE.currency=PEN
+PE.fractionDigits=2
+PF.currency=XPF
+PF.fractionDigits=0
+PG.currency=PGK
+PG.fractionDigits=2
+PH.currency=PHP
+PH.fractionDigits=2
+PK.currency=PKR
+PK.fractionDigits=2
+PL.currency=PLN
+PL.fractionDigits=2
+PM.currency=EUR
+PM.fractionDigits=2
+PN.currency=NZD
+PN.fractionDigits=2
+PR.currency=USD
+PR.fractionDigits=2
+PT.currency=EUR,PTE
+PT.fractionDigits=2
+PW.currency=USD
+PW.fractionDigits=2
+PY.currency=PYG
+PY.fractionDigits=0
+QA.currency=QAR
+QA.fractionDigits=2
+RE.currency=EUR
+RE.fractionDigits=2
+RO.currency=ROL
+RO.fractionDigits=2
+RU.currency=RUB
+RU.fractionDigits=2
+RW.currency=RWF
+RW.fractionDigits=0
+SA.currency=SAR
+SA.fractionDigits=2
+SB.currency=SBD
+SB.fractionDigits=2
+SC.currency=SCR
+SC.fractionDigits=2
+SD.currency=SDD
+SD.fractionDigits=2
+SE.currency=SEK
+SE.fractionDigits=2
+SG.currency=SGD
+SG.fractionDigits=2
+SH.currency=SHP
+SH.fractionDigits=2
+SI.currency=SIT
+SI.fractionDigits=2
+SJ.currency=NOK
+SJ.fractionDigits=2
+SK.currency=SKK
+SK.fractionDigits=2
+SL.currency=SLL
+SL.fractionDigits=2
+SM.currency=EUR
+SM.fractionDigits=2
+SN.currency=XOF
+SN.fractionDigits=0
+SO.currency=SOS
+SO.fractionDigits=2
+SR.currency=SRG
+SR.fractionDigits=2
+ST.currency=STD
+ST.fractionDigits=2
+SV.currency=SVC
+SV.fractionDigits=2
+SY.currency=SYP
+SY.fractionDigits=2
+SZ.currency=SZL
+SZ.fractionDigits=2
+TC.currency=USD
+TC.fractionDigits=2
+TD.currency=XAF
+TD.fractionDigits=0
+TF.currency=EUR
+TF.fractionDigits=2
+TG.currency=XOF
+TG.fractionDigits=0
+TH.currency=THB
+TH.fractionDigits=2
+TJ.currency=TJS
+TJ.fractionDigits=2
+TK.currency=NZD
+TK.fractionDigits=2
+TL.currency=USD
+TL.fractionDigits=2
+TM.currency=TMM
+TM.fractionDigits=2
+TN.currency=TND
+TN.fractionDigits=3
+TO.currency=TOP
+TO.fractionDigits=2
+TR.currency=TRL
+TR.fractionDigits=0
+TT.currency=TTD
+TT.fractionDigits=2
+TV.currency=AUD
+TV.fractionDigits=2
+TW.currency=TWD
+TW.fractionDigits=2
+TZ.currency=TZS
+TZ.fractionDigits=2
+UA.currency=UAH
+UA.fractionDigits=2
+UG.currency=UGX
+UG.fractionDigits=2
+UM.currency=USD
+UM.fractionDigits=2
+US.currency=USD
+US.fractionDigits=2
+UY.currency=UYU
+UY.fractionDigits=2
+UZ.currency=UZS
+UZ.fractionDigits=2
+VA.currency=EUR
+VA.fractionDigits=2
+VC.currency=XCD
+VC.fractionDigits=2
+VE.currency=VEB
+VE.fractionDigits=2
+VG.currency=USD
+VG.fractionDigits=2
+VI.currency=USD
+VI.fractionDigits=2
+VN.currency=VND
+VN.fractionDigits=2
+VU.currency=VUV
+VU.fractionDigits=0
+WF.currency=XPF
+WF.fractionDigits=0
+WS.currency=WST
+WS.fractionDigits=2
+YE.currency=YER
+YE.fractionDigits=2
+YT.currency=EUR
+YT.fractionDigits=2
+YU.currency=YUM
+YU.fractionDigits=2
+ZA.currency=ZAR
+ZA.fractionDigits=2
+ZM.currency=ZMK
+ZM.fractionDigits=2
+ZW.currency=ZWD
+ZW.fractionDigits=2

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/java/util/logging/logging.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/java/util/logging/logging.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/java/util/logging/logging.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/java/util/logging/logging.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,42 @@
+# Logging Configuration
+# ---------------------
+# By setting properties in this file, you can change the behavior
+# of the java.util.logging framework. Some examples are listed below.
+#
+#
+# To change the logging threshold of all loggers to the value
+# java.util.logging.Level.CONFIG, un-comment the following line:
+#
+# .level=CONFIG
+#
+#
+# To change the logging threshold of all loggers in the "foo.bar"
+# namespace to java.util.logging.Level.FINEST, un-comment the follwing
+# line. This will also affect any children, such as "foo.bar.baz".
+#
+# foo.bar.level=FINEST
+#
+#
+# To register a FileHandler for the "foo.bar" namespace and its
+# children, un-comment the following line. By default, the FileHandler
+# will write XML-formatted messages into a file "java0.log" in the
+# user's home directory.
+#
+# foo.bar.handlers=java.util.logging.FileHandler
+#
+#
+# To make a FileHandler use plain text instead of XML, and to place
+# the log file into a different location (such as /tmp/myfile.log
+# or /var/tmp/myfile.log), un-comment the following:
+#
+# java.util.logging.FileHandler.pattern=%t/myfile.log
+# java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
+#
+#
+# Logging can be configured in many ways. For more information, please
+# look at the documentation of the java.util.logging package.
+
+
+# Send log records to System.err, default to INFO per documentation.
+handlers = java.util.logging.ConsoleHandler
+.level = INFO

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/javax/imageio/plugins/jpeg/MessagesBundle.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/javax/imageio/plugins/jpeg/MessagesBundle.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/javax/imageio/plugins/jpeg/MessagesBundle.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/javax/imageio/plugins/jpeg/MessagesBundle.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,9 @@
+# Localized error messages for javax.imageio.plugins.jpeg
+
+# Compression types
+compression.types.jpeg=JPEG
+
+# Compression quality descriptions
+compression.minimum=Minimum useful
+compression.default=Visually lossless
+compression.maximum=Maximum useful

Added: llvm-gcc-4.2/trunk/libjava/classpath/resource/org/ietf/jgss/MessagesBundle.properties
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/resource/org/ietf/jgss/MessagesBundle.properties?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/resource/org/ietf/jgss/MessagesBundle.properties (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/resource/org/ietf/jgss/MessagesBundle.properties Thu Nov  8 16:56:19 2007
@@ -0,0 +1,60 @@
+# MessagesBundle.properties -- English GSS messages.
+# Copyright (C) 2004  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 Street, Fifth Floor, Boston, MA 02110-1301
+# USA
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library.  Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give
+# you permission to link this library with independent modules to
+# produce an executable, regardless of the license terms of these
+# independent modules, and to copy and distribute the resulting
+# executable under terms of your choice, provided that you also meet,
+# for each linked independent module, the terms and conditions of the
+# license of that module.  An independent module is a module which is
+# not derived from or based on this library.  If you modify this
+# library, you may extend this exception to your version of the
+# library, but you are not obligated to do so.  If you do not wish to
+# do so, delete this exception statement from your version.
+
+GSSException.BAD_MECH=An unsupported mechanism was requested.
+GSSException.BAD_NAME=An invalid name was supplied.
+GSSException.BAD_NAMETYPE=A supplied name was of an unsupported type.
+GSSException.BAD_BINDINGS=Incorrect channel bindings were supplied.
+GSSException.BAD_STATUS=An invalid status code was supplied.
+GSSException.BAD_MIC=A token had an invalid MIC.
+GSSException.NO_CRED=No credentials were supplied, or the credentials were unavailable or inaccessible.
+GSSException.NO_CONTEXT=Invalid context has been supplied.
+GSSException.DEFECTIVE_TOKEN=A supplied token was invalid.
+GSSException.DEFECTIVE_CREDENTIAL=A supplied credential was invalid.
+GSSException.CREDENTIALS_EXPIRED=The referenced credentials have expired.
+GSSException.CONTEXT_EXPIRED=The context has expired.
+GSSException.FAILURE=Miscellaneous failure.
+GSSException.BAD_QOP=The quality-of-protection requested could not be provided.
+GSSException.UNAUTHORIZED=The operation is forbidden by local security policy.
+GSSException.UNAVAILABLE=The operation or option is unavailable.
+GSSException.DUPLICATE_ELEMENT=The requested credential element already exists.
+GSSException.NAME_NOT_MN=The provided name was not a mechanism name.
+GSSException.OLD_TOKEN=The token\'s validity period has expired.
+GSSException.DUPLICATE_TOKEN=The token was a duplicate of an earlier version.
+GSSException.UNSEQ_TOKEN=A later token has already been processed.
+GSSException.GAP_TOKEN=An expected per-message token was not received.
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/scripts/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/scripts/Makefile.am?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/scripts/Makefile.am (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/scripts/Makefile.am Thu Nov  8 16:56:19 2007
@@ -0,0 +1,2 @@
+
+EXTRA_DIST = check_jni_methods.sh generate-locale-list.sh import-cacerts.sh

Added: llvm-gcc-4.2/trunk/libjava/classpath/scripts/Makefile.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/scripts/Makefile.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/scripts/Makefile.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/scripts/Makefile.in Thu Nov  8 16:56:19 2007
@@ -0,0 +1,451 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005  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.
+
+ at SET_MAKE@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+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@
+subdir = scripts
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/classpath.spec.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/multi.m4 \
+	$(top_srcdir)/../../libtool.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/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.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 = classpath.spec
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
+BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
+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@
+CREATE_ALSA_LIBRARIES_FALSE = @CREATE_ALSA_LIBRARIES_FALSE@
+CREATE_ALSA_LIBRARIES_TRUE = @CREATE_ALSA_LIBRARIES_TRUE@
+CREATE_API_DOCS_FALSE = @CREATE_API_DOCS_FALSE@
+CREATE_API_DOCS_TRUE = @CREATE_API_DOCS_TRUE@
+CREATE_COLLECTIONS_FALSE = @CREATE_COLLECTIONS_FALSE@
+CREATE_COLLECTIONS_TRUE = @CREATE_COLLECTIONS_TRUE@
+CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
+CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
+CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
+CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
+CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
+CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
+CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
+CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
+CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
+CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
+CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
+CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
+CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
+CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ECJ = @ECJ@
+EGREP = @EGREP@
+ENABLE_LOCAL_SOCKETS_FALSE = @ENABLE_LOCAL_SOCKETS_FALSE@
+ENABLE_LOCAL_SOCKETS_TRUE = @ENABLE_LOCAL_SOCKETS_TRUE@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXAMPLESDIR = @EXAMPLESDIR@
+EXEEXT = @EXEEXT@
+FASTJAR = @FASTJAR@
+FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
+FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
+FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
+FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
+FOUND_GCJX_TRUE = @FOUND_GCJX_TRUE@
+FOUND_GCJ_FALSE = @FOUND_GCJ_FALSE@
+FOUND_GCJ_TRUE = @FOUND_GCJ_TRUE@
+FOUND_JIKES_FALSE = @FOUND_JIKES_FALSE@
+FOUND_JIKES_TRUE = @FOUND_JIKES_TRUE@
+FOUND_KJC_FALSE = @FOUND_KJC_FALSE@
+FOUND_KJC_TRUE = @FOUND_KJC_TRUE@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GCJ = @GCJ@
+GCJX = @GCJX@
+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@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
+INSTALL_CLASS_FILES_FALSE = @INSTALL_CLASS_FILES_FALSE@
+INSTALL_CLASS_FILES_TRUE = @INSTALL_CLASS_FILES_TRUE@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_GLIBJ_ZIP_FALSE = @INSTALL_GLIBJ_ZIP_FALSE@
+INSTALL_GLIBJ_ZIP_TRUE = @INSTALL_GLIBJ_ZIP_TRUE@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@
+JAY = @JAY@
+JAY_SKELETON = @JAY_SKELETON@
+JIKES = @JIKES@
+JIKESENCODING = @JIKESENCODING@
+JIKESWARNINGS = @JIKESWARNINGS@
+KJC = @KJC@
+LDFLAGS = @LDFLAGS@
+LIBDEBUG = @LIBDEBUG@
+LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVERSION = @LIBVERSION@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+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@
+REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@
+REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@
+REMOVE = @REMOVE@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@
+STRIP = @STRIP@
+USER_CLASSLIB = @USER_CLASSLIB@
+USER_JAVAH = @USER_JAVAH@
+USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
+USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
+USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
+USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
+USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
+USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
+VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+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@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+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@
+datadir = @datadir@
+default_toolkit = @default_toolkit@
+exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+multi_basedir = @multi_basedir@
+nativeexeclibdir = @nativeexeclibdir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexeclibdir = @toolexeclibdir@
+vm_classes = @vm_classes@
+EXTRA_DIST = check_jni_methods.sh generate-locale-list.sh import-cacerts.sh
+all: all-am
+
+.SUFFIXES:
+$(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 \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  scripts/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  scripts/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
+classpath.spec: $(top_builddir)/config.status $(srcdir)/classpath.spec.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: 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)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-exec install-exec-am \
+	install-info install-info-am install-man install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
+	uninstall-info-am
+
+# 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:

Added: llvm-gcc-4.2/trunk/libjava/classpath/scripts/check_jni_methods.sh
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/scripts/check_jni_methods.sh?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/scripts/check_jni_methods.sh (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/scripts/check_jni_methods.sh Thu Nov  8 16:56:19 2007
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# Fail if any command fails
+set -e
+
+TMPFILE=/tmp/check-jni-methods.$$.1
+TMPFILE2=/tmp/check-jni-methods.$$.2
+TMPFILE3=/tmp/check-jni-methods.$$.3
+
+# Find all methods defined in the header files generated
+# from the java source files.
+grep -h '^JNIEXPORT .* Java_' include/*.h | \
+        LC_ALL=C sed -e 's,.*JNICALL \(Java_[a-z_A-Z0-9]*\).*$,\1,' | \
+	sort > $TMPFILE
+
+# Find all methods in the JNI C source files.
+find native/jni -name \*.c | \
+	xargs grep -h '^Java_' | \
+        LC_ALL=C sed -e 's,^\(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' > $TMPFILE2
+# Or in the the C++ files. (Note that cpp doesn't follow gnu conventions atm)
+# So we try to match both GNU style and some other style.
+find native/jni -name \*.cpp | \
+	xargs grep -h '^Java_' | \
+        LC_ALL=C sed -e 's,^\(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' >> $TMPFILE2
+find native/jni -name \*.cpp | \
+	xargs egrep -h '^(JNIEXPORT .* JNICALL )?Java_' | \
+	cut -f4 -d\  | \
+        LC_ALL=C sed -e 's,^\JNIEXPORT .* JNICALL \(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' >> $TMPFILE2
+mv $TMPFILE2 $TMPFILE3
+sort $TMPFILE3 | uniq > $TMPFILE2
+rm $TMPFILE3
+
+# Write temporary ignore file.
+cat > $TMPFILE3 << EOF
+-Java_gnu_java_awt_peer_gtk_GtkMenuComponentPeer_dispose
+-Java_java_lang_VMSystem_arraycopy
+-Java_java_lang_VMSystem_identityHashCode
+-Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
+-Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
+-Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
+EOF
+
+# Compare again silently.
+# Use fgrep and direct the output to /dev/null for compatibility with older
+# grep instead of using the non portable -q.
+if diff -b -U 0 $TMPFILE $TMPFILE2 | grep '^[+-]Java' | \
+    fgrep -v -f $TMPFILE3 > /dev/null;
+then
+  PROBLEM=1
+  echo "Found a problem with the JNI methods declared and implemented."
+  echo "(-) missing in implementation, (+) missing in header files"
+
+  # Compare the found method lists.
+  diff -b -U 0 $TMPFILE $TMPFILE2  | grep '^[+-]Java' | fgrep -v -f $TMPFILE3
+fi
+
+# Cleanup.
+rm -f $TMPFILE $TMPFILE2 $TMPFILE3
+
+if test "$PROBLEM" = "1" ; then
+  exit 1
+fi
+
+exit 0

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/scripts/check_jni_methods.sh

------------------------------------------------------------------------------
    svn:executable = *

Added: llvm-gcc-4.2/trunk/libjava/classpath/scripts/classpath.spec.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/scripts/classpath.spec.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/scripts/classpath.spec.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/scripts/classpath.spec.in Thu Nov  8 16:56:19 2007
@@ -0,0 +1,66 @@
+# $Id: classpath.spec.in,v 1.2 2005/07/04 14:31:01 ziga Exp $
+
+%define version_num @PACKAGE_VERSION@
+%define release_num 1
+
+Summary: GNU Classpath Java class libraries
+Name: classpath
+Version: %{version_num}
+Release: %{release_num}
+Group: Development/Tools
+Copyright: GPL+exception
+URL: http://www.classpath.org/
+BuildRoot: %{_tmppath}/%{name}-root
+BuildRequires: jikes, zip
+Packager: GNU Classpath <classpath at gnu.org>
+Source: ftp://ftp.gnu.org/pub/gnu/classpath/classpath-%{version_num}.tar.gz
+
+%description
+GNU Classpath, Essential Libraries for Java, is a GNU project to create
+free core class libraries for use with virtual machines and compilers
+for the Java programming language.
+
+%prep
+%setup -n classpath-%{version_num}
+
+%build
+pushd ${RPM_BUILD_DIR}/classpath-%{version_num}
+# Determine if we can build the GTK stuff
+GTKPEER='disable'
+if pkg-config --exists 'gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0'; then
+    GTKPEER='enable'
+fi
+%configure --with-jikes --enable-jni --${GTKPEER}-gtk-peer
+make
+popd
+
+%install
+pushd ${RPM_BUILD_DIR}/classpath-%{version_num}
+%{makeinstall}
+popd
+
+pushd ${RPM_BUILD_ROOT}/%{_infodir}
+rm -f dir
+for i in *; do
+    mv $i classpath-$i
+done
+popd
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%clean
+rm -rf ${RPM_BUILD_ROOT}
+
+%files
+%defattr(-,root,root)
+%doc AUTHORS COPYING LICENSE README THANKYOU
+%{_libdir}/classpath
+%dir %{_datadir}/classpath
+%{_libdir}/security/classpath.security
+%{_datadir}/classpath/glibj.zip
+%doc %{_datadir}/classpath/api
+%doc %{_datadir}/classpath/examples
+%doc %{_infodir}/*
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/scripts/generate-locale-list.sh
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/scripts/generate-locale-list.sh?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/scripts/generate-locale-list.sh (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/scripts/generate-locale-list.sh Thu Nov  8 16:56:19 2007
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+CLASSPATH_SRCDIR=`dirname $0`/..
+
+echo "/* LocaleData.java --"
+echo "   Copyright (C) 2004, 2005  Free Software Foundation, Inc."
+echo
+echo "This file is part of GNU Classpath."
+echo
+echo "GNU Classpath is free software; you can redistribute it and/or modify"
+echo "it under the terms of the GNU General Public License as published by"
+echo "the Free Software Foundation; either version 2, or (at your option)"
+echo "any later version."
+echo
+echo "GNU Classpath is distributed in the hope that it will be useful, but"
+echo "WITHOUT ANY WARRANTY; without even the implied warranty of"
+echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU"
+echo "General Public License for more details."
+echo
+echo "You should have received a copy of the GNU General Public License"
+echo "along with GNU Classpath; see the file COPYING.  If not, write to the"
+echo "Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA"
+echo "02110-1301 USA."
+echo
+echo "Linking this library statically or dynamically with other modules is"
+echo "making a combined work based on this library.  Thus, the terms and"
+echo "conditions of the GNU General Public License cover the whole"
+echo "combination."
+echo
+echo "As a special exception, the copyright holders of this library give you"
+echo "permission to link this library with independent modules to produce an"
+echo "executable, regardless of the license terms of these independent"
+echo "modules, and to copy and distribute the resulting executable under"
+echo "terms of your choice, provided that you also meet, for each linked"
+echo "independent module, the terms and conditions of the license of that"
+echo "module.  An independent module is a module which is not derived from"
+echo "or based on this library.  If you modify this library, you may extend"
+echo "this exception to your version of the library, but you are not"
+echo "obligated to do so.  If you do not wish to do so, delete this"
+echo "exception statement from your version. */"
+echo
+echo
+echo "package gnu.java.locale;"
+echo
+echo "// This file was automatically generated by scripts/generate-locale-list.sh"
+echo
+echo
+echo "class LocaleData"
+echo "{"
+echo "  public static final String[] localeNames ="
+echo "    {"
+
+( cd $CLASSPATH_SRCDIR/resource/gnu/java/locale ; ls LocaleInformation_*.properties ) | xargs -n 1 echo | sed -e 's/LocaleInformation_\(.*\)\.properties/\1/' |
+while read locale ; do echo "      \"$locale\"," ; done
+
+echo "    };"
+
+echo
+echo "  public static final String[] collatorLocaleNames ="
+echo "    {"
+
+( cd $CLASSPATH_SRCDIR/resource/gnu/java/locale; grep -l collation_rules LocaleInformation_*.properties) |
+ xargs -n 1 echo | sed -e 's/LocaleInformation_\(.*\)\.properties/\1/' |
+ sed -e '/^$/ d' |
+ while read locale ; do echo "      \"$locale\"," ; done
+
+echo "    };"
+
+echo "}"

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/scripts/generate-locale-list.sh

------------------------------------------------------------------------------
    svn:executable = *

Added: llvm-gcc-4.2/trunk/libjava/classpath/scripts/import-cacerts.sh
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/scripts/import-cacerts.sh?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/scripts/import-cacerts.sh (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/scripts/import-cacerts.sh Thu Nov  8 16:56:19 2007
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+function visitFile() {
+	install/bin/gkeytool \
+	-cacert \
+	-v \
+	-storepass changeit \
+	-keystore resource/java/security/cacerts.gkr \
+	-file "$1"
+}
+
+function visitDir() {
+	local d
+	d=$1
+	for f in "$d/"*
+	do
+		if [ -d "$f" ] ; then
+			visitDir "$f"
+		else
+			visitFile "$f"
+		fi
+	done
+}
+
+if [ "$#" -lt "1" ] ; then
+	echo "Usage: import-cacerts DIR"
+	echo "Import CA trusted certificates into a 'cacerts.gkr' key store"
+	echo "under resource/java/security using 'changeit' as its password,"
+	echo "and constructing the Alias from the certificate's file name."
+	echo
+	echo "  DIR  the 'ca-certificates' deb package installation directory"
+	echo "         containing trusted CA certificates."
+	echo
+else
+	caDir=$1
+	if [ ! -d $caDir ] ; then
+		echo "Argument MUST be a directory."
+		echo "Type command with no arguments for usage string."
+		exit 1
+	fi
+	visitDir $caDir
+fi
+exit 0
\ No newline at end of file

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/scripts/import-cacerts.sh

------------------------------------------------------------------------------
    svn:executable = *

Added: llvm-gcc-4.2/trunk/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/sun/reflect/annotation/AnnotationInvocationHandler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,340 @@
+/* sun.reflect.annotation.AnnotationInvocationHandler
+   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 sun.reflect.annotation;
+
+import java.io.Serializable;
+import java.lang.annotation.AnnotationTypeMismatchException;
+import java.lang.annotation.IncompleteAnnotationException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This class exists for serialization compatibility with the JDK.
+ * VMs can choose to implement annotations by constructing proxies
+ * with this invocation handler, but that is not required.
+ * If a different strategy for proxy objects is chosen, they can
+ * have a writeReplace method to substitute a Proxy based on this
+ * invocation handler is used for serialization.
+ */
+public final class AnnotationInvocationHandler
+  implements InvocationHandler, Serializable
+{
+    private static final long serialVersionUID = 6182022883658399397L;
+    private final Class type;
+    private final Map memberValues;
+
+    /**
+     * Construct a new invocation handler for an annotation proxy.
+     * Note that the VM is responsible for filling the memberValues map
+     * with the default values of all the annotation members.
+     */
+    public AnnotationInvocationHandler(Class type, Map memberValues)
+    {
+        this.type = type;
+        this.memberValues = memberValues;
+    }
+
+    /**
+     * Compare an instance of AnnotationInvocationHandler with another object.
+     * Note that the other object does not have to be an
+     * AnnotationInvocationHandler, any implementation of the annotation
+     * interface is allowed to be compared for equality.
+     * Note that this makes the equals method asymmetric, but this behavior
+     * is specified by Annotation.equals and identical to the JDK.
+     *
+     * This method is public for use by other parts of the VM. Some VMs
+     * (can) use different representations of annotations that reuse this
+     * method.
+     */
+    public static boolean equals(Class type, Map memberValues, Object other)
+    {
+        if (type.isInstance(other))
+        {
+            try
+            {
+                Method[] methods = type.getDeclaredMethods();
+                if (methods.length == memberValues.size())
+                {
+                    for (int i = 0; i < methods.length; i++)
+                    {
+                        String key = methods[i].getName();
+                        Object val = methods[i].invoke(other, new Object[0]);
+                        if (! deepEquals(memberValues.get(key), val))
+                        {
+                            return false;
+                        }
+                    }
+                    return true;
+                }
+            }
+            catch (IllegalAccessException _)
+            {
+                // Ignore exception, like the JDK
+            }
+            catch (InvocationTargetException _)
+            {
+                // Ignore exception, like the JDK
+            }
+        }
+        return false;
+    }
+
+    private static boolean deepEquals(Object o1, Object o2)
+    {
+        if (o1 == o2)
+            return true;
+
+        if (o1 == null || o2 == null)
+            return false;
+
+        if (o1 instanceof boolean[] && o2 instanceof boolean[])
+            return Arrays.equals((boolean[]) o1, (boolean[]) o2);
+
+        if (o1 instanceof byte[] && o2 instanceof byte[])
+            return Arrays.equals((byte[]) o1, (byte[]) o2);
+
+        if (o1 instanceof char[] && o2 instanceof char[])
+            return Arrays.equals((char[]) o1, (char[]) o2);
+
+        if (o1 instanceof short[] && o2 instanceof short[])
+            return Arrays.equals((short[]) o1, (short[]) o2);
+
+        if (o1 instanceof int[] && o2 instanceof int[])
+            return Arrays.equals((int[]) o1, (int[]) o2);
+
+        if (o1 instanceof float[] && o2 instanceof float[])
+            return Arrays.equals((float[]) o1, (float[]) o2);
+
+        if (o1 instanceof long[] && o2 instanceof long[])
+            return Arrays.equals((long[]) o1, (long[]) o2);
+
+        if (o1 instanceof double[] && o2 instanceof double[])
+            return Arrays.equals((double[]) o1, (double[]) o2);
+
+        if (o1 instanceof Object[] && o2 instanceof Object[])
+            return Arrays.equals((Object[]) o1, (Object[]) o2);
+
+        return o1.equals(o2);
+    }
+
+    private static int deepHashCode(Object obj)
+    {
+        if (obj instanceof boolean[])
+            return Arrays.hashCode((boolean[]) obj);
+
+        if (obj instanceof byte[])
+            return Arrays.hashCode((byte[]) obj);
+
+        if (obj instanceof char[])
+            return Arrays.hashCode((char[]) obj);
+
+        if (obj instanceof short[])
+            return Arrays.hashCode((short[]) obj);
+
+        if (obj instanceof int[])
+            return Arrays.hashCode((int[]) obj);
+
+        if (obj instanceof float[])
+            return Arrays.hashCode((float[]) obj);
+
+        if (obj instanceof long[])
+            return Arrays.hashCode((long[]) obj);
+
+        if (obj instanceof double[])
+            return Arrays.hashCode((double[]) obj);
+
+        if (obj instanceof Object[])
+            return Arrays.hashCode((Object[]) obj);
+
+        return obj.hashCode();
+    }
+
+    /**
+     * Compute the hashCode for an annotation. Note that the algorithm is
+     * specified by Annotation.hashCode.
+     *
+     * This method is public for use by other parts of the VM. Some VMs
+     * (can) use different representations of annotations that reuse this
+     * method.
+     */
+    public static int hashCode(Class type, Map memberValues)
+    {
+        int h = 0;
+        Iterator iter = memberValues.keySet().iterator();
+        while (iter.hasNext())
+        {
+            Object key = iter.next();
+            Object val = memberValues.get(key);
+            h += deepHashCode(val) ^ 127 * key.hashCode();
+        }
+        return h;
+    }
+
+    private static String deepToString(Object obj)
+    {
+        if (obj instanceof boolean[])
+            return Arrays.toString((boolean[]) obj);
+
+        if (obj instanceof byte[])
+            return Arrays.toString((byte[]) obj);
+
+        if (obj instanceof char[])
+            return Arrays.toString((char[]) obj);
+
+        if (obj instanceof short[])
+            return Arrays.toString((short[]) obj);
+
+        if (obj instanceof int[])
+            return Arrays.toString((int[]) obj);
+
+        if (obj instanceof float[])
+            return Arrays.toString((float[]) obj);
+
+        if (obj instanceof long[])
+            return Arrays.toString((long[]) obj);
+
+        if (obj instanceof double[])
+            return Arrays.toString((double[]) obj);
+
+        if (obj instanceof Object[])
+            return Arrays.toString((Object[]) obj);
+
+        return obj.toString();
+    }
+
+    /**
+     * This method is public for use by other parts of the VM. Some VMs
+     * (can) use different representations of annotations that reuse this
+     * method.
+     */
+    public static String toString(Class type, Map memberValues)
+    {
+        StringBuffer sb = new StringBuffer();
+        sb.append('@').append(type.getName()).append('(');
+        String sep = "";
+        Iterator iter = memberValues.keySet().iterator();
+        while (iter.hasNext())
+        {
+            Object key = iter.next();
+            Object val = memberValues.get(key);
+            sb.append(sep).append(key).append('=').append(deepToString(val));
+            sep = ", ";
+        }
+        sb.append(')');
+        return sb.toString();
+    }
+
+    private static Class getBoxedReturnType(Method method)
+    {
+        Class returnType = method.getReturnType();
+
+        if (returnType == boolean.class)
+            return Boolean.class;
+
+        if (returnType == byte.class)
+            return Byte.class;
+
+        if (returnType == char.class)
+            return Character.class;
+
+        if (returnType == short.class)
+            return Short.class;
+
+        if (returnType == int.class)
+            return Integer.class;
+
+        if (returnType == float.class)
+            return Float.class;
+
+        if (returnType == long.class)
+            return Long.class;
+
+        if (returnType == double.class)
+            return Double.class;
+
+        return returnType;
+    }
+
+    public Object invoke(Object proxy, Method method, Object[] args)
+      throws Throwable
+    {
+        String methodName = method.getName().intern();
+        if (args == null || args.length == 0)
+        {
+            if (methodName == "toString")
+            {
+                return toString(type, memberValues);
+            }
+            else if (methodName == "hashCode")
+            {
+                return Integer.valueOf(hashCode(type, memberValues));
+            }
+            else if (methodName == "annotationType")
+            {
+                return type;
+            }
+            else
+            {
+                Object val = memberValues.get(methodName);
+                if (val == null)
+                {
+                    throw new IncompleteAnnotationException(type, methodName);
+                }
+                if (! getBoxedReturnType(method).isInstance(val))
+                {
+                    throw new AnnotationTypeMismatchException(method,
+                        val.getClass().getName());
+                }
+                return val;
+            }
+        }
+        else if (args.length == 1)
+        {
+            if (methodName == "equals")
+            {
+                return Boolean.valueOf(equals(type, memberValues, args[0]));
+            }
+        }
+        throw new InternalError("Invalid annotation proxy");
+    }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/.cvsignore
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/.cvsignore?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/.cvsignore (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/.cvsignore Thu Nov  8 16:56:19 2007
@@ -0,0 +1,6 @@
+jarsigner
+keytool
+Makefile.in
+Makefile
+tools.zip
+appletviewer

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.am?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.am (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.am Thu Nov  8 16:56:19 2007
@@ -0,0 +1,172 @@
+## Input file for automake to generate the Makefile.in used by configure
+
+GLIBJ_CLASSPATH='$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip'
+
+# Setup the compiler to use the GNU Classpath library we just build
+if FOUND_GCJ
+JCOMPILER = $(GCJ) -encoding UTF-8 --bootclasspath $(GLIBJ_CLASSPATH) --classpath . -C
+else
+if FOUND_JIKES
+JCOMPILER = $(JIKES) $(JIKESENCODING) -bootclasspath '' -extdirs '' -sourcepath '' --classpath $(GLIBJ_CLASSPATH):.
+else
+if FOUND_GCJX
+JCOMPILER = $(GCJX) -encoding UTF-8 -bootclasspath '' -sourcepath '' -classpath $(GLIBJ_CLASSPATH):.
+else
+if FOUND_ECJ
+JCOMPILER = $(ECJ) -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath .
+else
+error dunno how to setup the JCOMPILER and compile
+endif
+endif
+endif
+endif
+
+## GCJ LOCAL: do not build and install wrapper binaries here, since
+## the build ordering will not work.  Instead build them in
+## gcc/libjava/Makefile.am.
+# if CREATE_WRAPPERS
+# bin_SCRIPTS =
+# bin_PROGRAMS = gappletviewer gjarsigner gkeytool \
+# 	gjar gnative2ascii gserialver
+# 
+# if FOUND_GCJ
+# LIBJVM = -lgcj
+# else
+# if FOUND_CACAO
+# LIBJVM = -ljvm
+# else
+# LIBJVM =
+# endif
+# endif
+# 
+# AM_CPPFLAGS = -Wall \
+# 	-I$(top_srcdir)/include \
+# 	-DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\""
+# 
+# gappletviewer_SOURCES = toolwrapper.c
+# gappletviewer_CFLAGS = \
+# 	-DTOOLPACKAGE="\"appletviewer\"" \
+# 	-DTOOLNAME="\"gappletviewer\""
+# gappletviewer_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gjarsigner_SOURCES = toolwrapper.c
+# gjarsigner_CFLAGS = \
+# 	-DTOOLPACKAGE="\"jarsigner\"" \
+# 	-DTOOLNAME="\"gjarsigner\""
+# gjarsigner_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gkeytool_SOURCES = toolwrapper.c
+# gkeytool_CFLAGS = \
+# 	-DTOOLPACKAGE="\"keytool\"" \
+# 	-DTOOLNAME="\"gkeytool\""
+# gkeytool_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gjar_SOURCES = toolwrapper.c
+# gjar_CFLAGS = \
+# 	-DTOOLPACKAGE="\"jar\"" \
+# 	-DTOOLNAME="\"gjar\""
+# gjar_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gnative2ascii_SOURCES = toolwrapper.c
+# gnative2ascii_CFLAGS = \
+# 	-DTOOLPACKAGE="\"native2ascii\"" \
+# 	-DTOOLNAME="\"gnative2ascii\""
+# gnative2ascii_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gserialver_SOURCES = toolwrapper.c
+# gserialver_CFLAGS = \
+# 	-DTOOLPACKAGE="\"serialver\"" \
+# 	-DTOOLNAME="\"gserialver\""
+# gserialver_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# else
+# bin_SCRIPTS = gappletviewer gjarsigner gkeytool \
+# 	gjar gnative2ascii gserialver
+# bin_PROGRAMS =
+# endif
+## END GCJ LOCAL
+EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
+	gjar.in gnative2ascii.in gserialver.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
+
+# The zip files with classes we want to produce.
+
+## GCJ LOCAL: rename this tools.jar for libgcj_tools_la_SOURCES in
+## gcc/libjava/Makefile.am.
+TOOLS_ZIP = tools.jar
+
+# Extra objects that will not exist until configure-time
+BUILT_SOURCES = $(TOOLS_ZIP)
+
+# The templates that must be included into the generated zip file.
+GRMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav
+RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmi/rmic/templates/*.jav
+
+TOOLS_TEMPLATES = $(GRMIC_TEMPLATES) $(RMIC_TEMPLATES)
+
+# This covers the built-in help texts, both for giop and rmic subpackages.
+GIOP_HELPS = $(srcdir)/gnu/classpath/tools/giop/*.txt
+RMI_HELPS = $(srcdir)/gnu/classpath/tools/rmi/*.txt
+
+TOOLS_HELPS = $(GIOP_HELPS) $(RMI_HELPS)
+
+# The tool specific README files.
+READMES = $(srcdir)/gnu/classpath/tools/giop/README
+
+# All the files we find "interesting"
+ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(TOOLS_TEMPLATES) $(TOOLS_HELPS)
+
+## GCJ LOCAL: build tools.zip but do not install it.  It is installed
+## in gcc/libjava/Makefile.am.
+# # Some architecture independent data to be installed.
+# TOOLS_DATA = $(TOOLS_ZIP)
+noinst_DATA = $(TOOLS_ZIP)
+
+# Where we want these data files installed.
+## GCJ LOCAL: install libgcj-tools.jar alongside libgcj.jar.
+# TOOLSdir = $(datadir)/java
+
+# 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.
+## GCJ LOCAL: assume FASTJAR since we pass --with-fastjar to configure
+$(TOOLS_ZIP): $(TOOLS_JAVA_FILES)
+	mkdir -p classes/gnu/classpath/tools/giop/grmic/templates
+	mkdir -p classes/gnu/classpath/tools/rmi/rmic/templates
+	mkdir -p classes/gnu/classpath/tools/appletviewer
+	mkdir -p classes/gnu/classpath/tools/jarsigner
+	mkdir -p classes/gnu/classpath/tools/keytool
+	cp $(RMIC_TEMPLATES) classes/gnu/classpath/tools/rmi/rmic/templates
+	cp $(GRMIC_TEMPLATES) classes/gnu/classpath/tools/giop/grmic/templates
+	cp $(RMI_HELPS) classes/gnu/classpath/tools/rmi/
+	cp $(GIOP_HELPS) classes/gnu/classpath/tools/giop/
+	$(JCOMPILER) -d classes $(TOOLS_JAVA_FILES)
+	(cd classes; \
+	$(FASTJAR) cf ../$(TOOLS_ZIP) .; \
+	cd ..)
+	rm -rf classes
+
+# Zip file be gone! (and make sure the classes are gone too)
+clean-local:
+	rm -rf $(TOOLS_ZIP) classes
+
+# FIXME: remove this when GNU Classpath includes a bootstrap VM.
+installcheck-binSCRIPTS:
+	:

Propchange: llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.am

------------------------------------------------------------------------------
    svn:executable = *

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/Makefile.in Thu Nov  8 16:56:19 2007
@@ -0,0 +1,626 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005  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.
+
+ at SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+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@
+subdir = tools
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/appletviewer.in $(srcdir)/gappletviewer.in \
+	$(srcdir)/gjar.in $(srcdir)/gjarsigner.in \
+	$(srcdir)/gkeytool.in $(srcdir)/gnative2ascii.in \
+	$(srcdir)/gserialver.in $(srcdir)/jarsigner.in \
+	$(srcdir)/keytool.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/multi.m4 \
+	$(top_srcdir)/../../libtool.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/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.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 appletviewer jarsigner keytool
+SOURCES =
+DIST_SOURCES =
+DATA = $(noinst_DATA)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
+BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
+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@
+CREATE_ALSA_LIBRARIES_FALSE = @CREATE_ALSA_LIBRARIES_FALSE@
+CREATE_ALSA_LIBRARIES_TRUE = @CREATE_ALSA_LIBRARIES_TRUE@
+CREATE_API_DOCS_FALSE = @CREATE_API_DOCS_FALSE@
+CREATE_API_DOCS_TRUE = @CREATE_API_DOCS_TRUE@
+CREATE_COLLECTIONS_FALSE = @CREATE_COLLECTIONS_FALSE@
+CREATE_COLLECTIONS_TRUE = @CREATE_COLLECTIONS_TRUE@
+CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
+CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
+CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
+CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GCONF_PEER_LIBRARIES_FALSE = @CREATE_GCONF_PEER_LIBRARIES_FALSE@
+CREATE_GCONF_PEER_LIBRARIES_TRUE = @CREATE_GCONF_PEER_LIBRARIES_TRUE@
+CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
+CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
+CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
+CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
+CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
+CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
+CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
+CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
+CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
+CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ECJ = @ECJ@
+EGREP = @EGREP@
+ENABLE_LOCAL_SOCKETS_FALSE = @ENABLE_LOCAL_SOCKETS_FALSE@
+ENABLE_LOCAL_SOCKETS_TRUE = @ENABLE_LOCAL_SOCKETS_TRUE@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXAMPLESDIR = @EXAMPLESDIR@
+EXEEXT = @EXEEXT@
+FASTJAR = @FASTJAR@
+FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
+FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
+FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
+FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
+FOUND_GCJX_TRUE = @FOUND_GCJX_TRUE@
+FOUND_GCJ_FALSE = @FOUND_GCJ_FALSE@
+FOUND_GCJ_TRUE = @FOUND_GCJ_TRUE@
+FOUND_JIKES_FALSE = @FOUND_JIKES_FALSE@
+FOUND_JIKES_TRUE = @FOUND_JIKES_TRUE@
+FOUND_KJC_FALSE = @FOUND_KJC_FALSE@
+FOUND_KJC_TRUE = @FOUND_KJC_TRUE@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GCJ = @GCJ@
+GCJX = @GCJX@
+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@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
+INSTALL_CLASS_FILES_FALSE = @INSTALL_CLASS_FILES_FALSE@
+INSTALL_CLASS_FILES_TRUE = @INSTALL_CLASS_FILES_TRUE@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_GLIBJ_ZIP_FALSE = @INSTALL_GLIBJ_ZIP_FALSE@
+INSTALL_GLIBJ_ZIP_TRUE = @INSTALL_GLIBJ_ZIP_TRUE@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@
+JAY = @JAY@
+JAY_SKELETON = @JAY_SKELETON@
+JIKES = @JIKES@
+JIKESENCODING = @JIKESENCODING@
+JIKESWARNINGS = @JIKESWARNINGS@
+KJC = @KJC@
+LDFLAGS = @LDFLAGS@
+LIBDEBUG = @LIBDEBUG@
+LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVERSION = @LIBVERSION@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+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@
+REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@
+REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@
+REMOVE = @REMOVE@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@
+STRIP = @STRIP@
+USER_CLASSLIB = @USER_CLASSLIB@
+USER_JAVAH = @USER_JAVAH@
+USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
+USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
+USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
+USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_ESCHER_FALSE = @USE_ESCHER_FALSE@
+USE_ESCHER_TRUE = @USE_ESCHER_TRUE@
+USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
+USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
+VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+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@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+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@
+datadir = @datadir@
+default_toolkit = @default_toolkit@
+exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+multi_basedir = @multi_basedir@
+nativeexeclibdir = @nativeexeclibdir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexeclibdir = @toolexeclibdir@
+vm_classes = @vm_classes@
+GLIBJ_CLASSPATH = '$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip'
+ at FOUND_ECJ_TRUE@@FOUND_GCJX_FALSE@@FOUND_GCJ_FALSE@@FOUND_JIKES_FALSE at JCOMPILER = $(ECJ) -encoding UTF-8 -bootclasspath $(GLIBJ_CLASSPATH) -classpath .
+ at FOUND_GCJX_TRUE@@FOUND_GCJ_FALSE@@FOUND_JIKES_FALSE at JCOMPILER = $(GCJX) -encoding UTF-8 -bootclasspath '' -sourcepath '' -classpath $(GLIBJ_CLASSPATH):.
+ at FOUND_GCJ_FALSE@@FOUND_JIKES_TRUE at JCOMPILER = $(JIKES) $(JIKESENCODING) -bootclasspath '' -extdirs '' -sourcepath '' --classpath $(GLIBJ_CLASSPATH):.
+
+# Setup the compiler to use the GNU Classpath library we just build
+ at FOUND_GCJ_TRUE@JCOMPILER = $(GCJ) -encoding UTF-8 --bootclasspath $(GLIBJ_CLASSPATH) --classpath . -C
+
+# if CREATE_WRAPPERS
+# bin_SCRIPTS =
+# bin_PROGRAMS = gappletviewer gjarsigner gkeytool \
+# 	gjar gnative2ascii gserialver
+# 
+# if FOUND_GCJ
+# LIBJVM = -lgcj
+# else
+# if FOUND_CACAO
+# LIBJVM = -ljvm
+# else
+# LIBJVM =
+# endif
+# endif
+# 
+# AM_CPPFLAGS = -Wall \
+# 	-I$(top_srcdir)/include \
+# 	-DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\""
+# 
+# gappletviewer_SOURCES = toolwrapper.c
+# gappletviewer_CFLAGS = \
+# 	-DTOOLPACKAGE="\"appletviewer\"" \
+# 	-DTOOLNAME="\"gappletviewer\""
+# gappletviewer_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gjarsigner_SOURCES = toolwrapper.c
+# gjarsigner_CFLAGS = \
+# 	-DTOOLPACKAGE="\"jarsigner\"" \
+# 	-DTOOLNAME="\"gjarsigner\""
+# gjarsigner_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gkeytool_SOURCES = toolwrapper.c
+# gkeytool_CFLAGS = \
+# 	-DTOOLPACKAGE="\"keytool\"" \
+# 	-DTOOLNAME="\"gkeytool\""
+# gkeytool_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gjar_SOURCES = toolwrapper.c
+# gjar_CFLAGS = \
+# 	-DTOOLPACKAGE="\"jar\"" \
+# 	-DTOOLNAME="\"gjar\""
+# gjar_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gnative2ascii_SOURCES = toolwrapper.c
+# gnative2ascii_CFLAGS = \
+# 	-DTOOLPACKAGE="\"native2ascii\"" \
+# 	-DTOOLNAME="\"gnative2ascii\""
+# gnative2ascii_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# gserialver_SOURCES = toolwrapper.c
+# gserialver_CFLAGS = \
+# 	-DTOOLPACKAGE="\"serialver\"" \
+# 	-DTOOLNAME="\"gserialver\""
+# gserialver_LDFLAGS = -L$(libdir) $(LIBJVM)
+# 
+# else
+# bin_SCRIPTS = gappletviewer gjarsigner gkeytool \
+# 	gjar gnative2ascii gserialver
+# bin_PROGRAMS =
+# endif
+EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
+	gjar.in gnative2ascii.in gserialver.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
+
+# The zip files with classes we want to produce.
+TOOLS_ZIP = tools.jar
+
+# Extra objects that will not exist until configure-time
+BUILT_SOURCES = $(TOOLS_ZIP)
+
+# The templates that must be included into the generated zip file.
+GRMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav
+RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmi/rmic/templates/*.jav
+TOOLS_TEMPLATES = $(GRMIC_TEMPLATES) $(RMIC_TEMPLATES)
+
+# This covers the built-in help texts, both for giop and rmic subpackages.
+GIOP_HELPS = $(srcdir)/gnu/classpath/tools/giop/*.txt
+RMI_HELPS = $(srcdir)/gnu/classpath/tools/rmi/*.txt
+TOOLS_HELPS = $(GIOP_HELPS) $(RMI_HELPS)
+
+# The tool specific README files.
+READMES = $(srcdir)/gnu/classpath/tools/giop/README
+
+# All the files we find "interesting"
+ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(TOOLS_TEMPLATES) $(TOOLS_HELPS)
+
+# # Some architecture independent data to be installed.
+# TOOLS_DATA = $(TOOLS_ZIP)
+noinst_DATA = $(TOOLS_ZIP)
+all: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+$(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 \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  tools/Makefile'; \
+	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
+gappletviewer: $(top_builddir)/config.status $(srcdir)/gappletviewer.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gjarsigner: $(top_builddir)/config.status $(srcdir)/gjarsigner.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gkeytool: $(top_builddir)/config.status $(srcdir)/gkeytool.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gjar: $(top_builddir)/config.status $(srcdir)/gjar.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gnative2ascii: $(top_builddir)/config.status $(srcdir)/gnative2ascii.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+gserialver: $(top_builddir)/config.status $(srcdir)/gserialver.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+appletviewer: $(top_builddir)/config.status $(srcdir)/appletviewer.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+jarsigner: $(top_builddir)/config.status $(srcdir)/jarsigner.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+keytool: $(top_builddir)/config.status $(srcdir)/keytool.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+	$(MAKE) $(AM_MAKEFLAGS) \
+	  top_distdir="$(top_distdir)" distdir="$(distdir)" \
+	  dist-hook
+check-am: all-am
+check: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(DATA)
+installdirs:
+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)
+
+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-generic clean-libtool clean-local mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	clean-local dist-hook distclean distclean-generic \
+	distclean-libtool distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-exec \
+	install-exec-am install-info install-info-am install-man \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	uninstall uninstall-am uninstall-info-am
+
+ at FOUND_ECJ_FALSE@@FOUND_GCJX_FALSE@@FOUND_GCJ_FALSE@@FOUND_JIKES_FALSE at error dunno how to setup the JCOMPILER and compile
+
+# Where we want these data files installed.
+# TOOLSdir = $(datadir)/java
+
+# 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): $(TOOLS_JAVA_FILES)
+	mkdir -p classes/gnu/classpath/tools/giop/grmic/templates
+	mkdir -p classes/gnu/classpath/tools/rmi/rmic/templates
+	mkdir -p classes/gnu/classpath/tools/appletviewer
+	mkdir -p classes/gnu/classpath/tools/jarsigner
+	mkdir -p classes/gnu/classpath/tools/keytool
+	cp $(RMIC_TEMPLATES) classes/gnu/classpath/tools/rmi/rmic/templates
+	cp $(GRMIC_TEMPLATES) classes/gnu/classpath/tools/giop/grmic/templates
+	cp $(RMI_HELPS) classes/gnu/classpath/tools/rmi/
+	cp $(GIOP_HELPS) classes/gnu/classpath/tools/giop/
+	$(JCOMPILER) -d classes $(TOOLS_JAVA_FILES)
+	(cd classes; \
+	$(FASTJAR) cf ../$(TOOLS_ZIP) .; \
+	cd ..)
+	rm -rf classes
+
+# Zip file be gone! (and make sure the classes are gone too)
+clean-local:
+	rm -rf $(TOOLS_ZIP) classes
+
+# 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:

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/README
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/README?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/README (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/README Thu Nov  8 16:56:19 2007
@@ -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.
+
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/appletviewer.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/appletviewer.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/appletviewer.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/appletviewer.in Thu Nov  8 16:56:19 2007
@@ -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 $@

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gappletviewer.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gappletviewer.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gappletviewer.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gappletviewer.in Thu Nov  8 16:56:19 2007
@@ -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 "$@"

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gjar.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gjar.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gjar.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gjar.in Thu Nov  8 16:56:19 2007
@@ -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 jar tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jar.Main "$@"

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gjarsigner.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gjarsigner.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gjarsigner.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gjarsigner.in Thu Nov  8 16:56:19 2007
@@ -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 "$@"

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gkeytool.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gkeytool.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gkeytool.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gkeytool.in Thu Nov  8 16:56:19 2007
@@ -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 "$@"

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnative2ascii.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnative2ascii.in?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnative2ascii.in (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnative2ascii.in Thu Nov  8 16:56:19 2007
@@ -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 native2ascii tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.native2ascii.Main "$@"

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/AbstractMethodGenerator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/AbstractMethodGenerator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/AbstractMethodGenerator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/AbstractMethodGenerator.java Thu Nov  8 16:56:19 2007
@@ -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;
+
+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();
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/HelpPrinter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/HelpPrinter.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/HelpPrinter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/HelpPrinter.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,116 @@
+/* HelpPrinter -- help message printer
+   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;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * The shared class to print the help message and exit, when applicable. 
+ * Support the --help key.
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)
+ */
+public class HelpPrinter
+{
+  /**
+   * Check for the --help, -help and -? keys. If one is found, print help and
+   * exit the program.
+   * 
+   * @param args the program arguments.
+   * @param helpResourcePath the path to the help resource, related to the
+   *          HelpPrinter class.
+   */
+  public static void checkHelpKey(String[] args, String helpResourcePath)
+  {
+    for (int i = 0; i < args.length; i++)
+      {
+        String a = args[i];
+        if (a.equals("-?") || a.equalsIgnoreCase("-help")
+            || a.equalsIgnoreCase("--help"))
+          printHelpAndExit(helpResourcePath);
+      }
+  }
+
+  /**
+   * Prints the contents of the resource specified by the designated path.
+   * 
+   * @param helpResourcePath the path to a help resource, related to the
+   *          HelpPrinter class.
+   */
+  public static void printHelp(String helpResourcePath)
+  {
+    InputStream in = HelpPrinter.class.getResourceAsStream(helpResourcePath);
+    BufferedReader br = new BufferedReader(new InputStreamReader(in));
+    try
+      {
+        String s;
+        while ((s = br.readLine()) != null)
+          System.out.println(s);
+      }
+    catch (IOException x)
+      {
+        System.err.print("Resource loading is broken:");
+        x.printStackTrace(System.err);
+      }
+    finally
+      {
+        try
+          {
+            br.close();
+          }
+        catch (IOException ignored)
+          {
+          }
+      }
+  }
+
+  /**
+   * Prints the help message and terminates.
+   * 
+   * @param helpResourcePath the path to the help resource, related to the
+   *          HelpPrinter class.
+   */
+  public static void printHelpAndExit(String helpResourcePath)
+  {
+    printHelp(helpResourcePath);
+    System.exit(0);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,81 @@
+/* AppletClassLoader -- a loader for applet classes
+   Copyright (C) 2004, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+
+public class AppletClassLoader extends URLClassLoader
+{
+  /**
+   * Constructs a new <code>AppletLoader</code> object.
+   *
+   * @param codebase the codebase of the applet
+   * @param archives the urls to add to the search path
+   */
+  public AppletClassLoader(URL codebase, ArrayList archives)
+  {
+    super(new URL[0]);
+
+    for (int count = 0; count < archives.size(); count++)
+      addURL((URL) archives.get(count));
+
+    addURL(codebase);
+  }
+
+  /**
+   * Finds the specified class. This method should be overridden by
+   * class loader implementations that follow the delegation model for
+   * loading classes, and will be invoked by the loadClass method after
+   * checking the parent class loader for the requested class. The default
+   * implementation throws a ClassNotFoundException.
+   *
+   * (description copied from java.lang.ClassLoader.findClass(String))
+   *
+   * @param name The name of the class.
+   *
+   * @return the resulting <code>Class</code> object.
+   *
+   * @exception ClassNotFoundException if the class is not found.
+   */
+  protected Class findClass(String name) throws ClassNotFoundException
+  {
+    return super.findClass(name);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* AppletSecurityManager.java -- an applet security manager
+   Copyright (C) 2004, 2006  Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.appletviewer;
+
+import java.io.FilePermission;
+import java.net.SocketPermission;
+import java.security.Permission;
+import java.security.SecurityPermission;
+import java.util.PropertyPermission;
+
+class AppletSecurityManager extends SecurityManager
+{
+  private boolean plugin;
+  
+  AppletSecurityManager(boolean plugin)
+  {
+    this.plugin = plugin;
+  }
+
+  public void checkPermission(Permission permission)
+  {
+    if (permission == null)
+      throw new NullPointerException();
+
+    // FIXME: we need to restrict this.
+    //
+    // libgcj asks for "java.io.FilePermission <<ALL FILES>> execute"
+    // to be able to execute "addr2line" to get proper stack traces.
+    if (permission instanceof FilePermission)
+      return;
+    
+    // FIXME: we need to restrict this.
+    if (permission instanceof SecurityPermission)
+      return;
+    
+    // FIXME: is this really needed ?
+    if (permission instanceof PropertyPermission)
+      return;
+    
+    // Needed to allow to access AWT event queue.
+    if (permission.getName().equals("accessEventQueue"))
+      return;
+    
+    // Needed to create a class loader for each codebase.
+    if (permission.getName().equals("createClassLoader"))
+      return;
+
+    // FIXME: we need to allow access to codebase here.
+
+    if (permission instanceof SocketPermission      // for net access
+	|| permission instanceof RuntimePermission) // for checkWrite(FileDescriptor)
+      return;
+
+    if (! plugin && permission.getName().equals("exitVM"))
+      return;
+    
+    // Reject all other permissions.
+    throw new SecurityException();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java Thu Nov  8 16:56:19 2007
@@ -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 at redhat.com)
+ * @author Thomas Fitzsimmons (fitzsim at 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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,66 @@
+/* AppletWarning -- a security warning message display dialog
+   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 javax.swing.JOptionPane;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class AppletWarning
+{
+  private static String TITLE = "WARNING";
+  private static boolean showWarning = false;
+
+  private static String MESSAGE =
+    "The current version of this applet plugin does not provide\n" +
+    "a security manager capable of handling Java (tm) applets. Applets\n" +
+    "have UNRESTRICTED access to your computer. This means they can do\n" +
+    "anything you can do, like deleting all your important data.\n\n" +
+    "Continue ?";
+  
+  public static int show()
+  {
+    if (showWarning)
+      return JOptionPane.showConfirmDialog(null, MESSAGE, TITLE,
+                                           JOptionPane.YES_NO_OPTION,
+                                           JOptionPane.WARNING_MESSAGE);
+    else
+      return JOptionPane.YES_OPTION;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java Thu Nov  8 16:56:19 2007
@@ -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();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,138 @@
+/* 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("unknown codebase");
+      }
+  }
+
+  /**
+   * Returns the value of the specified parameter that was specified
+   * in the <code>APPLET</code> tag for this applet.
+   *
+   * @param name the key name
+   *
+   * @return the key value
+   */
+  public String getParameter(String name)
+  {
+    return (String) 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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,175 @@
+/* ConsoleDialog -- a console dialog for 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 java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+
+/**
+ * This class is a little dialog showing standard output and standard error output.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public class ConsoleDialog extends Frame
+  implements ActionListener
+{
+  static class InternalOutputStream extends OutputStream
+  {
+    private ConsoleDialog console;
+
+    public InternalOutputStream(ConsoleDialog console)
+    {
+      super();
+      this.console = console;
+    }
+
+    public void write(int data) throws IOException
+    {
+      console.print(String.valueOf((char) data));
+    }
+  }
+
+  private TextArea textArea;
+  private Button buttonClear;
+  private Button buttonHide;
+  private PrintStream printStream;
+
+  /**
+   * Creates a console dialog object.
+   */
+  public ConsoleDialog()
+  {
+    super(Main.messages.getString("gcjwebplugin.console_title"));
+
+    setSize(400, 200);
+    setLayout(new BorderLayout());
+    addWindowListener(new WindowAdapter()
+        {
+	  public void windowClosing(WindowEvent event)
+	  {
+	    hide();
+	  }
+        });
+
+    textArea = new TextArea();
+    textArea.setEditable(false);
+    add(textArea);
+
+    Panel panel = new Panel();
+    panel.setLayout(new FlowLayout());
+    add(panel, BorderLayout.SOUTH);
+
+    buttonClear = new Button(Main.messages.getString("gcjwebplugin.console_clear"));
+    buttonClear.addActionListener(this);
+    panel.add(buttonClear);
+
+    buttonHide = new Button(Main.messages.getString("gcjwebplugin.console_hide"));
+    buttonHide.addActionListener(this);
+    panel.add(buttonHide);
+
+    printStream = new PrintStream(new InternalOutputStream(this));
+    clearTextArea();
+  }
+
+  /**
+   * Clears the content of the textarea and inserts the initial text.
+   */
+  public void clearTextArea()
+  {
+    textArea.setText("");
+    
+    println("java.vm.version: " + System.getProperty("java.vm.version"));
+    println("java.vm.vendor: " + System.getProperty("java.vm.vendor"));
+  }
+
+  /**
+   * Print a message into the console dialog.
+   *
+   * @param message the message to print.
+   */
+  public void print(String message)
+  {
+    textArea.append(message);
+  }
+
+  /**
+   * Print a line into the console dialog.
+   *
+   * @param message the line to print.
+   */
+  public void println(String message)
+  {
+    print(message + "\n");
+  }
+
+  /**
+   * Perform actions on button clicks inside the console dialog.
+   *
+   * @param event the event.
+   */
+  public void actionPerformed(ActionEvent event)
+  {
+    if (event.getSource() == buttonHide)
+      hide(); // Hide console window.
+    else if (event.getSource() == buttonClear)
+      clearTextArea(); // Clear text area and insert standard messages.
+  }
+
+  /**
+   * Returns a <code>PrintStream</code> object that prints into the
+   * console dialog.
+   *
+   * @return the <code>PrintStream</code> object.
+   */
+  public PrintStream getPrintStream()
+  {
+    return printStream;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java Thu Nov  8 16:56:19 2007
@@ -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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,293 @@
+/* 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.getopt.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.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ResourceBundle;
+
+
+class Main
+{
+  /**
+   * The localized strings are kept in a separate file.
+   */
+  public static final ResourceBundle messages = ResourceBundle.getBundle
+    ("gnu.classpath.tools.appletviewer.MessagesBundle");
+
+  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("Error loading applet");
+
+    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("usage: appletviewer [OPTION] -code CODE | URL...");
+
+    OptionGroup attributeGroup = new OptionGroup("Applet tag options");
+
+    attributeGroup.add(new Option("code", Main.messages.getString
+                                  ("gcjwebplugin.code_description"),
+                                  "CODE")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          code = argument;
+        }
+      });
+    attributeGroup.add(new Option("codebase", Main.messages.getString
+                                  ("gcjwebplugin.codebase_description"),
+                                  "CODEBASE")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          codebase = argument;
+        }
+      });
+    attributeGroup.add(new Option("archive", Main.messages.getString
+                                  ("gcjwebplugin.archive_description"),
+                                  "ARCHIVE")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          archive = argument;
+        }
+      });
+    attributeGroup.add(new Option("width", Main.messages.getString
+                                  ("gcjwebplugin.width_description"),
+                                  "WIDTH")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          dimensions.width = Integer.parseInt(argument);
+        }
+      });
+    attributeGroup.add(new Option("height", Main.messages.getString
+                                  ("gcjwebplugin.height_description"),
+                                  "HEIGHT")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          dimensions.height = Integer.parseInt(argument);
+        }
+      });
+    attributeGroup.add(new Option("param", Main.messages.getString
+                                  ("gcjwebplugin.param_description"),
+                                  "NAME,VALUE")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          parameters.add(argument);
+        }
+      });
+    OptionGroup pluginGroup = new OptionGroup("Plugin option");
+    pluginGroup.add(new Option("plugin", Main.messages.getString
+                               ("gcjwebplugin.plugin_description"),
+                               "INPUT,OUTPUT")
+      {
+        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("Debugging option");
+    debuggingGroup.add(new Option("verbose", Main.messages.getString
+                                  ("gcjwebplugin.verbose_description"),
+                                  (String) null)
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          verbose = true;
+        }
+      });
+    OptionGroup compatibilityGroup = new OptionGroup("Compatibility options");
+    compatibilityGroup.add(new Option("debug", Main.messages.getString
+                                      ("gcjwebplugin.debug_description"),
+                                      (String) null)
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          // Currently ignored.
+        }
+      });
+    compatibilityGroup.add(new Option("encoding", Main.messages.getString
+                                      ("gcjwebplugin.encoding_description"),
+                                      "CHARSET")
+      {
+        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)
+      {
+	InputStream in;
+	OutputStream out;
+
+        in = new FileInputStream(pipeInName);
+        out = new FileOutputStream(pipeOutName);
+
+	PluginAppletViewer.start(in, out);
+      }
+    else
+      {
+        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(Main.messages.getString("gcjwebplugin.no_input_files"));
+                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("raw arguments:");
+
+        for (int i = 0; i < args.length; i++)
+          System.out.println(" " + args[i]);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java Thu Nov  8 16:56:19 2007
@@ -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)
+      {
+        System.err.println("showDocument failed: " + e);
+      }
+  }
+
+  public void showStatus(String status)
+  {
+    try
+      {
+        PluginAppletViewer.write("status " + status);
+      }
+    catch(IOException e)
+      {
+        System.err.println("showDocument failed: " + e);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,172 @@
+/* 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("  PIPE: applet viewer wrote: " + 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("  PIPE: applet viewer read: " + message);
+
+    if (message == null || message.equals("shutdown"))
+      {
+	// Close input/output channels to plugin.
+	pluginInputStream.close();
+	pluginOutputStream.close();
+
+	System.err.println("appletviewer: exiting plugin applet viewer");
+	System.exit(0);
+      }
+
+    return message;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,454 @@
+/* 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;
+
+import javax.swing.JOptionPane;
+
+
+class PluginAppletWindow
+    extends EmbeddedWindow
+    implements ContainerListener, ComponentListener, MouseListener,
+    MouseMotionListener, InputMethodListener, HierarchyListener,
+    HierarchyBoundsListener
+{
+  
+  // This class implements various listeners because the author of an applet
+  // may attach listeners to it, unaware of the applet's parent (this class). 
+  // So, we must pass all listener events on this plugin applet window to the
+  // actual applet.
+  
+  private static HashMap contexts = new HashMap();
+  private Applet applet;
+  private TagParser parser;
+  private AppletTag tag;
+
+  PluginAppletWindow()
+  {
+    super();
+    addContainerListener(this);
+    addComponentListener(this);
+    addMouseListener(this);
+    addMouseMotionListener(this);
+    addInputMethodListener(this);
+    addHierarchyListener(this);
+    addHierarchyBoundsListener(this);
+  }  
+  
+  ///////////////////////////////////
+  /// ContainerListener Methods /////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when a component is added to the container.
+   * 
+   * @param event the <code>ContainerEvent</code> indicating component
+   *          addition
+   */
+  public void componentAdded(ContainerEvent event)
+  {
+    if (applet != null)
+      {
+        ContainerListener[] l = applet.getContainerListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentAdded(event);
+      }
+  }
+
+  /**
+   * This method is called when a component is removed from the container.
+   * 
+   * @param event the <code>ContainerEvent</code> indicating component removal
+   */
+  public void componentRemoved(ContainerEvent event)
+  {
+    if (applet != null)
+      {
+        ContainerListener[] l = applet.getContainerListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentRemoved(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// ComponentListener Methods /////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the component is resized.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the resize
+   */
+  public void componentResized(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentResized(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is moved.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the move
+   */
+  public void componentMoved(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentMoved(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is made visible.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the visibility
+   */
+  public void componentShown(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentShown(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is hidden.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the visibility
+   */
+  public void componentHidden(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentHidden(event);
+      }
+  }
+     
+  ///////////////////////////////////
+  ////// MouseListener Methods //////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the mouse is clicked (pressed and released
+   * in short succession) on a component.
+   *
+   * @param event the <code>MouseEvent</code> indicating the click
+   */
+  public void mouseClicked(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseClicked(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is pressed over a component.
+   *
+   * @param event the <code>MouseEvent</code> for the press
+   */
+  public void mousePressed(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mousePressed(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is released over a component.
+   *
+   * @param event the <code>MouseEvent</code> for the release
+   */
+  public void mouseReleased(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseReleased(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse enters a component.
+   *
+   * @param event the <code>MouseEvent</code> for the entry
+   */
+  public void mouseEntered(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseEntered(event);
+      }
+  }
+
+  /** 
+   * This method is called when the mouse exits a component.
+   *
+   * @param event the <code>MouseEvent</code> for the exit
+   */
+  public void mouseExited(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseExited(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// MouseMotionListener Methods ///
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the mouse is moved over a component
+   * while a button has been pressed.
+   *
+   * @param event the <code>MouseEvent</code> indicating the motion
+   */
+  public void mouseDragged(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseMotionListener[] l = applet.getMouseMotionListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseDragged(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is moved over a component
+   * while no button is pressed.
+   *
+   * @param event the <code>MouseEvent</code> indicating the motion
+   */
+  public void mouseMoved(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseMotionListener[] l = applet.getMouseMotionListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseMoved(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// InputMethodListener Methods ///
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the text is changed.
+   *
+   * @param event the <code>InputMethodEvent</code> indicating the text change
+   */
+  public void inputMethodTextChanged(InputMethodEvent event)
+  {
+    if (applet != null)
+      {
+        InputMethodListener[] l = applet.getInputMethodListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].inputMethodTextChanged(event);
+      }
+  }
+
+  /**
+   * This method is called when the cursor position within the text is changed.
+   *
+   * @param event the <code>InputMethodEvent</code> indicating the change
+   */
+  public void caretPositionChanged(InputMethodEvent event)
+  {
+    if (applet != null)
+      {
+        InputMethodListener[] l = applet.getInputMethodListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].caretPositionChanged(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  //// HierarchyListener Methods ////
+  ///////////////////////////////////
+  
+  /**
+   * Called when the hierarchy of this component changes. Use
+   * <code>getChangeFlags()</code> on the event to see what exactly changed.
+   *
+   * @param e 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());
+
+        int result = AppletWarning.show();
+        if (result == JOptionPane.NO_OPTION)
+          return;
+
+        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);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* 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("showDocument is not implemented in standalone mode");
+  }
+
+  // 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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,144 @@
+/* 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("appletviewer: option '--code' requires a class filename");
+          System.exit(1);
+        }
+      
+      String tagString =
+        "<EMBED"
+        + " CODE=\"" + code + "\""
+        + " WIDTH=" + dimensions.width
+        + " HEIGHT=" + dimensions.height
+        + " CODEBASE=\"" + codebase + "\""
+        + " ARCHIVE=\"" + archives + "\">";
+
+      // Handle parameters.
+      Iterator pairs = parameters.iterator();
+      while (pairs.hasNext())
+        {
+          StringTokenizer paramTokenizer =
+            new StringTokenizer((String) pairs.next(), ",");
+          tagString +=
+            "<PARAM NAME=" + paramTokenizer.nextToken().trim() + " VALUE="
+            + paramTokenizer.nextToken().trim() + ">";
+        }
+      
+      tagString += "</EMBED>";
+
+      StringReader reader = new StringReader(tagString);
+      String path = System.getProperty("user.dir") + File.separator;
+      TagParser parser = new TagParser(reader,
+                                    new URL("file", "", path));
+      appletTags.addAll(parser.parseAppletTags());
+
+      printTags();
+      createWindows();
+    }
+
+  void printTags()
+  {
+    if (verbose)
+      {
+        System.out.println("parsed applet tags:");
+
+        for (int i = 0; i < appletTags.size(); i++)
+          {
+            AppletTag tag = (AppletTag) appletTags.get(i);
+
+            System.out.println(" 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);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,559 @@
+/* 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(Main.messages.getString("gcjwebplugin.menu_restart"));
+    restartItem.setEnabled(false);
+    restartItem.addActionListener(this);
+    reloadItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_reload"));
+    reloadItem.setEnabled(false);
+    reloadItem.addActionListener(this);
+    cancelItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_cancel"));
+    cancelItem.setEnabled(false);
+    cancelItem.addActionListener(this);
+    saveItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_save"));
+    saveItem.setEnabled(false);
+    saveItem.addActionListener(this);
+    startItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_start"));
+    startItem.setEnabled(false);
+    startItem.addActionListener(this);
+    cloneItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_clone"));
+    cloneItem.setEnabled(false);
+    cloneItem.addActionListener(this);
+    closeItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_close"));
+    closeItem.setEnabled(false);
+    closeItem.addActionListener(this);
+    tagItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_tag"));
+    tagItem.setEnabled(false);
+    tagItem.addActionListener(this);
+    infoItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_info"));
+    infoItem.setEnabled(false);
+    infoItem.addActionListener(this);
+    editItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_edit"));
+    editItem.setEnabled(false);
+    editItem.addActionListener(this);
+    editItem.setEnabled(false);
+    encodingItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_encoding"));
+    encodingItem.setEnabled(false);
+    encodingItem.addActionListener(this);
+    printItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_print"));
+    printItem.setEnabled(false);
+    printItem.addActionListener(this);
+    propertiesItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_properties"));
+    propertiesItem.setEnabled(false);
+    propertiesItem.addActionListener(this);
+    quitItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_quit"));
+    quitItem.addActionListener(this);
+
+    MenuBar menuBar = new MenuBar();
+    Menu menuApplet = new Menu(Main.messages.getString("gcjwebplugin.menu_title"));
+    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("GNU Classpath Applet Viewer: " + tag.code);
+
+    AppletContext context = (AppletContext) contexts.get(tag.codebase);
+    ((StandaloneAppletContext) context).addApplet(applet);
+
+    applet.setStub(new CommonAppletStub(tag, context, applet));
+
+    // Create the frame's peer. Otherwise getPreferredSize will read
+    // its insets as 0.
+    addNotify();
+    Insets i = getInsets();
+    Dimension size = tag.getSize();
+    setSize(i.left + size.width + i.right,
+            i.top + size.height + status.getPreferredSize().height
+            + i.bottom);
+    applet.setSize(size);
+
+    // Initialize the applet before showing this window so that the
+    // applet doesn't receive events before it has been initialized.
+    applet.init();
+    applet.start();
+    setVisible(true);
+  }
+
+  private void closeWindow()
+  {
+    applet.stop();
+    StandaloneAppletViewer.appletWindows.remove(this);
+    StandaloneAppletWindow.this.hide();
+  }
+
+  public void actionPerformed(ActionEvent e)
+  {
+    if (e.getSource() == quitItem)
+      {
+        closeWindow();
+        System.exit(0);
+      }
+    else if (e.getSource() == closeItem)
+      {
+	// Close current window.
+	closeWindow();
+	
+	// Exit if there are other windows left.
+	if (StandaloneAppletViewer.appletWindows.isEmpty())
+          System.exit(0);
+      }
+  }
+
+  void showStatus(String status)
+  {
+    this.status.setText(status);
+  }
+  
+
+  ///////////////////////////////////
+  /// ContainerListener Methods /////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when a component is added to the container.
+   * 
+   * @param event the <code>ContainerEvent</code> indicating component
+   *          addition
+   */
+  public void componentAdded(ContainerEvent event)
+  {
+    if (applet != null)
+      {
+        ContainerListener[] l = applet.getContainerListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentAdded(event);
+      }
+  }
+
+  /**
+   * This method is called when a component is removed from the container.
+   * 
+   * @param event the <code>ContainerEvent</code> indicating component removal
+   */
+  public void componentRemoved(ContainerEvent event)
+  {
+    if (applet != null)
+      {
+        ContainerListener[] l = applet.getContainerListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentRemoved(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// ComponentListener Methods /////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the component is resized.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the resize
+   */
+  public void componentResized(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentResized(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is moved.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the move
+   */
+  public void componentMoved(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentMoved(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is made visible.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the visibility
+   */
+  public void componentShown(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentShown(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is hidden.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the visibility
+   */
+  public void componentHidden(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentHidden(event);
+      }
+  }
+     
+  ///////////////////////////////////
+  ////// MouseListener Methods //////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the mouse is clicked (pressed and released
+   * in short succession) on a component.
+   *
+   * @param event the <code>MouseEvent</code> indicating the click
+   */
+  public void mouseClicked(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseClicked(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is pressed over a component.
+   *
+   * @param event the <code>MouseEvent</code> for the press
+   */
+  public void mousePressed(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mousePressed(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is released over a component.
+   *
+   * @param event the <code>MouseEvent</code> for the release
+   */
+  public void mouseReleased(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseReleased(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse enters a component.
+   *
+   * @param event the <code>MouseEvent</code> for the entry
+   */
+  public void mouseEntered(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseEntered(event);
+      }
+  }
+
+  /** 
+   * This method is called when the mouse exits a component.
+   *
+   * @param event the <code>MouseEvent</code> for the exit
+   */
+  public void mouseExited(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseExited(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// MouseMotionListener Methods ///
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the mouse is moved over a component
+   * while a button has been pressed.
+   *
+   * @param event the <code>MouseEvent</code> indicating the motion
+   */
+  public void mouseDragged(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseMotionListener[] l = applet.getMouseMotionListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseDragged(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is moved over a component
+   * while no button is pressed.
+   *
+   * @param event the <code>MouseEvent</code> indicating the motion
+   */
+  public void mouseMoved(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseMotionListener[] l = applet.getMouseMotionListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseMoved(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// InputMethodListener Methods ///
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the text is changed.
+   *
+   * @param event the <code>InputMethodEvent</code> indicating the text change
+   */
+  public void inputMethodTextChanged(InputMethodEvent event)
+  {
+    if (applet != null)
+      {
+        InputMethodListener[] l = applet.getInputMethodListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].inputMethodTextChanged(event);
+      }
+  }
+
+  /**
+   * This method is called when the cursor position within the text is changed.
+   *
+   * @param event the <code>InputMethodEvent</code> indicating the change
+   */
+  public void caretPositionChanged(InputMethodEvent event)
+  {
+    if (applet != null)
+      {
+        InputMethodListener[] l = applet.getInputMethodListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].caretPositionChanged(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  //// HierarchyListener Methods ////
+  ///////////////////////////////////
+  
+  /**
+   * Called when the hierarchy of this component changes. Use
+   * <code>getChangeFlags()</code> on the event to see what exactly changed.
+   *
+   * @param e 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);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,302 @@
+/* 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();
+            }
+
+          t.parameters.put(key.toLowerCase(), val);
+        }
+  }
+  
+  /**
+   * Parses the archive string and returns a list.
+   * 
+   * @param 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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/CallbackUtil.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,145 @@
+/* CallbackUtil.java -- Callback related utilities
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import gnu.javax.security.auth.callback.ConsoleCallbackHandler;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.CallbackHandler;
+
+/**
+ * A <i>Helper</i> class containing general purpose utlity methods dealing with
+ * callback handlers and their <i>Security Provider</i>.
+ */
+public abstract class CallbackUtil
+{
+  private static final Logger log = Logger.getLogger(CallbackUtil.class.getName());
+
+  // default 0-arguments constructor
+
+  // Class methods
+  // --------------------------------------------------------------------------
+
+  /**
+   * Return an implementation of the {@link CallbackHandler}, from any
+   * {@link Provider}, capable of handling callbacks through the <i>console</i>;
+   * i.e. <code>System.in</code> and <code>System.out</code>.
+   * <p>
+   * If no <i>Security Provider</i> for this type of callback was found, this
+   * method returns the default GNU implementation.
+   * 
+   * @return a console {@link CallbackHandler} implementation.
+   */
+  public static final CallbackHandler getConsoleHandler()
+  {
+    CallbackHandler result = getHandler("Console");
+    if (result == null)
+      {
+        log.fine("No console callback handler found. Will use ours");
+        result = new ConsoleCallbackHandler();
+      }
+    return result;
+  }
+
+  /**
+   * Return a {@link CallbackHandler}, of a designated type, for interacting
+   * with the user.
+   * <p>
+   * This method first finds all currently installed <i>Security Providers</i>
+   * capable of providing such service and then in turn attempts to instantiate
+   * the handler from those providers. As soon as one provider returns a non-
+   * null instance of the callback handler, the search stops and that instance
+   * is returned.
+   * 
+   * @return a {@link CallbackHandler} of the designated type, or
+   *         <code>null</code> if no provider was found for theis type of
+   *         callback.
+   */
+  private static final CallbackHandler getHandler(String handlerType)
+  {
+    log.entering(CallbackUtil.class.getName(), "getHandler", handlerType);
+
+    CallbackHandler result = null;
+    String service = "CallbackHandler." + handlerType;
+    Provider[] providers = Security.getProviders(service);
+    if (providers != null)
+      for (int i = 0; i < providers.length; i++)
+        {
+          Provider p = providers[i];
+          String className = p.getProperty(service);
+          if (className != null)
+            try
+              {
+                result = (CallbackHandler) Class.forName(className.trim()).newInstance();
+              }
+            catch (InstantiationException x)
+              {
+                log.fine("InstantiationException while creating ["
+                         + className + "] from provider [" + p.getName()
+                         + "]. Ignore");
+              }
+            catch (IllegalAccessException x)
+              {
+                log.fine("IllegalAccessException while creating ["
+                         + className + "] from provider [" + p.getName()
+                         + "]. Ignore");
+              }
+            catch (ClassNotFoundException x)
+              {
+                log.fine("ClassNotFoundException while creating ["
+                         + className + "] from provider [" + p.getName()
+                         + "]. Ignore");
+              }
+
+            if (result != null)
+              {
+
+                log.fine("Will use [" + result.getClass().getName()
+                         + "] from [" + p.getName() + "]");
+                break;
+              }
+        }
+
+    log.exiting(CallbackUtil.class.getName(), "getHandler", result);
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/ProviderUtil.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,163 @@
+/* ProviderUtil.java -- Security Provider related utilities
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.Provider;
+import java.security.Security;
+import java.util.logging.Logger;
+
+/**
+ * A <i>Helper</i> class containing general purpose utlity methods dealing with
+ * installing and removing <i>Security Providers</i> at runtime.
+ */
+public abstract class ProviderUtil
+{
+  private static final Logger log = Logger.getLogger(ProviderUtil.class.getName());
+
+  // default 0-arguments constructor
+
+  // Class methods
+  // --------------------------------------------------------------------------
+
+  /**
+   * Attempt to (a) instantiate, and (b) add a designated {@link Provider} by
+   * inserting at at the top of the list of <i>Security Providers</i> already
+   * present at runtime, only if it is not already installed.
+   * <p>
+   * <b>IMPORTANT</b>: This method overrides the security check usually carried
+   * out by the security manager when inserting a new {@link Provider}.
+   * 
+   * @param providerClass a fully qualified, non-null, class name of a
+   *          <i>Security Provider</i> to add if it is not already installed.
+   * @return an instance of {@link SecurityProviderInfo} referencing the
+   *         {@link Provider} instance created with the designated class name,
+   *         and its position in the underlying JVM runtime.
+   */
+  public static final SecurityProviderInfo addProvider(String providerClass)
+  {
+    log.entering(ProviderUtil.class.getName(), "addProvider", providerClass);
+
+    Provider provider = null;
+    try
+      {
+        provider = (Provider) Class.forName(providerClass.trim()).newInstance();
+      }
+    catch (InstantiationException x)
+    {
+      log.fine("InstantiationException while creating [" + providerClass
+               + "]. Ignore");
+    }
+  catch (IllegalAccessException x)
+    {
+      log.fine("IllegalAccessException while creating [" + providerClass
+               + "]. Ignore");
+    }
+  catch (ClassNotFoundException x)
+    {
+      log.fine("ClassNotFoundException while creating [" + providerClass
+               + "]. Ignore");
+    }
+
+    int position = provider != null ? addProvider(provider) : -1;
+    SecurityProviderInfo result = new SecurityProviderInfo(provider, position);
+
+    log.exiting(ProviderUtil.class.getName(), "addProvider", result);
+    return result;
+  }
+
+  /**
+   * Attempt to add the designated {@link Provider} by inserting at at the top
+   * of the list of <i>Security Providers</i> already present at runtime, only
+   * if it is not already installed.
+   * <p>
+   * <b>IMPORTANT</b>: This method overrides the security check usually carried
+   * out by the security manager when inserting a new {@link Provider}.
+   * 
+   * @param provider a non-null <i>Security Provider</i> to add if it is not
+   *          already installed.
+   * @return the new position of the designated provider in the list if it was
+   *         not already present, or <code>-1</code> if it was already
+   *         installed.
+   */
+  public static final int addProvider(final Provider provider)
+  {
+    log.entering(ProviderUtil.class.getName(), "addProvider", provider);
+
+    Integer actualPosition = (Integer) AccessController.doPrivileged(new PrivilegedAction()
+    {
+      public Object run()
+      {
+        int result = Security.insertProviderAt(provider, 1);
+        return Integer.valueOf(result);
+      }
+    });
+
+    int result = actualPosition.intValue();
+    log.fine("Provider [" + provider.getName() + "] installed? " + (result != - 1));
+
+    log.exiting(ProviderUtil.class.getName(), "addProvider", actualPosition);
+    return result;
+  }
+
+  /**
+   * Remove a designated <i>Security Provider</i>.
+   * <p>
+   * <b>IMPORTANT</b>: This method overrides the security check usually carried
+   * out by the security manager when removing a {@link Provider}.
+   * 
+   * @param providerName the name of the {@link Provider} to remove.
+   */
+  public static final void removeProvider(final String providerName)
+  {
+    log.entering(ProviderUtil.class.getName(), "removeProvider", providerName);
+
+    AccessController.doPrivileged(new PrivilegedAction()
+    {
+      public Object run()
+      {
+        Security.removeProvider(providerName);
+        return null;
+      }
+    });
+
+    log.exiting(ProviderUtil.class.getName(), "removeProvider");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/common/SecurityProviderInfo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,99 @@
+/* SecurityProviderInfo.java -- Data Access Object for a security provider
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.security.Provider;
+
+/**
+ * A Data Access Object (DAO) referenceing a <i>Security Provider</i> and its
+ * position in the list of installed <i>Security Providers</i> in the underlying
+ * JVM runtime.
+ */
+public class SecurityProviderInfo
+{
+  final private Provider provider;
+  final private int position;
+  private transient String str;
+
+  /**
+   * Constructs an instance of <code>SecurityProviderInfo</code>.
+   * <p>
+   * Used by {@link ProviderUtil} to indicate the result of adding a provider,
+   * given its class name.
+   * 
+   * @param provider the possibly <code>null</code> {@link Provider}.
+   * @param position the position of <code>provider</code> in the list of
+   * <i>Security Providers</i> in the underlying JVM runtime. <code>-1</code>
+   * if that provider (a) is <code>null</code>, or (b) was not added because it
+   * was already there.
+   */
+  SecurityProviderInfo(Provider provider, int position)
+  {
+    super();
+
+    this.provider = provider;
+    this.position = position;
+  }
+
+  /** @return the possibly <code>null</code> {@link Provider} instance. */
+  public Provider getProvider()
+  {
+    return this.provider;
+  }
+
+  /**
+   * @return the position of the {@link Provider}, or <code>-1</code> if it
+   *         was not added.
+   */
+  public int getPosition()
+  {
+    return this.position;
+  }
+
+  public String toString()
+  {
+    if (str == null)
+      if (provider == null)
+        str = "SecurityProviderInfo{null, -1}";
+      else
+        str = "SecurityProviderInfo{" + provider.getName() + ", " + position + "}";
+
+    return str;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* 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.getopt;
+
+import java.text.MessageFormat;
+
+import gnu.classpath.Configuration;
+
+/**
+ * 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)
+  {
+    super(programName, getVersionString(programName));
+  }
+
+  public ClasspathToolParser(String programName, boolean longOnly)
+  {
+    super(programName, getVersionString(programName), longOnly);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java Thu Nov  8 16:56:19 2007
@@ -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;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java Thu Nov  8 16:56:19 2007
@@ -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;
+
+public 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 + '!';
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,200 @@
+/* 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.
+ */
+public abstract class Option
+{
+  private char shortName;
+
+  private String longName;
+
+  private String description;
+
+  private String argumentName;
+
+  /**
+   * 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)
+  {
+    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)
+  {
+    this.shortName = shortName;
+    this.description = description;
+    this.argumentName = argumentName;
+  }
+
+  /**
+   * 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)
+  {
+    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)
+  {
+    this.shortName = shortName;
+    this.longName = longName;
+    this.argumentName = argumentName;
+    this.description = description;
+  }
+
+  /**
+   * 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;
+  }
+
+  /**
+   * 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;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* 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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,271 @@
+/* OptionGroup.java - a group of related command-line options
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING.  If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library.  Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module.  An independent module is a module which is not derived from
+ or based on this library.  If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so.  If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.getopt;
+
+import java.io.PrintStream;
+import java.text.BreakIterator;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+
+/**
+ * An option group holds a collection of Options. It also has a name. Option
+ * groups are primarily useful for grouping help output.
+ */
+public class OptionGroup
+{
+  /** An 80-character string of whitespaces to use as a source for padding. */
+  private static final String FILLER = "                                        "
+                                     + "                                        ";
+  private String name;
+
+  ArrayList options = new ArrayList();
+
+  /**
+   * Create a new nameless option group. This can only be used by Parser.
+   */
+  OptionGroup()
+  {
+  }
+
+  /**
+   * Create a new option group with the indicated name.
+   * 
+   * @param name the name
+   */
+  public OptionGroup(String name)
+  {
+    this.name = name;
+  }
+
+  /**
+   * Print a designated text to a {@link PrintStream}, eventually wrapping the
+   * lines of text so as to ensure that the width of each line does not overflow
+   * {@link Parser#MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+   * {@link BreakIterator} using the default {@link Locale}.
+   * <p>
+   * The text to print may contain <code>\n</code> characters. This method will
+   * force a line-break for each such character.
+   * 
+   * @param out the {@link PrintStream} destination of the formatted text.
+   * @param text the text to print.
+   * @param leftMargin a positive value indicating the column position of the
+   *          start of the first line. Continuation lines, if they exist, are
+   *          printed starting at <code>leftMargin + 2</code> as per GNU
+   *          convention.
+   * @see Parser#MAX_LINE_LENGTH
+   */
+  protected static void formatText(PrintStream out, String text, int leftMargin)
+  {
+    formatText(out, text, leftMargin, Locale.getDefault());
+  }
+
+  /**
+   * Similar to the method with the same name and three arguments, except that
+   * the caller MUST specify a non-null {@link Locale} instance.
+   * <p>
+   * Print a designated text to a {@link PrintStream}, eventually wrapping the
+   * lines of text so as to ensure that the width of each line does not overflow
+   * {@link Parser#MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+   * {@link BreakIterator} using the designated {@link Locale}.
+   * <p>
+   * The text to print may contain <code>\n</code> characters. This method will
+   * force a line-break for each such character.
+   * 
+   * @param out the {@link PrintStream} destination of the formatted text.
+   * @param text the text to print.
+   * @param leftMargin a positive value indicating the column position of the
+   *          start of the first line. Continuation lines, if they exist, are
+   *          printed starting at <code>leftMargin + 2</code> as per GNU
+   *          convention.
+   * @param aLocale the {@link Locale} instance to use when constructing the
+   *          {@link BreakIterator}.
+   * @see Parser#MAX_LINE_LENGTH
+   */
+  protected static void formatText(PrintStream out, String text, int leftMargin,
+                                   Locale aLocale)
+  {
+    BreakIterator bit = BreakIterator.getLineInstance(aLocale);
+    String[] lines = text.split("\n");
+    int length = leftMargin;
+    String leftPadding = FILLER.substring(0, leftMargin + 2);
+    for (int i = 0; i < lines.length; i++)
+      {
+        text = lines[i];
+        bit.setText(text);
+        int start = bit.first();
+        int finish;
+        while ((finish = bit.next()) != BreakIterator.DONE)
+          {
+            String word = text.substring(start, finish);
+            length += word.length();
+            if (length >= Parser.MAX_LINE_LENGTH)
+              {
+                out.println();
+                out.print(leftPadding);
+                length = word.length() + leftMargin + 2;
+              }
+            out.print(word);
+            start = finish;
+          }
+        out.println();
+        if (i != lines.length - 1)
+          {
+            length = leftMargin + 2;
+            out.print(leftPadding);
+          }
+      }
+  }
+
+  /**
+   * Add an option to this option group.
+   * 
+   * @param opt the option to add
+   */
+  public void add(Option opt)
+  {
+    options.add(opt);
+  }
+
+  /**
+   * Print the help output for this option group.
+   * 
+   * @param out the stream to which to print
+   */
+  public void printHelp(PrintStream out, boolean longOnly)
+  {
+    // Compute maximum lengths.
+    int maxArgLen = 0;
+    boolean shortOptionSeen = false;
+    Iterator it;
+
+    // The first pass only looks to see if we have a short option.
+    it = options.iterator();
+    while (it.hasNext())
+      {
+        Option option = (Option) it.next();
+        if (option.getShortName() != '\0')
+          {
+            shortOptionSeen = true;
+            break;
+          }
+      }
+
+    it = options.iterator();
+    while (it.hasNext())
+      {
+        Option option = (Option) it.next();
+        String argName = option.getArgumentName();
+        // First compute the width required for the short
+        // option. "2" is the initial indentation. In the
+        // GNU style we don't print an argument name for
+        // a short option if there is also a long name for
+        // the option.
+        int thisArgLen = 2;
+        if (shortOptionSeen)
+          thisArgLen += 4;
+        if (option.getLongName() != null)
+          {
+            // Handle either '-' or '--'.
+            thisArgLen += 1 + option.getLongName().length();
+            if (! longOnly)
+              ++thisArgLen;
+          }
+        // Add in the width of the argument name.
+        if (argName != null)
+          thisArgLen += 1 + argName.length();
+        maxArgLen = Math.max(maxArgLen, thisArgLen);
+      }
+
+    // Print the help.
+    if (name != null)
+      out.println(name + ":");
+    it = options.iterator();
+    while (it.hasNext())
+      {
+        Option option = (Option) it.next();
+        String argName = option.getArgumentName();
+        int column = 0;
+        if (option.getShortName() != '\0')
+          {
+            out.print("  -");
+            out.print(option.getShortName());
+            column += 4;
+            if (option.getLongName() == null)
+              {
+                if (argName != null)
+                  {
+                    // This is a silly hack just for '-J'.  We don't
+                    // support joined options in general, but this option
+                    // is filtered out before argument processing can see it.
+                    if (option.getShortName() != 'J')
+                      {
+                        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);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,462 @@
+/* Parser.java - parse 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.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;
+
+  private ArrayList options = new ArrayList();
+
+  private ArrayList optionGroups = new ArrayList();
+
+  private OptionGroup defaultGroup = new OptionGroup();
+
+  // These are used while parsing.
+  private int currentIndex;
+
+  private String[] args;
+
+  /**
+   * Create a new parser. The program name is used when printing error messages.
+   * The version string is printed verbatim in response to "--version".
+   * 
+   * @param programName the name of the program
+   * @param versionString the program's version information
+   */
+  public Parser(String programName, String versionString)
+  {
+    this(programName, versionString, false);
+  }
+
+  /**
+   * Print a designated text to a {@link PrintStream}, eventually wrapping the
+   * lines of text so as to ensure that the width of each line does not overflow
+   * {@link #MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+   * {@link BreakIterator} using the default {@link Locale}.
+   * <p>
+   * The text to print may contain <code>\n</code> characters. This method will
+   * force a line-break for each such character.
+   * 
+   * @param out the {@link PrintStream} destination of the formatted text.
+   * @param text the text to print.
+   * @see Parser#MAX_LINE_LENGTH
+   */
+  protected static void formatText(PrintStream out, String text)
+  {
+    formatText(out, text, Locale.getDefault());
+  }
+
+  /**
+   * Similar to the method with the same name and two arguments, except that the
+   * caller MUST specify a non-null {@link Locale} instance.
+   * <p>
+   * Print a designated text to a {@link PrintStream}, eventually wrapping the
+   * lines of text so as to ensure that the width of each line does not overflow
+   * {@link #MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+   * {@link BreakIterator} using the designated {@link Locale}.
+   * <p>
+   * The text to print may contain <code>\n</code> characters. This method will
+   * force a line-break for each such character.
+   * 
+   * @param out the {@link PrintStream} destination of the formatted text.
+   * @param text the text to print.
+   * @param aLocale the {@link Locale} instance to use when constructing the
+   *          {@link BreakIterator}.
+   * @see Parser#MAX_LINE_LENGTH
+   */
+  protected static void formatText(PrintStream out, String text, Locale aLocale)
+  {
+    BreakIterator bit = BreakIterator.getLineInstance(aLocale);
+    String[] lines = text.split("\n"); //$NON-NLS-1$
+    for (int i = 0; i < lines.length; i++)
+      {
+        text = lines[i];
+        bit.setText(text);
+        int length = 0;
+        int finish;
+        int start = bit.first();
+        while ((finish = bit.next()) != BreakIterator.DONE)
+          {
+            String word = text.substring(start, finish);
+            length += word.length();
+            if (length >= MAX_LINE_LENGTH)
+              {
+                out.println();
+                length = word.length();
+              }
+            out.print(word);
+            start = finish;
+          }
+        out.println();
+      }
+  }
+
+  /**
+   * Create a new parser. The program name is used when printing error messages.
+   * The version string is printed verbatim in response to "--version".
+   * 
+   * @param programName the name of the program
+   * @param versionString the program's version information
+   * @param longOnly true if the parser should work in long-option-only mode
+   */
+  public Parser(String programName, final String versionString, boolean longOnly)
+  {
+    this.programName = programName;
+    this.longOnly = longOnly;
+
+    // Put standard options in their own section near the end.
+    OptionGroup 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);
+      }
+    });
+    finalGroup.add(new Option('J', Messages.getString("Parser.JArgument"), Messages.getString("Parser.JName")) //$NON-NLS-1$ //$NON-NLS-2$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        // -J should be handled by the appletviewer wrapper binary.
+        // We add it here so that it shows up in the --help output.
+        // Note that there is a special case for this in OptionGroup.
+      }
+    });
+    add(finalGroup);
+
+    add(defaultGroup);
+  }
+
+  /**
+   * Set the header text that is printed by --help.
+   * 
+   * @param headerText the header text
+   */
+  public void setHeader(String headerText)
+  {
+    this.headerText = headerText;
+  }
+
+  /**
+   * Set the footer text that is printed by --help.
+   * 
+   * @param footerText the footer text
+   */
+  public 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)
+  {
+    options.add(opt);
+    defaultGroup.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)
+  {
+    options.addAll(group.options);
+    // 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);
+  }
+
+  public void printHelp()
+  {
+    this.printHelp(System.out);
+  }
+
+  void printHelp(PrintStream out)
+  {
+    if (headerText != null)
+      {
+        formatText(out, headerText);
+        out.println();
+      }
+
+    Iterator it = optionGroups.iterator();
+    while (it.hasNext())
+      {
+        OptionGroup group = (OptionGroup) it.next();
+        // An option group might be empty, in which case we don't
+        // want to print it..
+        if (! group.options.isEmpty())
+          {
+            group.printHelp(out, longOnly);
+            out.println();
+          }
+      }
+
+    if (footerText != null)
+      formatText(out, footerText);
+  }
+
+  /**
+   * This method can be overridden by subclassses to provide some option
+   * validation.  It is called by the parser after all options have been
+   * parsed.  If an option validation problem is encountered, this should
+   * throw an {@link OptionException} whose message should be shown to
+   * the user.
+   * <p>
+   * It is better to do validation here than after {@link #parse(String[])}
+   * returns, because the parser will print a message referring the
+   * user to the <code>--help</code> option.
+   * <p>
+   * The base implementation does nothing.
+   * 
+   * @throws OptionException the error encountered
+   */
+  protected void validate() throws OptionException
+  {
+    // Base implementation does nothing.
+  }
+
+  private String getArgument(String request) throws OptionException
+  {
+    ++currentIndex;
+    if (currentIndex >= args.length)
+      {
+        String message
+          = MessageFormat.format(Messages.getString("Parser.ArgReqd"), //$NON-NLS-1$
+                                 new Object[] { request });
+        throw new OptionException(request);
+      }
+    return args[currentIndex];
+  }
+
+  private void handleLongOption(String real, int index) throws OptionException
+  {
+    String option = real.substring(index);
+    String justName = option;
+    int eq = option.indexOf('=');
+    if (eq != - 1)
+      justName = option.substring(0, eq);
+    char shortName = 0;
+    if (justName.length() == 1)
+      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 (shortName != 0 && opt.getShortName() == shortName)
+          {
+            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 handleShortOption(char option) throws OptionException
+  {
+    Option found = null;
+    for (int i = options.size() - 1; i >= 0; --i)
+      {
+        Option opt = (Option) options.get(i);
+        if (option == opt.getShortName())
+          {
+            found = opt;
+            break;
+          }
+      }
+    if (found == null)
+      {
+        String msg = MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
+                                          new Object[] { "" + option }); //$NON-NLS-1$
+        throw new OptionException(msg);
+      }
+    String argument = null;
+    if (found.getTakesArgument())
+      argument = getArgument("-" + option); //$NON-NLS-1$
+    found.parsed(argument);
+  }
+
+  private void handleShortOptions(String option) throws OptionException
+  {
+    for (int i = 1; i < option.length(); ++i)
+      {
+        handleShortOption(option.charAt(i));
+      }
+  }
+
+  /**
+   * 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)
+  {
+    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]);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,189 @@
+/* GRMIC.java -- GIOP support for RMIC.
+   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.
+*/
+
+package gnu.classpath.tools.giop;
+
+import gnu.classpath.tools.HelpPrinter;
+import gnu.classpath.tools.giop.grmic.GiopRmicCompiler;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * The main class of the GIOP compiler to generate stubs and ties for 
+ * javax.rmi package.
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)  
+ */
+public class GRMIC
+{
+  /**
+   * The version of the compiler.
+   */
+  public static String VERSION = "0.0 alpha pre";
+  
+  /**
+   * The GRMIC compiler methods
+   * 
+   * @param args the compiler parameters.
+   */
+  public static void main(String[] args)
+  {
+    boolean noWrite = false;
+    boolean verbose = false;
+
+    String HelpPath = "giop/GRMIC.txt";
+
+    HelpPrinter.checkHelpKey(args, HelpPath);
+
+    File output = new File(".");
+
+    if (args.length == 0)
+      {
+        HelpPrinter.printHelpAndExit(HelpPath);
+      }
+    else
+      {
+        GiopRmicCompiler compiler = new GiopRmicCompiler();
+
+        int cl = - 1;
+
+        Options: for (int i = 0; i < args.length; i++)
+          {
+            String c = args[i];
+            if (c.equals("-poa"))
+              compiler.setPoaMode(true);
+            else if (c.equals("-impl"))
+              compiler.setPoaMode(false);
+            else if (c.equals("-v"))
+              {
+                printVersion();
+                System.exit(0);
+              }
+            else if (c.equals("-nowrite"))
+              noWrite = true;
+            else if (c.equals("-nowarn"))
+              compiler.setWarnings(false);
+            else if (c.equals("-verbose"))
+              {
+                verbose = true;
+                compiler.setVerbose(true);
+              }
+            else if (c.equals("-force"))
+              {
+                compiler.setForce(true);
+              }
+            else if (c.equals("-d"))
+              {
+                int f = i + 1;
+                if (f < args.length)
+                  {
+                    output = new File(args[f]);
+                    i++;
+                  }
+                else
+                  HelpPrinter.printHelpAndExit(HelpPath);
+              }
+            else if (c.equals("-classpath"))
+              {
+                int f = i + 1;
+                if (f < args.length)
+                  {
+                    compiler.setClassPath(args[f]);
+                    i++;
+                  }
+                else
+                  HelpPrinter.printHelpAndExit(HelpPath);
+              }
+            else if (c.charAt(0) != '-')
+            // No more options - start of class list.
+              {
+                cl = i;
+                break Options;
+              }
+          }
+
+        if (cl < 0)
+          HelpPrinter.printHelpAndExit(HelpPath);
+
+        if (verbose)
+          System.out.println("Compiling to " + output.getAbsolutePath());
+
+        // Compile classes
+        Compile: for (int i = cl; i < args.length; i++)
+          {
+            if (args[i].charAt(0) != '-')
+              {
+                compiler.reset();
+                Class c = compiler.loadClass(args[i]);
+
+                compiler.compile(c);
+                String packag = compiler.getPackageName().replace('.', '/');
+                File fw = new File(output, packag);
+
+                // Generate stub.
+                String stub = compiler.generateStub();
+                String subName = "_" + compiler.getStubName() + "_Stub.java";
+
+                compiler.reset();
+                compiler.compile(c);
+
+                // Generate tie
+                String tie = compiler.generateTie();
+                String tieName = "_" + compiler.name(c) + "_Tie.java";
+
+                if (noWrite)
+                  continue Compile;
+
+                try
+                  {
+                    fw.mkdirs();
+                    OutputStream out = new FileOutputStream(new File(fw,
+                                                                     subName));
+                    out.write(stub.getBytes());
+                    out.close();
+
+                    out = new FileOutputStream(new File(fw, tieName));
+                    out.write(tie.getBytes());
+                    out.close();
+                  }
+                catch (IOException ioex)
+                  {
+                    System.err.println("Output path not accessible");
+                    ioex.printStackTrace();
+                    System.exit(1);
+                  }
+              }
+          }
+      }
+  }
+  
+  /**
+   * Print the version information.
+   */
+  public static void printVersion()
+  {
+    System.out.println
+      ("grmic v "+VERSION+" - GIOP stub and tie generator for javax.rmi.* ");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.txt?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.txt (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.txt Thu Nov  8 16:56:19 2007
@@ -0,0 +1,33 @@
+GIOP stub and tie generator source code generator for javax.rmi.*, omg.org.*
+
+Copyright 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+
+Usage: grmic <options> <class names>
+
+ where <options> includes:
+  -poa              Generate the Servant based ties (default)
+  -impl             Generate the obsoleted ObjectImpl based ties
+                      (for backward compatibility)
+  -nowarn            Show no warnings
+  -nowrite           Do not write any files (check for errors only)
+  -d <folder>        Place generated files into the given folder
+  -classpath <path>  Specifies the path, where to find the classes being 
+                     compiled  
+  
+  -help              Print this help text
+  -v                 Print version
+  -verbose           Verbose output
+  -force             Try to generate code even if the input classes seem not
+                     consistent with RMI specification. 
+  
+  
+ and <class names> can include one or more non abstract classes that implement
+ Remote and are accessible via current class path.
+
+* This tool generates the source code that must be compiled with java compiler. 
+* GRMIC is invoked from RMIC if the -iiop or -giop keys are specified.
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/IorParser.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/IorParser.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/IorParser.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/IorParser.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,109 @@
+/* IorParser.java -- IOR parser.
+   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.
+*/
+
+
+package gnu.classpath.tools.giop;
+
+import gnu.CORBA.IOR;
+import gnu.classpath.tools.HelpPrinter;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.omg.CORBA.BAD_PARAM;
+
+/**
+ * Parses the information, encoded in the Interoperable Object References
+ * (IORs).
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)  
+ */
+public class IorParser
+{
+  /**
+   * Parse and print IOR reference. The system exit code is 0 if the parsed
+   * IOR was correct, 1 if it was invalid or missing.
+   * 
+   * @param args supports -f file to read IOR from the file.
+   */
+  public static void main(String[] args)
+  {
+    boolean ok = false;
+    String HelpResource = "giop/IorParser.txt";
+    HelpPrinter.checkHelpKey(args, HelpResource);
+    if (args.length == 0)
+      HelpPrinter.printHelpAndExit(HelpResource);
+    else if (args[0].equals("-f") && args.length==2)
+      {        
+        File file = new File(args[1]);
+        if (!file.exists())
+          System.err.println("The file "+file.getAbsolutePath()+" is missing.");
+        // Read IOR reference from file.
+        String ior = null;        
+    try
+      {
+        FileReader fr = new FileReader(file);
+        BufferedReader br = new BufferedReader(fr);
+        ior = br.readLine();
+        br.close();
+        ok = parseAndPrint(ior);
+      }
+    catch (IOException e)
+      {
+        System.err.print("Unable to read the file "+file);
+        e.printStackTrace();
+      }
+        
+      }
+    else if (args.length == 1)
+      ok = parseAndPrint(args[0]);
+    else
+      HelpPrinter.printHelpAndExit(HelpResource);
+    
+    if (ok)
+      System.exit(0);
+    else
+      System.exit(1);
+  }
+  
+  /**
+   * Parse and print IOR.
+   * 
+   * @param ior the IOR string to anlyse.
+   * @return true if the passed value is a valid IOR, false otherwise.
+   */
+  public static boolean parseAndPrint(String ior)
+  {
+    try
+      {
+        IOR gior = IOR.parse(ior);
+        System.out.println(gior.toStringFormatted());
+        return true;
+      }
+    catch (BAD_PARAM e)
+      {
+        System.out.println("Invalid ior: "+e.getMessage());
+        return false;
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/IorParser.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/IorParser.txt?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/IorParser.txt (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/IorParser.txt Thu Nov  8 16:56:19 2007
@@ -0,0 +1,10 @@
+Copyright 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+
+IOR (interoperable GIOP object reference) parser,
+  usage: IorParser -f ior_file
+     or: IorParser -f ior_string
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameService.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameService.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameService.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameService.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* NameService.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.giop;
+
+import gnu.CORBA.NamingService.NamingServiceTransient;
+import gnu.classpath.tools.HelpPrinter;
+
+/**
+ * The implementation of the transient naming service. The naming service
+ * is a kind of the network server that registers local and remote objects
+ * by name, and later can provide the object reference in response to the
+ * given name.
+ * 
+ * GNU Classpath currently works with this naming service and is also
+ * interoperable with the Sun Microsystems naming services from releases 1.3 and
+ * 1.4, both transient <i>tnameserv</i> and persistent <i>orbd</i>.
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org)  
+ */
+public class NameService
+{
+  /**
+   * Start the naming service on the current host at the given port. The
+   * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
+   * present, specifies the port, on that the service must be started. If this
+   * key is not specified, the service starts at the port 900.
+   * 
+   * The parameter -ior FILE_NAME, if present, forces to store the ior string of
+   * this naming service to the specified file.
+   * 
+   * @param args the parameter string.
+   */
+  public static void main(String[] args)
+  {
+    HelpPrinter.checkHelpKey(args, "giop/NamingService.txt");
+    System.out.println("Please use --help for options.");    
+    NamingServiceTransient.main(args);
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameServicePersistent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameServicePersistent.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameServicePersistent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameServicePersistent.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,186 @@
+/* NamingServicePersistent.java -- The persistent 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.giop;
+
+import gnu.CORBA.OrbFunctional;
+import gnu.CORBA.IOR;
+import gnu.CORBA.NamingService.Ext;
+import gnu.classpath.tools.HelpPrinter;
+import gnu.classpath.tools.giop.nameservice.PersistentContext;
+
+import org.omg.CosNaming.NamingContextExt;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * The server for the gnu classpath persistent naming service. 
+ * 
+ * GNU Classpath currently works with this naming service and is also
+ * interoperable with the Sun Microsystems naming services from releases 1.3 and
+ * 1.4, both transient <i>tnameserv</i> and persistent <i>orbd</i>.
+ * 
+ * @author Audrius Meskauskas, Lithuania (AudriusA at Bioinformatics.org)
+ */
+public class NameServicePersistent
+{
+  /**
+   * 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;
+
+  /**
+   * 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");
+      }
+  }
+
+  /**
+   * Start the naming service on the current host at the given port. The
+   * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
+   * present, specifies the port, on that the service must be started. If this
+   * key is not specified, the service starts at the port 900. The parameter
+   * -ior FILE_NAME, if present, forces to store the ior string of this naming
+   * service to the specified file.
+   * 
+   * @param args the parameter string.
+   */
+  public static void main(String[] args)
+  {
+    HelpPrinter.checkHelpKey(args, "giop/NameServicePersistent.txt");
+    System.out.println("Please use --help for options.");
+
+    int port = PORT;
+    String iorf = null;
+    boolean reset = false;
+    String folder = "";
+    try
+      {
+        // Create and initialize the ORB
+        final OrbFunctional orb = new OrbFunctional();
+
+        for (int i = 0; i < args.length; i++)
+          {
+            if (i < args.length - 1)
+              {
+                if (args[i].endsWith("ORBInitialPort"))
+                  port = Integer.parseInt(args[i + 1]);
+
+                if (args[i].equals("-ior"))
+                  iorf = args[i + 1];
+
+                if (args[i].equals("-folder"))
+                  folder = args[i + 1];
+              }
+            if (args[i].equals("-reset"))
+              reset = true;
+          }
+
+        OrbFunctional.setPort(port);
+
+        // Create the servant and register it with the ORB
+        File dataFolder = new File(folder);
+        System.out.println("Persistent data stored at "
+                           + dataFolder.getAbsolutePath());
+        dataFolder.mkdirs();
+
+        // / TODO support more starting modes.
+        NamingContextExt namer = new Ext(
+                                         new PersistentContext(
+                                                               orb,
+                                                               dataFolder,
+                                                               reset));
+
+        // 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) 2006 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 (Exception e)
+      {
+        System.err.println("ERROR: " + e);
+        e.printStackTrace(System.out);
+      }
+
+    // Restore the default value for allocating ports for the subsequent
+    // objects.
+    OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameServicePersistent.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameServicePersistent.txt?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameServicePersistent.txt (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NameServicePersistent.txt Thu Nov  8 16:56:19 2007
@@ -0,0 +1,28 @@
+Copyright 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+
+GNU Classpath GIOP persitent naming service.
+  usage: NameServicePersistent <options>
+
+ where <options> includes:
+* -org.omg.CORBA.ORBInitialPort NNN
+ or -ORBInitialPort NNN          - specifies the port, on that the 
+                                   service must be started. If this key
+                                   is not specified, the service starts
+                                   at the port 900.
+   
+* -ior FILE_NAME                - store the IOR reference to this naming 
+                                  service to the specified file. The
+                                  IOR reference contains enough 
+                                  information to locate the service
+                                  on the web.
+* - folder FOLDER               - store the persistent information
+                                  to the given folder
+* - reset                       - discard any previously stored
+                                  persistent information (cold start)                                          
+
+
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NamingService.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NamingService.txt?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NamingService.txt (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/NamingService.txt Thu Nov  8 16:56:19 2007
@@ -0,0 +1,21 @@
+Copyright 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+
+GNU Classpath GIOP naming service, usage: NameService <options>
+
+ where <options> includes:
+* -org.omg.CORBA.ORBInitialPort NNN or
+* -ORBInitialPort NNN                   - specifies the port, on that the 
+                                          service must be started. If this key
+                                          is not specified, the service starts
+                                          at the port 900.
+   
+* -ior FILE_NAME                        - store the IOR reference to this naming 
+                                          service to the specified file. The
+                                          IOR reference contains enough 
+                                          information to locate the service
+                                          on the web.
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/README
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/README?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/README (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/README Thu Nov  8 16:56:19 2007
@@ -0,0 +1,19 @@
+This package defines GIOP tools for creating the applications that use this
+protocol. It provides necessary support for org.omg.* and javax.rmi.* 
+packages.
+
+All GIOP tools support the --help option.
+
+The list of the currently available tools:
+
+* 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).
+* RMIC -                 RMI stub and tie source code generator (complements
+                         the ASM based bytecode generator in the separate
+                         tools package).
\ No newline at end of file

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/CompilationError.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/CompilationError.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/CompilationError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/CompilationError.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,52 @@
+/* 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.
+*/
+
+package gnu.classpath.tools.giop.grmic;
+
+/**
+ * This error is thrown when the target being compiled has illegal
+ * strutures.
+ * 
+ * @author Audrius Meskauskas, Lithuania (audriusa at 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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/Generator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/Generator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/Generator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/Generator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,128 @@
+/* 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.
+*/
+
+package gnu.classpath.tools.giop.grmic;
+
+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 at 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));
+    StringBuffer b = new StringBuffer();
+
+    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;
+    StringBuffer b = new StringBuffer(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();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopIo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopIo.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopIo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopIo.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,112 @@
+/* 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.
+*/
+
+package gnu.classpath.tools.giop.grmic;
+
+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 at 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, GiopRmicCompiler 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, GiopRmicCompiler 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);";
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,593 @@
+/* GiopRmicCompiler -- Central GIOP-based RMI stub and tie compiler class.
+   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.
+*/
+
+package gnu.classpath.tools.giop.grmic;
+
+import gnu.classpath.tools.AbstractMethodGenerator;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+/**
+ * Provides the extended rmic functionality to generate the POA - based classes
+ * for GIOP (javax.rmi.CORBA package).
+ * 
+ * @author Audrius Meskauskas, Lithuania (audriusa at Bioinformatics.org)
+ */
+public class GiopRmicCompiler
+    extends Generator implements Comparator
+{
+  /** The package name. */
+  protected String packag;
+
+  /**
+   * The "basic" name (normally, the interface name, unless several Remote -
+   * derived interfaces are implemented.
+   */
+  protected String name;
+
+  /**
+   * The name (without package) of the class, passed as the parameter.
+   */
+  protected String implName;
+
+  /**
+   * The proposed name for the stub.
+   */
+  protected String stubName;
+
+  /**
+   * The Remote's, implemented by this class.
+   */
+  protected Collection implementedRemotes = new HashSet();
+
+  /**
+   * The extra classes that must be imported.
+   */
+  protected Collection extraImports = new HashSet();
+
+  /**
+   * The methods we must implement.
+   */
+  protected Collection methods = new HashSet();
+
+  /**
+   * The map of all code generator variables.
+   */
+  public Properties vars = new Properties();
+
+  /**
+   * If this flag is set (true by default), the compiler generates the Servant
+   * based classes. If set to false, the compiler generates the old style
+   * ObjectImpl based classes.
+   */
+  protected boolean poaMode = true;
+
+  /**
+   * If this flag is set (true by default), the compiler emits warnings.
+   */
+  protected boolean warnings = true;
+
+  /**
+   * Verbose output
+   */
+  protected boolean verbose = false;
+  
+  /**
+   * Force mode - do not check the exceptions
+   */
+  protected boolean force = false;
+  
+  /**
+   * The class loader to load the class being compiled.
+   */
+  ClassLoader classLoader;
+
+  /**
+   * Clear data, preparing for the next compilation.
+   */
+  public void reset()
+  {
+    packag = name = implName = stubName = null;
+    implementedRemotes.clear();
+    extraImports.clear();
+    methods.clear();
+    vars.clear();
+  }
+  
+  /**
+   * Set the class path (handle the -classpath key)
+   * 
+   * @param classPath the class path to set.
+   */
+  public void setClassPath(String classPath)
+  {
+    classLoader = Thread.currentThread().getContextClassLoader();
+    StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator,
+                                              true);
+    ArrayList urls = new ArrayList(tok.countTokens());
+    String s = null;
+    try
+      {
+        while (tok.hasMoreTokens())
+          {
+            s = tok.nextToken();
+            if (s.equals(File.pathSeparator))
+              urls.add(new File(".").toURL());
+            else
+              {
+                urls.add(new File(s).toURL());
+                if (tok.hasMoreTokens())
+                  {
+                    // Skip the separator.
+                    tok.nextToken();
+                    // If the classpath ended with a separator,
+                    // append the current directory.
+                    if (! tok.hasMoreTokens())
+                      urls.add(new File(".").toURL());
+                  }
+              }
+          }
+      }
+    catch (MalformedURLException ex)
+      {
+        System.err.println("Malformed path '" + s + "' in classpath '"
+                           + classPath + "'");
+        System.exit(1);
+      }
+    URL[] u = new URL[urls.size()];
+    for (int i = 0; i < u.length; i++)
+      {
+        u[i] = (URL) urls.get(i);
+      }
+
+    classLoader = new URLClassLoader(u, classLoader);
+  }    
+  
+  /**
+   * Loads the class with the given name (uses class path, if applicable)
+   * 
+   * @param name the name of the class.
+   */
+  public Class loadClass(String name)
+  {
+    ClassLoader loader = classLoader;
+    if (loader == null)
+      loader = Thread.currentThread().getContextClassLoader();
+    try
+      {
+        return loader.loadClass(name);
+      }
+    catch (ClassNotFoundException e)
+      {
+        System.err.println(name+" not found on "+loader);
+        System.exit(1);
+        // Unreacheable code.
+        return null;
+      }
+  }
+
+  /**
+   * Compile the given class (the instance of Remote), generating the stub and
+   * tie for it.
+   * 
+   * @param remote
+   *          the class to compile.
+   */
+  public synchronized void compile(Class remote)
+  {
+    reset();
+    String s;
+
+    // Get the package.
+    s = remote.getName();
+    int p = s.lastIndexOf('.');
+    if (p < 0)
+      {
+        // Root package.
+        packag = "";
+        implName = name = s;
+      }
+    else
+      {
+        packag = s.substring(0, p);
+        implName = name = s.substring(p + 1);
+      }
+     
+    name = convertStubName(name);
+
+    stubName = name;
+
+    vars.put("#name", name);
+    vars.put("#package", packag);
+    vars.put("#implName", implName);
+
+    if (verbose)
+      System.out.println("Package " + packag + ", name " + name + " impl "
+                         + implName);
+
+    // Get the implemented remotes.
+    Class[] interfaces = remote.getInterfaces();
+
+    for (int i = 0; i < interfaces.length; i++)
+      {
+        if (Remote.class.isAssignableFrom(interfaces[i]))
+          {
+            if (! interfaces[i].equals(Remote.class))
+              {
+                implementedRemotes.add(interfaces[i]);
+              }
+          }
+      }
+
+    vars.put("#idList", getIdList(implementedRemotes));
+
+    // Collect and process methods.
+    Iterator iter = implementedRemotes.iterator();
+
+    while (iter.hasNext())
+      {
+        Class c = (Class) iter.next();
+        Method[] m = c.getMethods();
+
+        // Check if throws RemoteException.
+        for (int i = 0; i < m.length; i++)
+          {
+            Class[] exc = m[i].getExceptionTypes();
+            boolean remEx = false;
+
+            for (int j = 0; j < exc.length; j++)
+              {
+                if (RemoteException.class.isAssignableFrom(exc[j]))
+                  {
+                    remEx = true;
+                    break;
+                  }
+	      }
+	    if (! remEx && !force)
+	      throw new CompilationError(m[i].getName() + ", defined in "
+					 + c.getName()
+					 + ", does not throw "
+					 + RemoteException.class.getName());
+            AbstractMethodGenerator mm = createMethodGenerator(m[i]);
+            methods.add(mm);
+          }
+      }
+  }
+
+  /**
+   * Create the method generator for the given method.
+   * 
+   * @param m the method
+   * 
+   * @return the created method generator
+   */
+  protected AbstractMethodGenerator createMethodGenerator(Method m)
+  {
+    return new MethodGenerator(m, this);
+  }
+
+  /**
+   * Get the name of the given class. The class is added to imports, if not
+   * already present and not from java.lang and not from the current package.
+   * 
+   * @param nameIt
+   *          the class to name
+   * @return the name of class as it should appear in java language
+   */
+  public String name(Class nameIt)
+  {
+    if (nameIt.isArray())
+      {
+        // Mesure dimensions:
+        int dimension = 0;
+        Class finalComponent = nameIt;
+        while (finalComponent.isArray())
+          {
+            finalComponent = finalComponent.getComponentType();
+            dimension++;
+          }
+
+        StringBuffer brackets = new StringBuffer();
+
+        for (int i = 0; i < dimension; i++)
+          {
+            brackets.append("[]");
+          }
+
+        return name(finalComponent) + " " + brackets;
+      }
+    else
+      {
+        String n = nameIt.getName();
+        if (! nameIt.isArray() && ! nameIt.isPrimitive())
+          if (! n.startsWith("java.lang")
+              && ! (packag != null && n.startsWith(packag)))
+            extraImports.add(n);
+
+        int p = n.lastIndexOf('.');
+        if (p < 0)
+          return n;
+        else
+          return n.substring(p + 1);
+      }
+  }
+
+  /**
+   * Get the RMI-style repository Id for the given class.
+   * 
+   * @param c
+   *          the interface, for that the repository Id must be created.
+   * @return the repository id
+   */
+  public String getId(Class c)
+  {
+    return "RMI:" + c.getName() + ":0000000000000000";
+  }
+
+  /**
+   * Get repository Id string array declaration.
+   * 
+   * @param remotes
+   *          the collection of interfaces
+   * @return the fully formatted string array.
+   */
+  public String getIdList(Collection remotes)
+  {
+    StringBuffer b = new StringBuffer();
+
+    // Keep the Ids sorted, ensuring, that the same order will be preserved
+    // between compilations.
+    TreeSet sortedIds = new TreeSet();
+
+    Iterator iter = remotes.iterator();
+    while (iter.hasNext())
+      {
+        sortedIds.add(getId((Class) iter.next()));
+      }
+
+    iter = sortedIds.iterator();
+    while (iter.hasNext())
+      {
+        b.append("      \"" + iter.next() + "\"");
+        if (iter.hasNext())
+          b.append(", \n");
+      }
+    return b.toString();
+  }
+
+  /**
+   * Generate stub. Can only be called from {@link #compile}.
+   * 
+   * @return the string, containing the text of the generated stub.
+   */
+  public String generateStub()
+  {
+    String template = getResource("Stub.jav");
+
+    // Generate methods.
+    StringBuffer b = new StringBuffer();
+    Iterator iter = methods.iterator();
+    while (iter.hasNext())
+      {
+        AbstractMethodGenerator m = (AbstractMethodGenerator) iter.next();
+        b.append(m.generateStubMethod());
+      }
+
+    vars.put("#stub_methods", b.toString());
+    vars.put("#imports", getImportStatements());
+    vars.put("#interfaces", getAllInterfaces());
+
+    String output = replaceAll(template, vars);
+    return output;
+  }
+
+  /**
+   * Get the list of all interfaces, implemented by the class, that are
+   * derived from Remote.
+   * 
+   * @return the string - all interfaces.
+   */
+  public String getAllInterfaces()
+  {
+    StringBuffer b = new StringBuffer();
+    Iterator iter = implementedRemotes.iterator();
+
+    while (iter.hasNext())
+      {
+        b.append(name((Class) iter.next()));
+        if (iter.hasNext())
+          b.append(", ");
+      }
+
+    return b.toString();
+  }
+
+  /**
+   * Generate Tie. Can only be called from {@link #compile}.
+   * 
+   * @return the string, containing the text of the generated Tie.
+   */
+  public String generateTie()
+  {
+    String template;
+    if (poaMode)
+      template = getResource("Tie.jav");
+    else
+      template = getResource("ImplTie.jav");
+
+    // Generate methods.
+    HashFinder hashFinder = new HashFinder();
+
+    // Find the hash character position:
+    Iterator iter = methods.iterator();
+    String[] names = new String[methods.size()];
+    int p = 0;
+
+    for (int i = 0; i < names.length; i++)
+      names[i] = ((MethodGenerator) iter.next()).getGiopMethodName();
+
+    int hashCharPosition = hashFinder.findHashCharPosition(names);
+
+    iter = methods.iterator();
+    while (iter.hasNext())
+      ((MethodGenerator) iter.next()).hashCharPosition = hashCharPosition;
+
+    vars.put("#hashCharPos", Integer.toString(hashCharPosition));
+
+    ArrayList sortedMethods = new ArrayList(methods);
+    Collections.sort(sortedMethods, this);
+
+    iter = sortedMethods.iterator();
+
+    StringBuffer b = new StringBuffer();
+
+    MethodGenerator prev = null;
+
+    while (iter.hasNext())
+      {
+        MethodGenerator m = (MethodGenerator) iter.next();
+        m.previous = prev;
+        m.hashCharPosition = hashCharPosition;
+        prev = m;
+        b.append(m.generateTieMethod());
+      }
+
+    vars.put("#tie_methods", b.toString());
+
+    vars.put("#imports", getImportStatements());
+
+    String output = replaceAll(template, vars);
+    return output;
+  }
+
+  public int compare(Object a, Object b)
+  {
+    MethodGenerator g1 = (MethodGenerator) a;
+    MethodGenerator g2 = (MethodGenerator) b;
+
+    return g1.getHashChar() - g2.getHashChar();
+  }
+
+  /**
+   * Import the extra classes, used as the method parameters and return values.
+   * 
+   * @return the additional import block.
+   */
+  protected String getImportStatements()
+  {
+    TreeSet imp = new TreeSet();
+
+    Iterator it = extraImports.iterator();
+    while (it.hasNext())
+      {
+        String ic = it.next().toString();
+        imp.add("import " + ic + ";\n");
+      }
+
+    StringBuffer b = new StringBuffer();
+    it = imp.iterator();
+
+    while (it.hasNext())
+      {
+        b.append(it.next());
+      }
+    return b.toString();
+  }
+
+  /**
+   * If this flag is set (true by default), the compiler generates the Servant
+   * based classes. If set to false, the compiler generates the old style
+   * ObjectImpl based classes.
+   */
+  public void setPoaMode(boolean mode)
+  {
+    poaMode = mode;
+  }
+
+  /**
+   * Set the verbose output mode (false by default)
+   * 
+   * @param isVerbose the verbose output mode
+   */
+  public void setVerbose(boolean isVerbose)
+  {
+    verbose = isVerbose;
+  }
+
+  /**
+   * If this flag is set (true by default), the compiler emits warnings.
+   */
+  public void setWarnings(boolean warn)
+  {
+    warnings = warn;
+  }
+  
+  /**
+   * Set the error ignore mode.
+   */
+  public void setForce(boolean isforce)
+  {
+    force = isforce;
+  }
+
+  /**
+   * Get the package name.
+   */
+  public String getPackageName()
+  {
+    return packag;
+  }
+
+  /**
+   * Get the proposed stub name
+   */
+  public String getStubName()
+  {
+    return stubName;
+  }
+  
+  /**
+   * Additional processing of the stub name.
+   */
+  public String convertStubName(String name)
+  {
+    // Drop the Impl suffix, if one exists.
+    if (name.endsWith("Impl"))
+      return name.substring(0, name.length() - "Impl".length());
+    else
+      return name;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/HashFinder.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/HashFinder.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/HashFinder.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/HashFinder.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* 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.
+*/
+
+
+package gnu.classpath.tools.giop.grmic;
+
+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 at 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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,285 @@
+/* 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.
+*/
+
+package gnu.classpath.tools.giop.grmic;
+
+import gnu.classpath.tools.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 at Bioinformatics.org)
+ */
+public class MethodGenerator implements AbstractMethodGenerator
+{
+  /**
+   * The method being defined.
+   */
+  Method method;
+
+  /**
+   * The parent code generator.
+   */
+  GiopRmicCompiler 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, GiopRmicCompiler 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()
+  {
+    StringBuffer b = new StringBuffer();
+
+    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()
+  {
+    StringBuffer b = new StringBuffer();
+
+    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()
+  {
+    StringBuffer b = new StringBuffer();
+
+    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()
+  {
+    StringBuffer b = new StringBuffer();
+    Class[] args = method.getParameterTypes();
+
+    for (int i = 0; i < args.length; i++)
+      {
+        b.append("                ");
+        b.append(rmic.name(args[i]));
+        b.append(" ");
+        b.append("p"+i);
+        b.append(" = ");
+        b.append(GiopIo.getReadStatement(args[i], rmic));
+        if (i<args.length-1)
+          b.append("\n");
+      }
+    return b.toString();
+  }
+
+  /**
+   * Get the write statement for writing parameters inside the stub.
+   * 
+   * @return the write statement.
+   */
+  public String getStubParaWriteStatement()
+  {
+    StringBuffer b = new StringBuffer();
+    Class[] args = method.getParameterTypes();
+
+    for (int i = 0; i < args.length; i++)
+      {
+        b.append("             ");
+        b.append(GiopIo.getWriteStatement(args[i], "p" + i, rmic));
+        b.append("\n");
+      }
+    return b.toString();
+  }
+  
+  /**
+   * Get the hash char.
+   */
+  public char getHashChar()
+  {
+    return getGiopMethodName().charAt(hashCharPosition);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/ImplTie.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/ImplTie.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/ImplTie.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/ImplTie.jav Thu Nov  8 16:56:19 2007
@@ -0,0 +1,152 @@
+package #package;
+
+#imports
+import java.rmi.Remote;
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+
+import org.omg.CORBA_2_3.portable.ObjectImpl;
+import org.omg.CORBA_2_3.portable.InputStream;
+
+// This Tie type is obsolete. Use the POA - based tie (key -poa).
+
+/**
+ * This class accepts remote calls to the served GIOP object and delegates them
+ * to the enclosed implementing class. Being derived from the ObjectImpl,
+ * it directly implements the GIOP Object.
+ *
+ * It is normally generated with grmic -impl
+ */
+public class _#nameImpl_Tie extends ObjectImpl implements Tie
+{
+  /**
+   * All decoded remote calls are forwarded to this target.
+   */
+  #implName target;
+  
+  /**
+   * The array of repository ids, supported by this GIOP Object
+   */ 
+  private static final String[] type_ids =
+    { 
+#idList
+    };
+      
+  /**
+   * Get an array of all interfaces (repository ids),
+   * supported by this Object.
+   *
+   * @return the array of Ids.
+   */
+  public String[] _ids() 
+  { 
+    return type_ids;
+  }  
+
+  /**
+   * Set the invocation target, where all received calls are finally
+   * forwarded.
+   *
+   * @param a_target the forwarding target
+   *
+   * @throws ClassCastException if the target is not an instance of
+   * #implName
+   */ 
+  public void setTarget(Remote a_target)
+  {
+    this.target = (#implName) a_target;
+  }
+
+  /**
+   * Get the invocation target, where all received calls are finally
+   * forwarded.
+   *
+   * @return the target, an instance of
+   * #implName
+   */ 
+  public Remote getTarget()
+  {
+    return target;
+  }
+  
+  /**
+   * Return the actual GIOP object that would handle this request.
+   * 
+   * @return <code>this</code>, always.
+   */
+  public org.omg.CORBA.Object thisObject()
+  {
+    return this;
+  }
+  
+  /**
+   * Deactivates this object, disconnecting it from the orb.
+   */
+  public void deactivate()
+  {
+     _orb().disconnect(this);
+     _set_delegate(null);
+     target = null;
+  }
+
+  /**
+   * Get the {@link ORB} where this {@link Servant} is connected.
+   * 
+   * @return the ORB
+   */
+  public ORB orb()
+  {
+    return _orb();
+  }
+
+  /**
+   * Connect this servant to the given ORB. 
+   */
+  public void orb(ORB orb)
+  {
+    orb.connect(this);
+  }
+
+/**
+ * This method is invoked by ORB in response to the remote call. It redirects
+ * the call to one of the methods in the target.
+ * 
+ * @param method the name of the method to call.
+ * @param parameter_stream the input stream, from where the parameters must be
+ * read. 
+ * @param reply the response hander, providing methods to return the result.
+ * 
+ * @return the output stream, created by the response handler
+ * 
+ * @throws SystemException if one occurs during method invocation.
+ */  
+  public OutputStream _invoke(String method, 
+    org.omg.CORBA.portable.InputStream parameter_stream,
+    ResponseHandler reply)
+  {
+    try
+      {
+        InputStream in =(InputStream) parameter_stream;
+          
+#tie_methods          
+          
+       throw new BAD_OPERATION("No such method: '"+method+"'");
+      }
+    catch (SystemException ex)
+      {
+        throw ex;
+      }
+    catch (Throwable ex)
+      {
+        throw new UnknownException(ex);
+      }
+  }
+}
\ No newline at end of file

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav Thu Nov  8 16:56:19 2007
@@ -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

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav Thu Nov  8 16:56:19 2007
@@ -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);
+      }
+   }

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav Thu Nov  8 16:56:19 2007
@@ -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);
+      }
+   }

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav Thu Nov  8 16:56:19 2007
@@ -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

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav Thu Nov  8 16:56:19 2007
@@ -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;
+              }

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav Thu Nov  8 16:56:19 2007
@@ -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;
+              }

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java Thu Nov  8 16:56:19 2007
@@ -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.giop.nameservice;
+
+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 at 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;
+  }  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java Thu Nov  8 16:56:19 2007
@@ -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.giop.nameservice;
+
+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 at 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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java Thu Nov  8 16:56:19 2007
@@ -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.giop.nameservice;
+
+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 at Bioinformatics.org)
+ */
+public class PersistentMap
+    extends NamingMap
+{
+  /**
+   * The data entry.
+   */
+  public static class Entry
+  {
+    String id;
+
+    String kind;
+
+    String ior;
+
+    /**
+     * Get the name component node.
+     */
+    public NameComponent getComponent()
+    {
+      return new NameComponent(id, kind);
+    }
+
+    /**
+     * Write the naming map entry to the output stream.
+     */
+    public void write(OutputStream out) throws IOException
+    {
+      // Format: id.kind <eoln> ior <eoln><eoln>
+      out.write(getKey(id, kind).getBytes());
+      out.write('\n');
+      out.write(ior.getBytes());
+      out.write('\n');
+      out.close();
+    }
+
+    /**
+     * Read the name component from the input stream
+     */
+    public boolean read(BufferedReader in) throws IOException
+    {
+      String key = in.readLine();
+      String xior = in.readLine();
+
+      if (key != null && xior != null)
+        {
+          if (key.length() < 2)
+            {
+              // A single char key cannot have the kind part.
+              id = key;
+              kind = "";
+            }
+          else
+            {
+              // Search for the id/kind splitter, dot:
+              int iks = - 1;
+              for (int i = 1; i < key.length(); i++)
+                {
+                  if (key.charAt(i) == '.')
+                    // The id is separated from kind by dot, unless preceeded by
+                    // the
+                    // escape character, \.
+                    if (key.charAt(i - 1) != '\\')
+                      {
+                        iks = i;
+                        break;
+                      }
+                }
+
+              // May also end by dot, if the kind field is missing.
+              if (iks < 0)
+                {
+                  id = key;
+                  kind = "";
+                }
+              else if (iks == key.length() - 1)
+                {
+                  id = key.substring(0, key.length() - 1);
+                  kind = "";
+                }
+              else
+                {
+                  id = key.substring(0, iks);
+                  kind = key.substring(iks + 1);
+                }
+            }
+          ior = xior;
+          return true;
+        }
+      else
+        return false;
+    }
+
+    /**
+     * Get the key value from the name component.
+     * 
+     * @param id the component id
+     * @param kind the component kind
+     * @return the key value
+     */
+    public String getKey(String id, String kind)
+    {
+      StringBuffer b = new StringBuffer(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(StringBuffer 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;
+          }
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java Thu Nov  8 16:56:19 2007
@@ -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;
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,247 @@
+/* Creator.java - create a new 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.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.Iterator;
+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();
+    InputStream inputStream = null;
+    if (isDirectory)
+      {
+        if (filename.charAt(filename.length() - 1) != '/')
+          filename += '/';
+      }
+    else
+      inputStream = new FileInputStream(file);
+    writeFile(isDirectory, inputStream, filename, verbose);
+  }
+
+  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)
+  {
+    Iterator it = parameters.entries.iterator();
+    ArrayList allEntries = new ArrayList();
+    while (it.hasNext())
+      {
+        Entry entry = (Entry) it.next();
+        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);
+    Iterator it = allEntries.iterator();
+    while (it.hasNext())
+      {
+        Entry entry = (Entry) it.next();
+        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);
+    outputStream = new JarOutputStream(os, manifest);
+    // FIXME: in Classpath 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();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,60 @@
+/* Entry.java - represent a single file to write to a 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.io.File;
+
+public class Entry
+{
+  public File file;
+
+  public String name;
+
+  public Entry(File file, String name)
+  {
+    this.file = file;
+    this.name = name;
+  }
+
+  public Entry(File file)
+  {
+    this.file = file;
+    this.name = file.toString();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java Thu Nov  8 16:56:19 2007
@@ -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);
+          }
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,144 @@
+/* Indexer.java -- add index.list file to 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 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.Iterator;
+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(StringBuffer 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');
+        Iterator i = entries.iterator();
+        while (i.hasNext())
+          {
+            result.append(i.next());
+            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.
+    StringBuffer contents = new StringBuffer();
+    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);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java Thu Nov  8 16:56:19 2007
@@ -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);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,266 @@
+/* Main.java - jar program main()
+ 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 gnu.classpath.tools.getopt.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.File;
+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 Parser initializeParser()
+  {
+    Parser 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;
+      }
+    });
+    p.add(grp);
+
+    return p;
+  }
+
+  private void run(String[] args)
+      throws InstantiationException, IllegalAccessException, IOException
+  {
+    Parser 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());
+    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);
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java Thu Nov  8 16:56:19 2007
@@ -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 + '!';
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* 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.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);
+    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();
+    tmpFile.renameTo(parameters.archiveFile);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,86 @@
+/* WorkSet.java -- Helper to track what files to work on
+   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.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+
+public class WorkSet
+{
+  private HashSet allItems;
+
+  private void initSet(ArrayList entries)
+  {
+    if (entries == null || entries.isEmpty())
+      return;
+    allItems = new HashSet();
+    Iterator it = entries.iterator();
+    while (it.hasNext())
+      {
+        Entry entry = (Entry) it.next();
+        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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/HashUtils.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,124 @@
+/* Utils.java -- Utility methods for JAR file signing/verification
+   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.java.security.hash.Sha160;
+import gnu.java.security.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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* JarSigner.java -- The signing handler of the gjarsigner tool
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.jarsigner;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.SystemProperties;
+import gnu.java.util.jar.JarUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.logging.Logger;
+
+/**
+ * The JAR signing handler of the <code>gjarsigner</code> tool.
+ */
+public class JarSigner
+{
+  private static final Logger log = Logger.getLogger(JarSigner.class.getName());
+  /** The owner tool of this handler. */
+  private Main main;
+
+  JarSigner(Main main)
+  {
+    super();
+
+    this.main = main;
+  }
+
+  void start() throws Exception
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    JarFile jarFile = new JarFile(main.getJarFileName());
+    SFHelper sfHelper = new SFHelper(jarFile);
+
+    sfHelper.startSigning();
+
+    // 1. compute the digests
+    for (Enumeration e = jarFile.entries(); e.hasMoreElements(); )
+      {
+        JarEntry je = (JarEntry) e.nextElement();
+        String jeName = je.getName();
+        if (jeName.equals(JarFile.MANIFEST_NAME)
+            || jeName.endsWith(File.separator))
+          continue;
+
+        sfHelper.updateEntry(je);
+        if (main.isVerbose())
+          System.out.println(Messages.getString("JarSigner.1") + jeName); //$NON-NLS-1$
+      }
+
+    sfHelper.finishSigning(main.isSectionsOnly());
+    if (main.isVerbose())
+      System.out.println(Messages.getString("JarSigner.2") + JarFile.MANIFEST_NAME); //$NON-NLS-1$
+
+    // 2. write jar entries and manifest
+    File signedJarFile = File.createTempFile("gcp-", ".jar"); //$NON-NLS-1$ //$NON-NLS-2$
+    FileOutputStream fos = new FileOutputStream(signedJarFile);
+    JarOutputStream outSignedJarFile = new JarOutputStream(fos,
+                                                           sfHelper.getManifest());
+    for (Enumeration e = jarFile.entries(); e.hasMoreElements(); )
+      {
+        JarEntry je = (JarEntry) e.nextElement();
+        String jeName = je.getName();
+        if (jeName.equals(JarFile.MANIFEST_NAME)
+            || jeName.endsWith(File.separator))
+          continue;
+
+        log.finest("Processing " + jeName); //$NON-NLS-1$
+        JarEntry newEntry = new JarEntry(jeName);
+        newEntry.setTime(je.getTime());
+        outSignedJarFile.putNextEntry(newEntry);
+        InputStream jeis = jarFile.getInputStream(je);
+        copyFromTo(jeis, outSignedJarFile);
+      }
+
+    // 3. create the .SF file
+    String signaturesFileName = main.getSigFileName();
+    String sfFileName = JarUtils.META_INF + signaturesFileName
+                        + JarUtils.SF_SUFFIX;
+    if (Configuration.DEBUG)
+      log.fine("Processing " + sfFileName); //$NON-NLS-1$
+    JarEntry sfEntry = new JarEntry(sfFileName);
+    sfEntry.setTime(System.currentTimeMillis());
+    outSignedJarFile.putNextEntry(sfEntry);
+    sfHelper.writeSF(outSignedJarFile);
+    if (Configuration.DEBUG)
+      log.fine("Created .SF file"); //$NON-NLS-1$
+    if (main.isVerbose())
+      System.out.println(Messages.getString("JarSigner.8") + sfFileName); //$NON-NLS-1$
+
+    // 4. create the .DSA file
+    String dsaFileName = JarUtils.META_INF + signaturesFileName
+                         + JarUtils.DSA_SUFFIX;
+    if (Configuration.DEBUG)
+      log.fine("Processing " + dsaFileName); //$NON-NLS-1$
+    JarEntry dsaEntry = new JarEntry(dsaFileName);
+    dsaEntry.setTime(System.currentTimeMillis());
+    outSignedJarFile.putNextEntry(dsaEntry);
+    sfHelper.writeDSA(outSignedJarFile,
+                      main.getSignerPrivateKey(),
+                      main.getSignerCertificateChain(),
+                      main.isInternalSF());
+    if (Configuration.DEBUG)
+      log.fine("Created .DSA file"); //$NON-NLS-1$
+    if (main.isVerbose())
+      System.out.println(Messages.getString("JarSigner.8") + dsaFileName); //$NON-NLS-1$
+
+    // cleanup
+    outSignedJarFile.close();
+    fos.close();
+    signedJarFile.renameTo(new File(main.getSignedJarFileName()));
+    if (Configuration.DEBUG)
+      log.fine("Renamed signed JAR file"); //$NON-NLS-1$
+    if (main.isVerbose())
+      System.out.println(SystemProperties.getProperty("line.separator") //$NON-NLS-1$
+                         + Messages.getString("JarSigner.14")); //$NON-NLS-1$
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  private void copyFromTo(InputStream in, JarOutputStream out)
+    throws IOException
+  {
+    byte[] buffer = new byte[8192];
+    int n;
+    while ((n = in.read(buffer)) != -1)
+      if (n > 0)
+        out.write(buffer, 0, n);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarVerifier.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,348 @@
+/* JarVerifier.java -- The verification 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.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.Certificate;
+import java.security.cert.CRLException;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.logging.Logger;
+import java.util.zip.ZipException;
+
+/**
+ * The JAR verification handler of the <code>gjarsigner</code> tool.
+ */
+public class JarVerifier
+{
+  private static final Logger log = Logger.getLogger(JarVerifier.class.getName());
+  /** The owner tool of this handler. */
+  private Main main;
+  private HashUtils util = new HashUtils();
+  /** The JAR file to verify. */
+  private JarFile jarFile;
+  /** Map of jar entry names to their hash. */
+  private Map 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 (Iterator it = sfFiles.iterator(); it.hasNext(); )
+          {
+            String alias = (String) it.next();
+            if (verifySF(alias))
+              if (verifySFEntries(alias))
+                count++;
+          }
+
+        if (count == 0)
+          System.out.println(Messages.getString("JarVerifier.3")); //$NON-NLS-1$
+        else if (count != limit)
+          System.out.println(Messages.getFormattedString("JarVerifier.4", //$NON-NLS-1$
+                                                         new Integer[] {Integer.valueOf(count),
+                                                                        Integer.valueOf(limit)}));
+        else
+          System.out.println(Messages.getFormattedString("JarVerifier.7", //$NON-NLS-1$
+                                                         Integer.valueOf(limit)));
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  /**
+   * @param sigFileName the name of the signature file; i.e. the name to use for
+   *          both the .SF and .DSA files.
+   * @return <code>true</code> if the designated file-name (usually a key-store
+   * <i>alias</i> name) has been successfully checked as the signer of the
+   * corresponding <code>.SF</code> file. Returns <code>false</code> otherwise.
+   * @throws IOException
+   * @throws ZipException
+   * @throws CertificateException
+   * @throws CRLException
+   */
+  private boolean verifySF(String sigFileName) throws CRLException,
+      CertificateException, ZipException, IOException
+  {
+    if (Configuration.DEBUG)
+      {
+        log.entering(this.getClass().getName(), "verifySF"); //$NON-NLS-1$
+        log.fine("About to verify signature of " + sigFileName + "..."); //$NON-NLS-1$ //$NON-NLS-2$
+      }
+    // 1. find the corresponding .DSA file for this .SF file
+    JarEntry dsaEntry = jarFile.getJarEntry(JarUtils.META_INF + sigFileName
+                                            + JarUtils.DSA_SUFFIX);
+    if (dsaEntry == null)
+      throw new SecurityException(Messages.getFormattedString("JarVerifier.13", //$NON-NLS-1$
+                                                              sigFileName));
+    // 2. read the .DSA file contents as a PKCS7 SignedData
+    InputStream in = jarFile.getInputStream(dsaEntry);
+    PKCS7SignedData pkcs7SignedData = new PKCS7SignedData(in);
+
+    // 4. get the encrypted digest octet string from the first SignerInfo
+    //    this octet string is the digital signature of the .SF file contents
+    Set signerInfos = pkcs7SignedData.getSignerInfos();
+    if (signerInfos == null || signerInfos.isEmpty())
+      throw new SecurityException(Messages.getString("JarVerifier.14")); //$NON-NLS-1$
+
+    SignerInfo signerInfo = (SignerInfo) signerInfos.iterator().next();
+    byte[] encryptedDigest = signerInfo.getEncryptedDigest();
+    if (encryptedDigest == null)
+      throw new SecurityException(Messages.getString("JarVerifier.16")); //$NON-NLS-1$
+
+    if (Configuration.DEBUG)
+      log.fine("\n" + Util.dumpString(encryptedDigest, "--- signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+
+    // 5. get the signer public key
+    Certificate cert = pkcs7SignedData.getCertificates()[0];
+    PublicKey verifierKey = cert.getPublicKey();
+    if (Configuration.DEBUG)
+      log.fine("--- verifier public key = " + verifierKey); //$NON-NLS-1$
+
+    // 6. verify the signature file signature
+    OID digestEncryptionAlgorithmOID = signerInfo.getDigestEncryptionAlgorithmId();
+    ISignature signatureAlgorithm;
+    ISignatureCodec signatureCodec;
+    if (digestEncryptionAlgorithmOID.equals(Main.DSA_SIGNATURE_OID))
+      {
+        signatureAlgorithm = new DSSSignature();
+        signatureCodec = new DSSSignatureX509Codec();
+      }
+    else
+      {
+        signatureAlgorithm = new RSAPKCS1V1_5Signature(Registry.MD5_HASH);
+        signatureCodec = new RSAPKCS1V1_5SignatureX509Codec();
+      }
+
+    Map signatureAttributes = new HashMap();
+    signatureAttributes.put(ISignature.VERIFIER_KEY, verifierKey);
+    signatureAlgorithm.setupVerify(signatureAttributes);
+
+    Object herSignature = signatureCodec.decodeSignature(encryptedDigest);
+
+    // 7. verify the signature file contents
+    JarEntry sfEntry = jarFile.getJarEntry(JarUtils.META_INF + sigFileName
+                                           + JarUtils.SF_SUFFIX);
+    in = jarFile.getInputStream(sfEntry);
+    byte[] buffer = new byte[2048];
+    int n;
+    while ((n = in.read(buffer)) != -1)
+      if (n > 0)
+        signatureAlgorithm.update(buffer, 0, n);
+
+    boolean result = signatureAlgorithm.verify(herSignature);
+    if (Configuration.DEBUG)
+      {
+        log.fine("Signature block [" + sigFileName + "] is " //$NON-NLS-1$ //$NON-NLS-2$
+                 + (result ? "" : "NOT ") + "OK"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        log.exiting(this.getClass().getName(), "verifySF", Boolean.valueOf(result)); //$NON-NLS-1$
+      }
+    return result;
+  }
+
+  /**
+   * This method is called after at least one signer (usually a key-store
+   * <code>alias</code> name) was found to be trusted; i.e. his/her signature
+   * block in the corresponding <code>.DSA</code> file was successfully
+   * verified using his/her public key.
+   * <p>
+   * This method, uses the contents of the corresponding <code>.SF</code> file
+   * to compute and verify the hashes of the manifest entries in the JAR file.
+   * 
+   * @param alias the name of the signature file; i.e. the name to use for both
+   *          the .SF and .DSA files.
+   * @return <code>true</code> if all the entries in the corresponding
+   *         <code>.SF</code> file have the same hash values as their
+   *         alter-ego in the <i>manifest</i> file of the JAR file inquestion.
+   * @throws IOException if an I/O related exception occurs during the process.
+   */
+  private boolean verifySFEntries(String alias) throws IOException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "verifySFEntries"); //$NON-NLS-1$
+    // 1. read the signature file
+    JarEntry jarEntry = jarFile.getJarEntry(JarUtils.META_INF + alias
+                                            + JarUtils.SF_SUFFIX);
+    InputStream in = jarFile.getInputStream(jarEntry);
+    Attributes attr = new Attributes();
+    Map 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 (Iterator it = entries.keySet().iterator(); it.hasNext();)
+        {
+          Entry me = (Entry) it.next();
+          String name = (String) me.getKey();
+          attr = (Attributes) me.getValue();
+          hash = attr.getValue(Main.DIGEST_ATTR);
+          result = verifySFEntry(name, hash);
+          if (! result)
+            break;
+        }
+
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "verifySFEntries", //$NON-NLS-1$
+                  Boolean.valueOf(result));
+    return result;
+  }
+
+  /**
+   * @param hash Base-64 encoded form of the manifest's digest.
+   * @return <code>true</code> if our computation of the manifest's hash
+   *         matches the given value; <code>false</code> otherwise.
+   * @throws IOException if unable to acquire the JAR's manifest entry.
+   */
+  private boolean verifyManifest(String hash) throws IOException
+  {
+    return verifySFEntry(JarFile.MANIFEST_NAME, hash);
+  }
+
+  /**
+   * @param name the name of a JAR entry to verify.
+   * @param hash Base-64 encoded form of the designated entry's digest.
+   * @return <code>true</code> if our computation of the JAR entry's hash
+   *         matches the given value; <code>false</code> otherwise.
+   * @throws IOException if an exception occurs while returning the entry's
+   *           input stream.
+   */
+  private boolean verifySFEntry(String name, String hash) throws IOException
+  {
+    String expectedValue = getEntryHash(JarFile.MANIFEST_NAME);
+    boolean result = expectedValue.equalsIgnoreCase(hash);
+    if (Configuration.DEBUG)
+      log.fine("Is " + name + " OK? " + result); //$NON-NLS-1$ //$NON-NLS-2$
+    return result;
+  }
+
+  private String getEntryHash(String entryName) throws IOException
+  {
+    String result = (String) entryHashes.get(entryName);
+    if (result == null)
+      {
+        JarEntry manifest = jarFile.getJarEntry(entryName);
+        InputStream in = jarFile.getInputStream(manifest);
+        result = util.hashStream(in);
+        entryHashes.put(entryName, result);
+      }
+
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,691 @@
+/* Main.java -- JAR signing and verification tool not unlike jarsigner
+   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.classpath.tools.common.CallbackUtil;
+import gnu.classpath.tools.common.ProviderUtil;
+import gnu.classpath.tools.getopt.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.java.security.OID;
+import gnu.java.security.Registry;
+import gnu.javax.security.auth.callback.ConsoleCallbackHandler;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.Security;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.jar.Attributes.Name;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The GNU Classpath implementation of the <i>jarsigner</i> tool.
+ * <p>
+ * The <i>jarsigner</i> tool is used to sign and verify JAR (Java ARchive)
+ * files.
+ * <p>
+ * This implementation is intended to be compatible with the behaviour
+ * described in the public documentation of the same tool included in JDK 1.4.
+ */
+public class Main
+{
+  protected static final Logger log = Logger.getLogger(Main.class.getName());
+  static final String KEYTOOL_TOOL = "jarsigner"; //$NON-NLS-1$
+  private static final Locale EN_US_LOCALE = new Locale("en", "US"); //$NON-NLS-1$ //$NON-NLS-2$
+  static final String DIGEST = "SHA1-Digest"; //$NON-NLS-1$
+  static final String DIGEST_MANIFEST = "SHA1-Digest-Manifest"; //$NON-NLS-1$
+  static final Name DIGEST_ATTR = new Name(DIGEST);
+  static final Name DIGEST_MANIFEST_ATTR = new Name(DIGEST_MANIFEST);
+  static final OID DSA_SIGNATURE_OID = new OID(Registry.DSA_OID_STRING);
+  static final OID RSA_SIGNATURE_OID = new OID(Registry.RSA_OID_STRING);
+
+  protected boolean verify;
+  protected String ksURL;
+  protected String ksType;
+  protected String password;
+  protected String ksPassword;
+  protected String sigFileName;
+  protected String signedJarFileName;
+  protected boolean verbose;
+  protected boolean certs;
+  protected boolean internalSF;
+  protected boolean sectionsOnly;
+  protected String providerClassName;
+  protected String jarFileName;
+  protected String alias;
+
+  protected Provider provider;
+  private boolean providerInstalled;
+  private char[] ksPasswordChars;
+  private KeyStore store;
+  private char[] passwordChars;
+  private PrivateKey signerPrivateKey;
+  private Certificate[] signerCertificateChain;
+  /** The callback handler to use when needing to interact with user. */
+  private CallbackHandler handler;
+  /** The command line parser. */
+  private ToolParser cmdLineParser;
+  protected ArrayList 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);
+  }
+
+  // helper methods -----------------------------------------------------------
+
+  /**
+   * Read the command line arguments setting the tool's parameters in
+   * preparation for the user desired action.
+   * 
+   * @param args an array of options (strings).
+   * @throws Exception if an exception occurs during the process.
+   */
+  private void processArgs(String[] args) throws Exception
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
+    cmdLineParser = new ToolParser();
+    cmdLineParser.initializeParser();
+    cmdLineParser.parse(args, new ToolParserCallback());
+
+    setupCommonParams();
+    if (verify)
+      {
+        if (Configuration.DEBUG)
+          {
+            log.fine("Will verify with the following parameters:"); //$NON-NLS-1$
+            log.fine("     jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("Options:"); //$NON-NLS-1$
+            log.fine("     provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("      verbose ? " + verbose); //$NON-NLS-1$
+            log.fine("        certs ? " + certs); //$NON-NLS-1$
+            log.fine("   internalsf ? " + internalSF); //$NON-NLS-1$
+            log.fine(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$
+          }
+      }
+    else // sign
+      {
+        setupSigningParams();
+        if (Configuration.DEBUG)
+          {
+            log.fine("Will sign with the following parameters:"); //$NON-NLS-1$
+            log.fine("     jar-file = '" + jarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("        alias = '" + alias + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("Options:"); //$NON-NLS-1$
+            log.fine("     keystore = '" + ksURL + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("    storetype = '" + ksType + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("    storepass = '" + ksPassword + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("      keypass = '" + password + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("      sigfile = '" + sigFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("    signedjar = '" + signedJarFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("     provider = '" + providerClassName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+            log.fine("      verbose ? " + verbose); //$NON-NLS-1$
+            log.fine("   internalsf ? " + internalSF); //$NON-NLS-1$
+            log.fine(" sectionsonly ? " + sectionsOnly); //$NON-NLS-1$
+          }
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "processArgs"); //$NON-NLS-1$
+  }
+
+  /**
+   * Invokes the <code>start()</code> method of the concrete handler.
+   * <p>
+   * Depending on the result of processing the command line arguments, this
+   * handler may be one for signing the jar, or verifying it.
+   * 
+   * @throws Exception if an exception occurs during the process.
+   */
+  private void start() throws Exception
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    if (verify)
+      {
+        JarVerifier jv = new JarVerifier(this);
+        jv.start();
+      }
+    else
+      {
+        JarSigner js = new JarSigner(this);
+        js.start();
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  /**
+   * Ensures that the underlying JVM is left in the same state as we found it
+   * when we first launched the tool. Specifically, if we have installed a new
+   * security provider then now is the time to remove it.
+   * <p>
+   * Note (rsn): this may not be necessary if we terminate the JVM; i.e. call
+   * {@link System#exit(int)} at the end of the tool's invocation. Nevertheless
+   * it's good practive to return the JVM to its initial state.
+   */
+  private void teardown()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+    if (providerInstalled)
+      ProviderUtil.removeProvider(provider.getName());
+
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+  }
+
+  /**
+   * After processing the command line arguments, this method is invoked to
+   * process the common parameters which may have been encountered among the
+   * actual arguments.
+   * <p>
+   * Common parameters are those which are allowed in both signing and
+   * verification modes.
+   * 
+   * @throws InstantiationException if a security provider class name is
+   *           specified but that class name is that of either an interface or
+   *           an abstract class.
+   * @throws IllegalAccessException if a security provider class name is
+   *           specified but no 0-arguments constructor is defined for that
+   *           class.
+   * @throws ClassNotFoundException if a security provider class name is
+   *           specified but no such class was found in the classpath.
+   * @throws IOException if the JAR file name for signing, or verifying, does
+   *           not exist, exists but denotes a directory, or is not readable.
+   */
+  private void setupCommonParams() throws InstantiationException,
+      IllegalAccessException, ClassNotFoundException, IOException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
+    File jar = new File(jarFileName);
+    if (! jar.exists())
+      throw new FileNotFoundException(jarFileName);
+
+    if (jar.isDirectory())
+      throw new IOException(Messages.getFormattedString("Main.70", jarFileName)); //$NON-NLS-1$
+
+    if (! jar.canRead())
+      throw new IOException(Messages.getFormattedString("Main.72", jarFileName)); //$NON-NLS-1$ //$NON-NLS-2$
+
+    if (providerClassName != null && providerClassName.length() > 0)
+      {
+        provider = (Provider) Class.forName(providerClassName).newInstance();
+        // is it already installed?
+        String providerName = provider.getName();
+        Provider installedProvider = Security.getProvider(providerName);
+        if (installedProvider != null)
+          {
+            if (Configuration.DEBUG)
+              log.finer("Provider " + providerName + " is already installed"); //$NON-NLS-1$ //$NON-NLS-2$
+          }
+        else // install it
+          installNewProvider();
+      }
+
+    if (! verbose && certs)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Option <certs> is set but <verbose> is not. Ignored"); //$NON-NLS-1$
+        certs = false;
+      }
+
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
+  }
+
+  /**
+   * Install the user defined security provider in the underlying JVM.
+   * <p>
+   * Also record this fact so we can remove it when we exit the tool.
+   */
+  private void installNewProvider()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$
+    providerInstalled = ProviderUtil.addProvider(provider) != -1;
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "installNewProvider"); //$NON-NLS-1$
+  }
+
+  /**
+   * After processing the command line arguments, this method is invoked to
+   * process the parameters which may have been encountered among the actual
+   * arguments, and which are specific to the signing action of the tool.
+   * 
+   * @throws KeyStoreException if no implementation of the designated (or
+   *           default type) of a key store is availabe.
+   * @throws IOException if an I/O related exception occurs during the process.
+   * @throws NoSuchAlgorithmException if an implementation of an algorithm used
+   *           by the key store is not available.
+   * @throws CertificateException if an exception occurs while reading a
+   *           certificate from the key store.
+   * @throws UnsupportedCallbackException if no implementation of a password
+   *           callback is available.
+   * @throws UnrecoverableKeyException if the wrong password was used to unlock
+   *           the key store.
+   * @throws SecurityException if the designated alias is not known to the key
+   *           store or is not an Alias of a Key Entry.
+   */
+  private void setupSigningParams() throws KeyStoreException, IOException,
+      NoSuchAlgorithmException, CertificateException,
+      UnsupportedCallbackException, UnrecoverableKeyException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$
+    if (ksURL == null || ksURL.trim().length() == 0)
+      {
+        String userHome = SystemProperties.getProperty("user.home"); //$NON-NLS-1$
+        if (userHome == null || userHome.trim().length() == 0)
+          throw new SecurityException(Messages.getString("Main.85")); //$NON-NLS-1$
+
+        ksURL = "file:" + userHome.trim() + "/.keystore"; //$NON-NLS-1$ //$NON-NLS-2$
+      }
+    else
+      {
+        ksURL = ksURL.trim();
+        if (ksURL.indexOf(":") == -1) //$NON-NLS-1$
+          ksURL = "file:" + ksURL; //$NON-NLS-1$
+      }
+
+    if (ksType == null || ksType.trim().length() == 0)
+      ksType = KeyStore.getDefaultType();
+    else
+      ksType = ksType.trim();
+
+    store = KeyStore.getInstance(ksType);
+
+    if (ksPassword == null)
+      {
+        // ask the user to provide one
+        PasswordCallback pcb = new PasswordCallback(Messages.getString("Main.92"), //$NON-NLS-1$
+                                                    false);
+        getCallbackHandler().handle(new Callback[] { pcb });
+        ksPasswordChars = pcb.getPassword();
+      }
+    else
+      ksPasswordChars = ksPassword.toCharArray();
+
+    URL url = new URL(ksURL);
+    InputStream stream = url.openStream();
+    store.load(stream, ksPasswordChars);
+
+    if (! store.containsAlias(alias))
+      throw new SecurityException(Messages.getFormattedString("Main.6", alias)); //$NON-NLS-1$
+
+    if (! store.isKeyEntry(alias))
+      throw new SecurityException(Messages.getFormattedString("Main.95", alias)); //$NON-NLS-1$
+
+    Key key;
+    if (password == null)
+      {
+        passwordChars = ksPasswordChars;
+        try
+          {
+            key = store.getKey(alias, passwordChars);
+          }
+        catch (UnrecoverableKeyException x)
+          {
+            // ask the user to provide one
+            String prompt = Messages.getFormattedString("Main.97", alias); //$NON-NLS-1$
+            PasswordCallback pcb = new PasswordCallback(prompt, false);
+            getCallbackHandler().handle(new Callback[] { pcb });
+            passwordChars = pcb.getPassword();
+            // take 2
+            key = store.getKey(alias, passwordChars);
+          }
+      }
+    else
+      {
+        passwordChars = password.toCharArray();
+        key = store.getKey(alias, passwordChars);
+      }
+
+    if (! (key instanceof PrivateKey))
+      throw new SecurityException(Messages.getFormattedString("Main.99", alias)); //$NON-NLS-1$
+
+    signerPrivateKey = (PrivateKey) key;
+    signerCertificateChain = store.getCertificateChain(alias);
+    if (Configuration.DEBUG)
+      log.fine(String.valueOf(signerCertificateChain));
+
+    if (sigFileName == null)
+      sigFileName = alias;
+
+    sigFileName = sigFileName.toUpperCase(EN_US_LOCALE);
+    if (sigFileName.length() > 8)
+      sigFileName = sigFileName.substring(0, 8);
+
+    char[] chars = sigFileName.toCharArray();
+    for (int i = 0; i < chars.length; i++)
+      {
+        char c = chars[i];
+        if (! (Character.isLetter(c)
+            || Character.isDigit(c)
+            || c == '_'
+            || c == '-'))
+          chars[i] = '_';
+      }
+
+    sigFileName = new String(chars);
+
+    if (signedJarFileName == null)
+      signedJarFileName = jarFileName;
+
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "setupSigningParams"); //$NON-NLS-1$
+  }
+
+  boolean isVerbose()
+  {
+    return verbose;
+  }
+
+  boolean isCerts()
+  {
+    return certs;
+  }
+
+  String getSigFileName()
+  {
+    return this.sigFileName;
+  }
+
+  String getJarFileName()
+  {
+    return this.jarFileName;
+  }
+
+  boolean isSectionsOnly()
+  {
+    return this.sectionsOnly;
+  }
+
+  boolean isInternalSF()
+  {
+    return this.internalSF;
+  }
+
+  PrivateKey getSignerPrivateKey()
+  {
+    return this.signerPrivateKey;
+  }
+
+  Certificate[] getSignerCertificateChain()
+  {
+    return signerCertificateChain;
+  }
+
+  String getSignedJarFileName()
+  {
+    return this.signedJarFileName;
+  }
+
+  /**
+   * Return a CallbackHandler which uses the Console (System.in and System.out)
+   * for interacting with the user.
+   * <p>
+   * This method first finds all currently installed security providers capable
+   * of providing such service and then in turn attempts to instantiate the
+   * handler from those providers. As soon as one provider returns a non-null
+   * instance of the callback handler, the search stops and that instance is
+   * set to be used from now on.
+   * <p>
+   * If no installed providers were found, this method falls back on the GNU
+   * provider, by-passing the Security search mechanism. The default console
+   * callback handler implementation is {@link ConsoleCallbackHandler}.
+   * 
+   * @return a console-based {@link CallbackHandler}.
+   */
+  protected CallbackHandler getCallbackHandler()
+  {
+    if (handler == null)
+      handler = CallbackUtil.getConsoleHandler();
+
+    return handler;
+  }
+
+  private class ToolParserCallback
+      extends FileArgumentCallback
+  {
+    public void notifyFile(String fileArgument)
+    {
+      fileAndAlias.add(fileArgument);
+    }
+  }
+
+  private class ToolParser
+      extends ClasspathToolParser
+  {
+    public ToolParser()
+    {
+      super(KEYTOOL_TOOL, true);
+    }
+
+    protected void validate() throws OptionException
+    {
+      if (fileAndAlias.size() < 1)
+        throw new OptionException(Messages.getString("Main.133")); //$NON-NLS-1$
+
+      jarFileName = (String) fileAndAlias.get(0);
+      if (! verify) // must have an ALIAS. use "mykey" if undefined
+        if (fileAndAlias.size() < 2)
+          {
+            if (Configuration.DEBUG)
+              log.fine("Missing ALIAS argument. Will use [mykey] instead"); //$NON-NLS-1$
+            alias = "mykey"; //$NON-NLS-1$
+          }
+        else
+          alias = (String) 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);
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java Thu Nov  8 16:56:19 2007
@@ -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.jarsigner;
+
+import gnu.classpath.Configuration;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+/**
+ * An initially generated Eclipse helper class to ease the use of localized
+ * messages.
+ * <p>
+ * Enriched to handle localized message formats.
+ */
+class Messages
+{
+  private static final Logger log = Logger.getLogger(Messages.class.getName());
+  private static final String BUNDLE_NAME = "gnu.classpath.tools.jarsigner.messages";
+  private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+  private static final Map 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) + '!';
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/SFHelper.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,505 @@
+/* SFHelper -- A .SF file helper
+   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.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
+{
+  // Constants and fields
+  // --------------------------------------------------------------------------
+
+  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;
+
+  // Constructor(s)
+  // --------------------------------------------------------------------------
+
+  /**
+   * @param jar the JAR archive the .SF file belongs to.
+   */
+  public SFHelper(JarFile jar)
+  {
+    super();
+
+    this.jar = jar;
+    this.state = READY;
+  }
+
+  // Class methods
+  // --------------------------------------------------------------------------
+
+  // Instance methods
+  // --------------------------------------------------------------------------
+
+  /**
+   * Writes the contents of the <code>.SF</code> file to the designated JAR
+   * output stream. Line-endings are platform-independent and consist of the
+   * 2-codepoint sequence <code>0x0D</code> and <code>0x0A</code>.
+   * 
+   * @param jar the JAR output stream to write a <code>.SF</code> file to.
+   * @throws IOException if an I/O related exception occurs during the process.
+   */
+  void writeSF(JarOutputStream jar) throws IOException
+  {
+    if (this.state != FINISHED)
+      throw new IllegalStateException(Messages.getString("SFHelper.1")); //$NON-NLS-1$
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    JarUtils.writeSFManifest(sfMainAttributes, sfEntries, baos);
+    sfBytes = baos.toByteArray();
+    if (Configuration.DEBUG)
+      log.fine("\n" + Util.dumpString(sfBytes, "+++ sfBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+    jar.write(sfBytes);
+    jar.flush();
+
+    this.state = SF_GENERATED;
+  }
+
+  /**
+   * The contents of the .DSA file is the DER encoded form of a PKCS#7
+   * ContentInfo of the type SignedData.
+   * <p>
+   * The ContentInfo ASN.1 syntax is as described in the "PKCS#7 Cryptographic
+   * Message Syntax Standard" (RSA Labs) specifications:
+   * <pre>
+   * ContentInfo ::= SEQUENCE {
+   *   contentType     ContentType,
+   *   content     [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
+   * }
+   * 
+   * ContentType ::= OBJECT IDENTIFIER
+   * </pre>
+   * <p>
+   * The ContentType is an OID which determines the type of the contents field
+   * that follows it. For the .DSA file the OID is "1.2.840.113549.1.7.2", while
+   * the content field is the byte array representing the DER encoded form of a
+   * SignedData content-type. The ASN.1 syntax of the SignedData type is as
+   * follows:
+   * <pre>
+   * SignedData ::= SEQUENCE {
+   *   version          Version, -- always 1 for PKCS#7 1.5
+   *   digestAlgorithms DigestAlgorithmIdentifiers,
+   *   contentInfo      ContentInfo,
+   *   certificates [0] IMPLICIT ExtendedCertificatesAndCertificates OPTIONAL,
+   *   crls         [1] IMPLICIT CertificateRevocationLists OPTIONAL,
+   *   signerInfos      SignerInfos
+   * }
+   * 
+   * DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
+   * 
+   * SignerInfos ::= SET OF SignerInfo
+   * </pre>
+   * <p>
+   * Finally the SignerInfo is a per-signer structure. Its ASN.1 syntax looks
+   * like so:
+   * <pre>
+   * SignerInfo ::= SEQUENCE {
+   *   version                       Version, -- always 1 for PKCS#7 1.5
+   *   issuerAndSerialNumber         IssuerAndSerialNumber,
+   *   digestAlgorithm               DigestAlgorithmIdentifier,
+   *   authenticatedAttributes   [0] IMPLICIT Attributes OPTIONAL,
+   *   digestEncryptionAlgorithm     DigestEncryptionAlgorithmIdentifier,
+   *   encryptedDigest               EncryptedDigest,
+   *   unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL
+   * }
+   * 
+   * EncryptedDigest ::= OCTET STRING
+   * </pre>
+   * 
+   * @param jar the JAR output stream to write a <code>.DSA</code> file to.
+   * @param signerKey the private key to sign with.
+   * @param certificates the possibly null signer certificate chain.
+   * @param internalSF if <code>true</code> then include the .SF file contents
+   * in the signed .DSA file; otherwise don't. 
+   * @throws IOException if an I/O related exception occurs during the process.
+   * @throws CRLException 
+   * @throws CertificateEncodingException 
+   */
+  void writeDSA(JarOutputStream jar, PrivateKey signerKey,
+                Certificate[] certificates, boolean internalSF)
+      throws IOException, CertificateEncodingException, CRLException
+  {
+    if (this.state != SF_GENERATED)
+      throw new IllegalStateException(Messages.getString("SFHelper.4")); //$NON-NLS-1$
+
+    if (Configuration.DEBUG)
+      log.fine("+++ signer private key = " + signerKey); //$NON-NLS-1$
+    ISignature signatureAlgorithm;
+    ISignatureCodec signatureCodec;
+    OID digestEncryptionAlgorithmOID;
+    if (signerKey instanceof DSAPrivateKey)
+      {
+        signatureAlgorithm = new DSSSignature();
+        signatureCodec = new DSSSignatureX509Codec();
+        digestEncryptionAlgorithmOID = Main.DSA_SIGNATURE_OID;
+      }
+    else if (signerKey instanceof RSAPrivateKey)
+      {
+        signatureAlgorithm = new RSAPKCS1V1_5Signature(Registry.MD5_HASH);
+        signatureCodec = new RSAPKCS1V1_5SignatureX509Codec();
+        digestEncryptionAlgorithmOID = Main.RSA_SIGNATURE_OID;
+      }
+    else
+      throw new SecurityException(Messages.getString("SFHelper.6")); //$NON-NLS-1$
+
+    Map signatureAttributes = new HashMap();
+    signatureAttributes.put(ISignature.SIGNER_KEY, signerKey);
+    signatureAlgorithm.setupSign(signatureAttributes);
+    signatureAlgorithm.update(sfBytes, 0, sfBytes.length);
+    Object signature = signatureAlgorithm.sign();
+    byte[] signedSFBytes = signatureCodec.encodeSignature(signature);
+    if (Configuration.DEBUG)
+      log.fine("\n" + Util.dumpString(signedSFBytes, "+++ signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$
+
+    Set 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;
+  }
+
+  // own methods --------------------------------------------------------------
+
+  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 = (Attributes) sfEntries.get(name);
+    if (sfAttributes == null)
+      {
+        sfAttributes = new Attributes();
+        sfEntries.put(name, sfAttributes);
+      }
+
+    sfAttributes.putValue(Main.DIGEST, sfHash);
+    if (Configuration.DEBUG)
+      {
+        log.fine("Name: " + name); //$NON-NLS-1$
+        log.fine(Main.DIGEST + ": " + sfHash); //$NON-NLS-1$
+        log.fine(""); //$NON-NLS-1$
+      }
+  }
+
+  /**
+   * @param sectionsOnly whether to compute, in addition to the files, the hash
+   * of the mainfest itself (<code>false</code>) or not (<code>true</code>).
+   */
+  void finishSigning(boolean sectionsOnly) throws IOException
+  {
+    if (state != STARTED)
+      throw new IllegalStateException(Messages.getString("SFHelper.10")); //$NON-NLS-1$
+
+    if (sectionsOnly)
+      return;
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    manifest.write(baos);
+    baos.flush();
+    String manifestHash = util.hashByteArray(baos.toByteArray());
+    if (Configuration.DEBUG)
+      log.fine("Hashed Manifest " + manifestHash); //$NON-NLS-1$
+    sfMainAttributes.putValue(Main.DIGEST_MANIFEST, manifestHash);
+
+    this.state = FINISHED;
+  }
+
+  /**
+   * Given an X.509 certificate this method returns the string representation of
+   * the Issuer Distinguished Name.
+   * 
+   * @param cert an X.509 certificate.
+   * @return the string representation of the Issuer's DN.
+   */
+  private String getIssuerName(X509Certificate cert)
+  {
+    X500Principal xp = cert.getIssuerX500Principal();
+    if (xp == null)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+                   + ", has null Issuer. Return [unknown]"); //$NON-NLS-1$
+        return Messages.getString("SFHelper.14"); //$NON-NLS-1$
+      }
+    String result = xp.getName();
+    if (result == null)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+                   + ", has an Issuer with null DN. Return [unnamed]"); //$NON-NLS-1$
+        return Messages.getString("SFHelper.17"); //$NON-NLS-1$
+      }
+    return result;
+  }
+
+  /**
+   * Given an X.509 certificate this method returns the string representation of
+   * the Subject Distinguished Name.
+   * 
+   * @param cert an X.509 certificate.
+   * @return the string representation of the Subject's DN.
+   */
+  private String getSubjectName(X509Certificate cert)
+  {
+    X500Principal xp = cert.getSubjectX500Principal();
+    if (xp == null)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+                   + ", has null Subject. Return [unknown]"); //$NON-NLS-1$
+        return Messages.getString("SFHelper.14"); //$NON-NLS-1$
+      }
+    String result = xp.getName();
+    if (result == null)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+                   + ", has a Subject with null DN. Return [unnamed]"); //$NON-NLS-1$
+        return Messages.getString("SFHelper.17"); //$NON-NLS-1$
+      }
+    return result;
+  }
+
+  /**
+   * Given an X.509 certificate this method returns the end validity date of 
+   * this certificate.
+   * 
+   * @param cert an X.509 certificate.
+   * @return the date when this certificate stops being valid.
+   */
+  private Date getNotAfterDate(X509Certificate cert)
+  {
+    Date result = cert.getNotAfter();
+    if (result == null)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+                   + ", has null start-validity date. Return epoch"); //$NON-NLS-1$
+        return new Date(0);
+      }
+    return result;
+  }
+
+  /**
+   * Given an X.509 certificate this method returns the start validity date of
+   * this certificate.
+   * 
+   * @param cert an X.509 certificate.
+   * @return the date when this certificate starts being valid.
+   */
+  private Date getNotBeforeDate(X509Certificate cert)
+  {
+    Date result = cert.getNotBefore();
+    if (result == null)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Certiticate, with serial number " + cert.getSerialNumber() //$NON-NLS-1$
+                   + ", has null end-validity date. Return epoch"); //$NON-NLS-1$
+        return new Date(0);
+      }
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/jarsigner/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.classpath.tools.jarsigner
+
+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. -->
+
+<html>
+<head>
+  <title>GNU Classpath - gnu.classpath.tools.jarsigner</title>
+</head>
+
+<body>
+This package contains the classes that provide an implementation of the
+Security Tool: <code>jarsigner</code>. The behaviour of these classes should
+match that of the same tool provided in the RI version 1.4.2, except for the
+following:
+
+<ul>
+  <li>The RI tool accepts -J<i>javaoption</i> options which it then passes to
+  the underlying JVM.  This is because the RI tool acts as a <i>wrapper</i>
+  around the JVM launcher.
+  <p>
+  This implementation DOES NOT support these options.
+  </li>
+</ul>
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/CACertCmd.java Thu Nov  8 16:56:19 2007
@@ -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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.util.logging.Logger;
+
+/**
+ * The <code>-cacert</code> keytol command handler is used to import a CA
+ * trusted X.509 certificate into a key store.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-file FILE_NAME</dt>
+ *      <dd>The fully qualified path of the file containing the trusted CA
+ *      certificate to import. If omitted, the tool will process STDIN.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+public class CACertCmd
+    extends Command
+{
+  private static final Logger log = Logger.getLogger(CACertCmd.class.getName());
+  /** Pathname of the file containing the CA certificate to import. */
+  protected String _certFileName;
+  /** Type of the key store to use. */
+  protected String _ksType;
+  /** The URL to the keystore where the trusted certificates will be added. */
+  protected String _ksURL;
+  /** The password protecting the keystore. */
+  protected String _ksPassword;
+  /** Class name of a security provider to use. */
+  protected String _providerClassName;
+  /** Reference to the X.509 factory. */
+  private CertificateFactory x509Factory;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param pathName the fully qualified path name of the file to process. */
+  public void setFile(String pathName)
+  {
+    this._certFileName = pathName;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  /* (non-Javadoc)
+   * @see gnu.classpath.tools.keytool.Command#setup()
+   */
+  void setup() throws Exception
+  {
+    setInputStreamParam(_certFileName);
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-cacert handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -file=" + _certFileName); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws CertificateException, KeyStoreException,
+      NoSuchAlgorithmException, IOException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    alias = getAliasFromFileName(_certFileName);
+    if (store.containsAlias(alias))
+      throw new IllegalArgumentException(Messages.getFormattedString("CACertCmd.0", //$NON-NLS-1$
+                                                                     alias));
+    x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
+    Certificate certificate = x509Factory.generateCertificate(inStream);
+    if (Configuration.DEBUG)
+      log.fine("certificate = " + certificate); //$NON-NLS-1$
+    store.setCertificateEntry(alias, certificate);
+    saveKeyStore();
+    if (verbose)
+      System.out.println(Messages.getFormattedString("CACertCmd.1", //$NON-NLS-1$
+                                                     new Object[] { _certFileName,
+                                                                    alias }));
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  /* (non-Javadoc)
+   * @see gnu.classpath.tools.keytool.Command#getParser()
+   */
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.CACERT_CMD, true);
+    result.setHeader(Messages.getString("CACertCmd.2")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("CACertCmd.3")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("CACertCmd.4")); //$NON-NLS-1$
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("CACertCmd.5"), //$NON-NLS-1$
+                           Messages.getString("CACertCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _certFileName = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("CACertCmd.7"), //$NON-NLS-1$
+                           Messages.getString("CACertCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("CACertCmd.9"), //$NON-NLS-1$
+                           Messages.getString("CACertCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("CACertCmd.11"), //$NON-NLS-1$
+                           Messages.getString("CACertCmd.12")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("CACertCmd.13"), //$NON-NLS-1$
+                           Messages.getString("CACertCmd.14")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("CACertCmd.15")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * Construct an Alias string from the name of the file containing the
+   * certificate to import. This method first removes the last dot (".")
+   * character and any subsequent characters from the input name, and then
+   * replaces any space and dot characters with underscores. For example the
+   * input string <code>brasil.gov.br.cert</code> will result in
+   * <code>brasil_gov_br</code> as its alias.
+   * 
+   * @param fileName the name of the file containing the CA certificate
+   * @return a string which can, and will, be used as the Alias of this CA
+   *         certificate.
+   */
+  private String getAliasFromFileName(String fileName)
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getAliasFromFileName", fileName); //$NON-NLS-1$
+    // get the basename
+    fileName = new File(fileName).getName();
+    // remove '.' if at start
+    if (fileName.startsWith(".")) //$NON-NLS-1$
+      fileName = fileName.substring(1);
+
+    // remove last \..+
+    int ndx = fileName.lastIndexOf('.');
+    if (ndx > 0)
+      fileName = fileName.substring(0, ndx);
+    // replace spaces and dots with underscores
+    char[] chars = fileName.toCharArray();
+    for (int i = 0; i < chars.length; i++)
+      {
+        char c = chars[i];
+        if (c == ' ' || c == '.')
+          chars[i] = '_';
+      }
+    String result = new String(chars);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getAliasFromFileName", result); //$NON-NLS-1$
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,475 @@
+/* CertReqCmd.java -- The certreq 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.getopt.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.security.util.Base64;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.x500.X500Principal;
+
+/**
+ * The <b>-certreq</b> keytool command handler is used to generate a Certificate
+ * Signing Request (CSR) in PKCS#10 format.
+ * <p>
+ * The ASN.1 specification of a CSR, as stated in RFC-2986 is as follows:
+ * <p>
+ * <pre>
+ * CertificationRequest ::= SEQUENCE {
+ *   certificationRequestInfo  CertificationRequestInfo,
+ *   signatureAlgorithm        AlgorithmIdentifier,
+ *   signature                 BIT STRING
+ * }
+ * 
+ * CertificationRequestInfo ::= SEQUENCE {
+ *   version           INTEGER -- v1(0)
+ *   subject           Name,
+ *   subjectPKInfo     SubjectPublicKeyInfo,
+ *   attributes    [0] IMPLICIT Attributes -- see note later
+ * }
+ * 
+ * SubjectPublicKeyInfo ::= SEQUENCE {
+ *   algorithm         AlgorithmIdentifier,
+ *   subjectPublicKey  BIT STRING
+ * }
+ * </pre>
+ * <b>IMPORTANT</b>: Some documentation (e.g. RSA examples) claims that the
+ * <code>attributes</code> field is <i>OPTIONAL</i> while <i>RFC-2986</i>
+ * implies the opposite. This implementation considers this field, by default,
+ * as <i>OPTIONAL</i>, unless the option <code>-attributes</code> is included
+ * on the command line.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-sigalg ALGORITHM</dt>
+ *      <dd>The canonical name of the digital signature algorithm to use for
+ *      signing the certificate. If this option is omitted, a default value will
+ *      be chosen based on the type of the private key associated with the
+ *      designated <i>Alias</i>. If the private key is a <code>DSA</code> one,
+ *      the value for the signature algorithm will be <code>SHA1withDSA</code>.
+ *      If on the other hand the private key is an <code>RSA</code> one, then
+ *      the tool will use <code>MD5withRSA</code> as the signature algorithm.
+ *      <p></dd>
+ *      
+ *      <dt>-file FILE_NAME</dt>
+ *      
+ *      <dt>-keypass PASSWORD</dt>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.
+ *      <p></dd>
+ *      
+ *      <dt>-attributes</dt>
+ *      <dd>Use this option to force the tool to encode a NULL DER value in the
+ *      CSR as the value of the Attributes field.</dd>
+ * </dl>
+ */
+class CertReqCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(CertReqCmd.class.getName());
+  private static final String ATTRIBUTES_OPT = "attributes"; //$NON-NLS-1$
+  protected String _alias;
+  protected String _sigAlgorithm;
+  protected String _certReqFileName;
+  protected String _password;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  protected boolean nullAttributes;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param alias the alias to use. */
+  public void setAlias(String alias)
+  {
+    this._alias = alias;
+  }
+
+  /**
+   * @param algorithm the canonical name of the digital signature algorithm to
+   *          use.
+   */
+  public void setSigalg(String algorithm)
+  {
+    this._sigAlgorithm = algorithm;
+  }
+
+  /** @param pathName the fully qualified path name of the file to process. */
+  public void setFile(String pathName)
+  {
+    this._certReqFileName = pathName;
+  }
+
+  /** @param password the (private) key password to use. */
+  public void setKeypass(String password)
+  {
+    this._password = password;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  /**
+   * @param flag whether to use, or not, a <code>NULL</code> DER value for
+   *          the certificate's Attributes field.
+   */
+  public void setAttributes(String flag)
+  {
+    this.nullAttributes = Boolean.valueOf(flag).booleanValue();
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setOutputStreamParam(_certReqFileName);
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    setAliasParam(_alias);
+    setKeyPasswordNoPrompt(_password);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-certreq handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -alias=" + alias); //$NON-NLS-1$
+        log.fine("  -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
+        log.fine("  -file=" + _certReqFileName); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+        log.fine("  -attributes=" + nullAttributes); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
+      UnsupportedCallbackException, UnrecoverableKeyException,
+      InvalidKeyException, SignatureException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    // 1. get the key entry and certificate chain associated to alias
+    Key privateKey = getAliasPrivateKey();
+    Certificate[] chain = store.getCertificateChain(alias);
+
+    // 2. get alias's DN and public key to use in the CSR
+    X509Certificate bottomCertificate = (X509Certificate) chain[0];
+    X500Principal aliasName = bottomCertificate.getIssuerX500Principal();
+    PublicKey publicKey = bottomCertificate.getPublicKey();
+
+    // 3. generate the CSR
+    setSignatureAlgorithmParam(_sigAlgorithm, privateKey);
+    byte[] derBytes = getCSR(aliasName, publicKey, (PrivateKey) privateKey);
+
+    // 4. encode it in base-64 and write it to outStream
+    String encoded = Base64.encode(derBytes, 0, derBytes.length, true);
+    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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java Thu Nov  8 16:56:19 2007
@@ -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 gnu.javax.security.auth.callback.ConsoleCallbackHandler;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.math.BigInteger;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.InvalidKeyException;
+import java.security.InvalidParameterException;
+import java.security.Key;
+import java.security.KeyPairGenerator;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.DSAKey;
+import java.security.interfaces.RSAKey;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.logging.Logger;
+import java.util.prefs.Preferences;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * A base class of the keytool command to facilitate implementation of concrete
+ * keytool Handlers.
+ */
+abstract class Command
+{
+  // Fields and constants -----------------------------------------------------
+
+  private static final Logger log = Logger.getLogger(Command.class.getName());
+  /** Default value for the ALIAS argument. */
+  private static final String DEFAULT_ALIAS = "mykey"; //$NON-NLS-1$
+  /** Default algorithm for key-pair generation. */
+  private static final String DEFAULT_KEY_ALGORITHM = "DSA"; //$NON-NLS-1$
+  /** Default DSA digital signature algorithm to use with DSA keys. */
+  private static final String DSA_SIGNATURE_ALGORITHM = "SHA1withDSA"; //$NON-NLS-1$
+  /** Default RSA digital signature algorithm to use with RSA keys. */
+  private static final String RSA_SIGNATURE_ALGORITHM = "MD5withRSA"; //$NON-NLS-1$
+  /** Default validity (in days) of newly generated certificates. */
+  private static final int DEFAULT_VALIDITY = 90;
+  /** OID of SHA1withDSA signature algorithm as stated in RFC-2459. */
+  protected static final OID SHA1_WITH_DSA = new OID("1.2.840.10040.4.3"); //$NON-NLS-1$
+  /** OID of MD2withRSA signature algorithm as stated in RFC-2459. */
+  private static final OID MD2_WITH_RSA = new OID("1.2.840.113549.1.1.2"); //$NON-NLS-1$
+  /** OID of MD5withRSA signature algorithm as stated in RFC-2459. */
+  private static final OID MD5_WITH_RSA = new OID("1.2.840.113549.1.1.4"); //$NON-NLS-1$
+  /** OID of SHA1withRSA signature algorithm as stated in RFC-2459. */
+  private static final OID SHA1_WITH_RSA = new OID("1.2.840.113549.1.1.5"); //$NON-NLS-1$
+  /** Number of milliseconds in one day. */
+  private static final long MILLIS_IN_A_DAY = 24 * 60 * 60 * 1000L;
+
+  /** The Alias to use. */
+  protected String alias;
+  /** The password characters protecting a Key Entry. */
+  protected char[] keyPasswordChars;
+  /** A security provider to add. */
+  protected Provider provider;
+  /** The key store type. */
+  protected String storeType;
+  /** The password characters protecting the key store. */
+  protected char[] storePasswordChars;
+  /** The key store URL. */
+  protected URL storeURL;
+  /** The input stream from the key store URL. */
+  protected InputStream storeStream;
+  /** The key store instance to use. */
+  protected KeyStore store;
+  /** The output stream the concrete handler will use. */
+  protected OutputStream outStream;
+  /** Whether we are printing to System.out. */
+  protected boolean systemOut;
+  /** The key-pair generation algorithm instance to use. */
+  protected KeyPairGenerator keyPairGenerator;
+  /** The digital signature algorithm instance to use. */
+  protected Signature signatureAlgorithm;
+  /** Validity period, in number of days, to use when generating certificates. */
+  protected int validityInDays;
+  /** The input stream the concrete handler will use. */
+  protected InputStream inStream;
+  /** Whether verbose output is required or not. */
+  protected boolean verbose;
+
+  /** MD5 hash to use when generating certificate fingerprints. */
+  private IMessageDigest md5 = new MD5();
+  /** SHA1 hash to use when generating certificate fingerprints. */
+  private IMessageDigest sha = new Sha160();
+  /** The new position of a user-defined provider if it is not already installed. */
+  private int providerNdx = -2;
+  /** The callback handler to use when needing to interact with user. */
+  private CallbackHandler handler;
+  /** The shutdown hook. */
+  private ShutdownHook shutdownThread;
+
+  // Constructor(s) -----------------------------------------------------------
+
+  protected Command()
+  {
+    super();
+    shutdownThread = new ShutdownHook();
+    Runtime.getRuntime().addShutdownHook(shutdownThread);
+  }
+
+  // Methods ------------------------------------------------------------------
+
+  /**
+   * A public method to allow using any keytool command handler programmatically
+   * by using a JavaBeans style of parameter(s) initialization. The user is
+   * assumed to have set individually the required options through their
+   * respective setters before invoking this method.
+   * <p>
+   * If an exception is encountered during the processing of the command, this
+   * implementation attempts to release any resources that may have been
+   * allocated at the time the exception occurs, before re-throwing that
+   * exception.
+   * 
+   * @throws Exception if an exception occurs during the processing of this
+   *           command. For a more comprehensive list of exceptions that may
+   *           occur, see the documentation of the {@link #setup()} and
+   *           {@link #start()} methods.
+   */
+  public void doCommand() throws Exception
+  {
+    try
+      {
+        setup();
+        start();
+      }
+    finally
+      {
+        teardown();
+        if (shutdownThread != null)
+          Runtime.getRuntime().removeShutdownHook(shutdownThread);
+      }
+  }
+
+  /**
+   * @param flag whether to use, or not, more verbose output while processing
+   *          the command.
+   */
+  public void setVerbose(String flag)
+  {
+    this.verbose = Boolean.valueOf(flag).booleanValue();
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  /**
+   * Given a potential sub-array of options for this concrete handler, starting
+   * at position <code>startIndex + 1</code>, potentially followed by other
+   * commands and their options, this method sets up this concrete command
+   * handler with its own options and returns the index of the first unprocessed
+   * argument in the array.
+   * <p>
+   * The general contract of this method is that it is invoked with the
+   * <code>startIndex</code> argument pointing to the keyword argument that
+   * uniquelly identifies the command itself; e.g. <code>-genkey</code> or
+   * <code>-list</code>, etc...
+   * 
+   * @param args an array of options for this handler and possibly other
+   *          commands and their options.
+   * @return the remaining un-processed <code>args</code>.
+   */
+  String[] processArgs(String[] args)
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
+    Parser cmdOptionsParser = getParser();
+    String[] result = cmdOptionsParser.parse(args);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "processArgs", result); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * Initialize this concrete command handler for later invocation of the
+   * {@link #start()} or {@link #doCommand()} methods.
+   * <p>
+   * Handlers usually initialize their local variables and resources within the
+   * scope of this call.
+   * 
+   * @throws IOException if an I/O related exception, such as opening an input
+   *           stream, occurs during the execution of this method.
+   * @throws UnsupportedCallbackException if a requested callback handler
+   *           implementation was not found, or was found but encountered an
+   *           exception during its processing.
+   * @throws ClassNotFoundException if a designated security provider class was
+   *           not found.
+   * @throws IllegalAccessException no 0-arguments constructor for the
+   *           designated security provider class was found.
+   * @throws InstantiationException the designated security provider class is
+   *           not instantiable.
+   * @throws KeyStoreException if an exception occurs during the instantiation
+   *           of the KeyStore.
+   * @throws CertificateException if a certificate related exception, such as
+   *           expiry, occurs during the loading of the KeyStore.
+   * @throws NoSuchAlgorithmException if no current security provider can
+   *           provide a needed algorithm referenced by the KeyStore or one of
+   *           its Key Entries or Certificates.
+   */
+  abstract void setup() throws Exception;
+
+  /**
+   * Do the real work this handler is supposed to do.
+   * <p>
+   * The code in this (abstract) class throws a <i>Not implemented yet</i>
+   * runtime exception. Concrete implementations MUST override this method.
+   * 
+   * @throws CertificateException If no concrete implementation was found for a
+   *           certificate Factory of a designated type. In this tool, the type
+   *           is usually X.509 v1.
+   * @throws KeyStoreException if a keys-store related exception occurs; e.g.
+   *           the key store has not been initialized.
+   * @throws IOException if an I/O related exception occurs during the process.
+   * @throws SignatureException if a digital signature related exception occurs.
+   * @throws InvalidKeyException if the genereated keys are invalid.
+   * @throws UnrecoverableKeyException if the password used to unlock a key in
+   *           the key store was invalid.
+   * @throws NoSuchAlgorithmException if a concrete implementation of an
+   *           algorithm used to store a Key Entry was not found at runtime.
+   * @throws UnsupportedCallbackException if a requested callback handler
+   *           implementation was not found, or was found but encountered an
+   *           exception during its processing.
+   */
+  void start() throws Exception
+  {
+    throw new RuntimeException("Not implemented yet"); //$NON-NLS-1$
+  }
+
+  /**
+   * Tear down the handler, releasing any resources which may have been
+   * allocated at setup time.
+   */
+  void teardown()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+    if (storeStream != null)
+      try
+        {
+          storeStream.close();
+        }
+      catch (IOException ignored)
+        {
+          if (Configuration.DEBUG)
+            log.fine("Exception while closing key store URL stream. Ignored: " //$NON-NLS-1$
+                     + ignored);
+        }
+
+    if (outStream != null)
+      {
+        try
+          {
+            outStream.flush();
+          }
+        catch (IOException ignored)
+          {
+          }
+
+        if (! systemOut)
+          try
+            {
+              outStream.close();
+            }
+          catch (IOException ignored)
+            {
+            }
+      }
+
+    if (inStream != null)
+      try
+        {
+          inStream.close();
+        }
+      catch (IOException ignored)
+        {
+        }
+
+    if (providerNdx > 0)
+      ProviderUtil.removeProvider(provider.getName());
+
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+  }
+
+  // parameter setup and validation methods -----------------------------------
+
+  /**
+   * @return a {@link Parser} that knows how to parse the concrete command's
+   *         options.
+   */
+  abstract Parser getParser();
+
+  /**
+   * Convenience method to setup the key store given its type, its password, its
+   * location and portentially a specialized security provider.
+   * <p>
+   * Calls the method with the same name and 5 arguments passing
+   * <code>false</code> to the first argument implying that no attempt to
+   * create the keystore will be made if one was not found at the designated
+   * location.
+   * 
+   * @param className the potentially null fully qualified class name of a
+   *          security provider to add at runtime, if no installed provider is
+   *          able to provide a key store implementation of the desired type.
+   * @param type the potentially null type of the key store to request from the
+   *          key store factory.
+   * @param password the potentially null password protecting the key store.
+   * @param url the URL of the key store.
+   */
+  protected void setKeyStoreParams(String className, String type,
+                                   String password, String url)
+      throws IOException, UnsupportedCallbackException, KeyStoreException,
+      NoSuchAlgorithmException, CertificateException
+  {
+    setKeyStoreParams(false, className, type, password, url);
+  }
+
+  /**
+   * Convenience method to setup the key store given its type, its password, its
+   * location and portentially a specialized security provider.
+   * 
+   * @param createIfNotFound if <code>true</code> then create the keystore if
+   *          it was not found; otherwise do not.
+   * @param className the potentially null fully qualified class name of a
+   *          security provider to add at runtime, if no installed provider is
+   *          able to provide a key store implementation of the desired type.
+   * @param type the potentially null type of the key store to request from the
+   *          key store factory.
+   * @param password the potentially null password protecting the key store.
+   * @param url the URL of the key store.
+   */
+  protected void setKeyStoreParams(boolean createIfNotFound, String className,
+                                   String type, String password, String url)
+      throws IOException, UnsupportedCallbackException, KeyStoreException,
+      NoSuchAlgorithmException, CertificateException
+  {
+    setProviderClassNameParam(className);
+    setKeystoreTypeParam(type);
+    setKeystoreURLParam(createIfNotFound, url, password);
+  }
+
+  /**
+   * Set a security provider class name to (install and) use for key store
+   * related operations.
+   * 
+   * @param className the possibly null, fully qualified class name of a
+   *          security provider to add, if it is not already installed, to the
+   *          set of available providers.
+   */
+  private void setProviderClassNameParam(String className)
+  {
+    if (Configuration.DEBUG)
+      log.fine("setProviderClassNameParam(" + className + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+    if (className != null && className.trim().length() > 0)
+      {
+        className = className.trim();
+        SecurityProviderInfo spi = ProviderUtil.addProvider(className);
+        provider = spi.getProvider();
+        if (provider == null)
+          {
+            if (Configuration.DEBUG)
+              log.fine("Was unable to add provider from class " + className);
+          }
+        providerNdx = spi.getPosition();
+      }
+  }
+
+  /**
+   * Set the type of key store to initialize, load and use.
+   * 
+   * @param type the possibly null type of the key store. if this argument is
+   *          <code>null</code>, or is an empty string, then this method sets
+   *          the type of the key store to be the default value returned from
+   *          the invocation of the {@link KeyStore#getDefaultType()} method.
+   *          For GNU Classpath this is <i>gkr</i> which stands for the "Gnu
+   *          KeyRing" specifications.
+   */
+  private void setKeystoreTypeParam(String type)
+  {
+    if (Configuration.DEBUG)
+      log.fine("setKeystoreTypeParam(" + type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+    if (type == null || type.trim().length() == 0)
+      storeType = KeyStore.getDefaultType();
+    else
+      storeType = type.trim();
+  }
+
+  /**
+   * Set the key password given a command line option argument. If no value was
+   * present on the command line then prompt the user to provide one.
+   * 
+   * @param password a possibly null key password gleaned from the command line.
+   * @throws IOException if an I/O related exception occurs.
+   * @throws UnsupportedCallbackException if no concrete implementation of a
+   *         password callback was found at runtime.
+   */
+  protected void setKeyPasswordParam(String password) throws IOException,
+      UnsupportedCallbackException
+  {
+    setKeyPasswordNoPrompt(password);
+    if (keyPasswordChars == null)
+      setKeyPasswordParam();
+  }
+
+  /**
+   * Set the Alias to use when associating Key Entries and Trusted Certificates
+   * in the current key store.
+   * 
+   * @param name the possibly null alias to use. If this arfument is
+   *          <code>null</code>, then a default value of <code>mykey</code>
+   *          will be used instead.
+   */
+  protected void setAliasParam(String name)
+  {
+    alias = name == null ? DEFAULT_ALIAS : name.trim();
+  }
+
+  /**
+   * Set the key password given a command line option argument.
+   * 
+   * @param password a possibly null key password gleaned from the command line.
+   */
+  protected void setKeyPasswordNoPrompt(String password)
+  {
+    if (password != null)
+      keyPasswordChars = password.toCharArray();
+  }
+
+  /**
+   * Prompt the user to provide a password to protect a Key Entry in the key
+   * store.
+   * 
+   * @throws IOException if an I/O related exception occurs.
+   * @throws UnsupportedCallbackException if no concrete implementation of a
+   *           password callback was found at runtime.
+   * @throws SecurityException if no password is available, even after prompting
+   *           the user.
+   */
+  private void setKeyPasswordParam() throws IOException,
+      UnsupportedCallbackException
+  {
+    String prompt = Messages.getFormattedString("Command.21", alias); //$NON-NLS-1$
+    PasswordCallback pcb = new PasswordCallback(prompt, false);
+    getCallbackHandler().handle(new Callback[] { pcb });
+    keyPasswordChars = pcb.getPassword();
+    pcb.clearPassword();
+    if (keyPasswordChars == null)
+      throw new SecurityException(Messages.getString("Command.23")); //$NON-NLS-1$
+  }
+
+  private void setKeystorePasswordParam(String password) throws IOException,
+      UnsupportedCallbackException
+  {
+    if (password != null)
+      storePasswordChars = password.toCharArray();
+    else // ask the user to provide one
+      {
+        String prompt = Messages.getString("Command.24"); //$NON-NLS-1$
+        PasswordCallback pcb = new PasswordCallback(prompt, false);
+        getCallbackHandler().handle(new Callback[] { pcb });
+        storePasswordChars = pcb.getPassword();
+        pcb.clearPassword();
+      }
+  }
+
+  /**
+   * Set the key store URL to use.
+   * 
+   * @param createIfNotFound when <code>true</code> an attempt to create a
+   *          keystore at the designated location will be made. If
+   *          <code>false</code> then no file creation is carried out, which
+   *          may cause an exception to be thrown later.
+   * @param url the full, or partial, URL to the keystore location.
+   * @param password an eventually null string to use when loading the keystore.
+   * @throws IOException
+   * @throws KeyStoreException
+   * @throws UnsupportedCallbackException
+   * @throws NoSuchAlgorithmException
+   * @throws CertificateException
+   */
+  private void setKeystoreURLParam(boolean createIfNotFound, String url,
+                                     String password) throws IOException,
+      KeyStoreException, UnsupportedCallbackException, NoSuchAlgorithmException,
+      CertificateException
+  {
+    if (Configuration.DEBUG)
+      log.fine("setKeystoreURLParam(" + url + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+    if (url == null || url.trim().length() == 0)
+      {
+        String userHome = SystemProperties.getProperty("user.home"); //$NON-NLS-1$
+        if (userHome == null || userHome.trim().length() == 0)
+          throw new InvalidParameterException(Messages.getString("Command.36")); //$NON-NLS-1$
+
+        url = userHome.trim() + "/.keystore"; //$NON-NLS-1$
+        // if it does not exist create it if required
+        if (createIfNotFound)
+          new File(url).createNewFile();
+        url = "file:" + url; //$NON-NLS-1$
+      }
+    else
+      {
+        url = url.trim();
+        if (url.indexOf(":") == -1) // if it does not exist create it //$NON-NLS-1$
+          {
+            if (createIfNotFound)
+              new File(url).createNewFile();
+          }
+        url = "file:" + url; //$NON-NLS-1$
+      }
+
+    boolean newKeyStore = false;
+    storeURL = new URL(url);
+    storeStream = storeURL.openStream();
+    if (storeStream.available() == 0)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Store is empty. Will use <null> when loading, to create it"); //$NON-NLS-1$
+        newKeyStore = true;
+      }
+
+    try
+      {
+        store = KeyStore.getInstance(storeType);
+      }
+    catch (KeyStoreException x)
+      {
+        if (provider != null)
+          throw x;
+
+        if (Configuration.DEBUG)
+          log.fine("Exception while getting key store with default provider(s)." //$NON-NLS-1$
+                   + " Will prompt user for another provider and continue"); //$NON-NLS-1$
+        String prompt = Messages.getString("Command.40"); //$NON-NLS-1$
+        NameCallback ncb = new NameCallback(prompt);
+        getCallbackHandler().handle(new Callback[] { ncb });
+        String className = ncb.getName();
+        setProviderClassNameParam(className); // we may have a Provider
+        if (provider == null)
+          {
+            x.fillInStackTrace();
+            throw x;
+          }
+        // try again
+        store = KeyStore.getInstance(storeType, provider);
+      }
+
+    setKeystorePasswordParam(password);
+
+    // now we have a KeyStore instance. load it
+    // KeyStore public API claims: "...In order to create an empty keystore,
+    // you pass null as the InputStream argument to the load method.
+    if (newKeyStore)
+      store.load(null, storePasswordChars);
+    else
+      store.load(storeStream, storePasswordChars);
+
+    // close the stream
+    try
+    {
+      storeStream.close();
+      storeStream = null;
+    }
+    catch (IOException x)
+    {
+      if (Configuration.DEBUG)
+        log.fine("Exception while closing the key store input stream: " + x //$NON-NLS-1$
+                 + ". Ignore"); //$NON-NLS-1$
+    }
+  }
+
+  protected void setOutputStreamParam(String fileName) throws SecurityException,
+      IOException
+  {
+    if (fileName == null || fileName.trim().length() == 0)
+      {
+        outStream = System.out;
+        systemOut = true;
+      }
+    else
+      {
+        fileName = fileName.trim();
+        File outFile = new File(fileName);
+        if (! outFile.exists())
+          {
+            boolean ok = outFile.createNewFile();
+            if (!ok)
+              throw new InvalidParameterException(Messages.getFormattedString("Command.19", //$NON-NLS-1$
+                                                                              fileName));
+          }
+        else
+          {
+            if (! outFile.isFile())
+              throw new InvalidParameterException(Messages.getFormattedString("Command.42", //$NON-NLS-1$
+                                                                              fileName));
+            if (! outFile.canWrite())
+              throw new InvalidParameterException(Messages.getFormattedString("Command.44", //$NON-NLS-1$
+                                                                              fileName));
+          }
+        outStream = new FileOutputStream(outFile);
+      }
+  }
+
+  protected void setInputStreamParam(String fileName)
+      throws FileNotFoundException
+  {
+    if (fileName == null || fileName.trim().length() == 0)
+      inStream = System.in;
+    else
+      {
+        fileName = fileName.trim();
+        File inFile = new File(fileName);
+        if (! (inFile.exists() && inFile.isFile() && inFile.canRead()))
+          throw new InvalidParameterException(Messages.getFormattedString("Command.46", //$NON-NLS-1$
+                                                                          fileName));
+        inStream = new FileInputStream(inFile);
+      }
+  }
+
+  /**
+   * Set both the key-pair generation algorithm, and the digital signature
+   * algorithm instances to use when generating new entries.
+   * 
+   * @param kpAlg the possibly null name of a key-pair generator algorithm.
+   *          if this argument is <code>null</code> or is an empty string, the
+   *          "DSS" algorithm will be used.
+   * @param sigAlg the possibly null name of a digital signature algorithm.
+   *          If this argument is <code>null</code> or is an empty string, this
+   *          method uses the "SHA1withDSA" (Digital Signature Standard, a.k.a.
+   *          DSA, with the Secure Hash Algorithm function) as the default
+   *          algorithm if, and only if, the key-pair generation algorithm ends
+   *          up being "DSS"; otherwise, if the key-pair generation algorithm
+   *          was "RSA", then the "MD5withRSA" signature algorithm will be used.
+   *          If the key-pair generation algorithm is neither "DSS" (or its
+   *          alias "DSA"), nor is it "RSA", then an exception is thrown.
+   * @throws NoSuchAlgorithmException if no concrete implementation of the
+   *           designated algorithm is available.
+   */
+  protected void setAlgorithmParams(String kpAlg, String sigAlg)
+      throws NoSuchAlgorithmException
+  {
+    if (kpAlg == null || kpAlg.trim().length() == 0)
+      kpAlg = DEFAULT_KEY_ALGORITHM;
+    else
+      kpAlg = kpAlg.trim().toLowerCase();
+
+    keyPairGenerator = KeyPairGenerator.getInstance(kpAlg);
+
+    if (sigAlg == null || sigAlg.trim().length() == 0)
+      if (kpAlg.equalsIgnoreCase(Registry.DSS_KPG)
+          || kpAlg.equalsIgnoreCase(Registry.DSA_KPG))
+        sigAlg = DSA_SIGNATURE_ALGORITHM;
+      else if (kpAlg.equalsIgnoreCase(Registry.RSA_KPG))
+        sigAlg = RSA_SIGNATURE_ALGORITHM;
+      else
+        throw new IllegalArgumentException(
+            Messages.getFormattedString("Command.20", //$NON-NLS-1$
+                                        new String[] { sigAlg, kpAlg }));
+    else
+      sigAlg = sigAlg.trim().toLowerCase();
+
+    signatureAlgorithm = Signature.getInstance(sigAlg);
+  }
+
+  /**
+   * Set the signature algorithm to use when digitally signing private keys,
+   * certificates, etc...
+   * <p>
+   * If the designated algorithm name is <code>null</code> or is an empty
+   * string, this method checks the private key (the second argument) and based
+   * on its type decides which algorithm to use. The keytool public
+   * specification states that if the private key is a DSA key, then the
+   * signature algorithm will be <code>SHA1withDSA</code>, otherwise if it is
+   * an RSA private key, then the signature algorithm will be
+   * <code>MD5withRSA</code>. If the private key is neither a private DSA nor
+   * a private RSA key, then this method throws an
+   * {@link IllegalArgumentException}.
+   * 
+   * @param algorithm the possibly null name of a digital signature algorithm.
+   * @param privateKey an instance of a private key to use as a fal-back option
+   *          when <code>algorithm</code> is invalid.
+   * @throws NoSuchAlgorithmException if no concrete implementation of the
+   *           designated, or default, signature algorithm is available.
+   */
+  protected void setSignatureAlgorithmParam(String algorithm, Key privateKey)
+      throws NoSuchAlgorithmException
+  {
+    if (algorithm == null || algorithm.trim().length() == 0)
+      if (privateKey instanceof DSAKey)
+        algorithm = DSA_SIGNATURE_ALGORITHM;
+      else if (privateKey instanceof RSAKey)
+        algorithm = RSA_SIGNATURE_ALGORITHM;
+      else
+        throw new InvalidParameterException(Messages.getString("Command.48")); //$NON-NLS-1$
+    else
+      algorithm = algorithm.trim();
+
+    signatureAlgorithm = Signature.getInstance(algorithm);
+  }
+
+  /**
+   * Set the validity period, in number of days, to use when issuing new
+   * certificates.
+   * 
+   * @param days the number of days, as a string, the generated certificate will
+   *          be valid for, starting from today's date. if this argument is
+   *          <code>null</code>, a default value of <code>90</code> days
+   *          will be used.
+   * @throws NumberFormatException if the designated string is not a decimal
+   *           integer.
+   * @throws InvalidParameterException if the integer value of the non-null
+   *           string is not greater than zero.
+   */
+  protected void setValidityParam(String days)
+  {
+    if (days == null || days.trim().length() == 0)
+      validityInDays = DEFAULT_VALIDITY;
+    else
+      {
+        days = days.trim();
+        validityInDays = Integer.parseInt(days);
+        if (validityInDays < 1)
+          throw new InvalidParameterException(Messages.getString("Command.51")); //$NON-NLS-1$
+      }
+  }
+
+  /**
+   * RFC-2459 (http://rfc.net/rfc2459.html) fully describes the structure and
+   * semantics of X.509 certificates. The ASN.1 structures below are gleaned
+   * from that reference.
+   * 
+   * <pre>
+   *  Certificate ::= SEQUENCE {
+   *    tbsCertificate      TBSCertificate,
+   *    signatureAlgorithm  AlgorithmIdentifier,
+   *    signatureValue      BIT STRING
+   *  }
+   *  
+   *  TBSCertificate ::= SEQUENCE {
+   *    version           [0] EXPLICIT Version DEFAULT v1,
+   *    serialNumber          CertificateSerialNumber,
+   *    signature             AlgorithmIdentifier,
+   *    issuer                Name,
+   *    validity              Validity,
+   *    subject               Name,
+   *    subjectPublicKeyInfo  SubjectPublicKeyInfo
+   *  }
+   *  
+   *  Version ::= INTEGER { v1(0), v2(1), v3(2) }
+   *  
+   *  CertificateSerialNumber ::= INTEGER
+   *  
+   *  Validity ::= SEQUENCE {
+   *    notBefore  Time,
+   *    notAfter   Time
+   *  }
+   *  
+   *  Time ::= CHOICE {
+   *    utcTime      UTCTime,
+   *    generalTime  GeneralizedTime
+   *  }
+   *  
+   *  UniqueIdentifier ::= BIT STRING
+   *  
+   *  SubjectPublicKeyInfo ::= SEQUENCE {
+   *    algorithm         AlgorithmIdentifier,
+   *    subjectPublicKey  BIT STRING
+   *  }
+   * </pre>
+   * 
+   * @param distinguishedName the X.500 Distinguished Name to use as both the
+   *          Issuer and Subject of the self-signed certificate to generate.
+   * @param publicKey the public key of the issuer/subject.
+   * @param privateKey the private key of the issuer/signer.
+   * @return the DER encoded form of a self-signed X.509 v1 certificate.
+   * @throws IOException If an I/O related exception occurs during the process.
+   * @throws SignatureException If a digital signature related exception occurs.
+   * @throws InvalidKeyException if the designated private key is invalid.
+   * @throws InvalidParameterException if the concrete signature algorithm does
+   *           not know its name, no OID is known/supported for that name, or we
+   *           were unable to match the name to a known string for which we can
+   *           use a standard OID.
+   */
+  protected byte[] getSelfSignedCertificate(X500DistinguishedName distinguishedName,
+                                            PublicKey publicKey,
+                                            PrivateKey privateKey)
+      throws IOException, SignatureException, InvalidKeyException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getSelfSignedCertificate", //$NON-NLS-1$
+                   new Object[] { distinguishedName, publicKey, privateKey });
+    byte[] versionBytes = new DERValue(DER.INTEGER, BigInteger.ZERO).getEncoded();
+    DERValue derVersion = new DERValue(DER.CONSTRUCTED | DER.CONTEXT | 0,
+                                       versionBytes.length, versionBytes, null);
+
+    // NOTE (rsn): the next 3 lines should be atomic but they're not.
+    Preferences prefs = Preferences.systemNodeForPackage(this.getClass());
+    int lastSerialNumber = prefs.getInt(Main.LAST_SERIAL_NUMBER, 0) + 1;
+    prefs.putInt(Main.LAST_SERIAL_NUMBER, lastSerialNumber);
+    DERValue derSerialNumber = new DERValue(DER.INTEGER,
+                                            BigInteger.valueOf(lastSerialNumber));
+
+    OID signatureID = getSignatureAlgorithmOID();
+    DERValue derSignatureID = new DERValue(DER.OBJECT_IDENTIFIER, signatureID);
+    ArrayList signature = new ArrayList(1);
+    signature.add(derSignatureID);
+    // rfc-2459 states the following:
+    //
+    // for the DSA signature:
+    // ...Where the id-dsa-with-sha1 algorithm identifier appears as the
+    // algorithm field in an AlgorithmIdentifier, the encoding shall omit
+    // the parameters field.  That is, the AlgorithmIdentifier shall be a
+    // SEQUENCE of one component - the OBJECT IDENTIFIER id-dsa-with-sha1.
+    // 
+    // for RSA signatures:
+    // ...When any of these three OIDs (i.e. xxxWithRSAEncryption) appears
+    // within the ASN.1 type AlgorithmIdentifier, the parameters component of
+    // that type shall be the ASN.1 type NULL.
+    if (! signatureID.equals(SHA1_WITH_DSA))
+      signature.add(new DERValue(DER.NULL, null));
+
+    DERValue derSignature = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+                                         signature);
+
+    DERValue derIssuer = new DERReader(distinguishedName.getDer()).read();
+
+    long notBefore = System.currentTimeMillis();
+    long notAfter = notBefore + validityInDays * MILLIS_IN_A_DAY;
+    
+    ArrayList validity = new ArrayList(2);
+    validity.add(new DERValue(DER.UTC_TIME, new Date(notBefore)));
+    validity.add(new DERValue(DER.UTC_TIME, new Date(notAfter)));
+    DERValue derValidity = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+                                        validity);
+
+    // for a self-signed certificate subject and issuer are identical
+    DERValue derSubject = derIssuer;
+
+    DERValue derSubjectPublicKeyInfo = new DERReader(publicKey.getEncoded()).read();
+
+    ArrayList tbsCertificate = new ArrayList(7);
+    tbsCertificate.add(derVersion);
+    tbsCertificate.add(derSerialNumber);
+    tbsCertificate.add(derSignature);
+    tbsCertificate.add(derIssuer);
+    tbsCertificate.add(derValidity);
+    tbsCertificate.add(derSubject);
+    tbsCertificate.add(derSubjectPublicKeyInfo);
+    DERValue derTBSCertificate = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+                                              tbsCertificate);
+
+    // The 'signature' field MUST contain the same algorithm identifier as the
+    // 'signatureAlgorithm' field in the sequence Certificate.
+    DERValue derSignatureAlgorithm = derSignature;
+
+    signatureAlgorithm.initSign(privateKey);
+    signatureAlgorithm.update(derTBSCertificate.getEncoded());
+    byte[] sigBytes = signatureAlgorithm.sign();
+    DERValue derSignatureValue = new DERValue(DER.BIT_STRING,
+                                              new BitString(sigBytes));
+
+    ArrayList certificate = new ArrayList(3);
+    certificate.add(derTBSCertificate);
+    certificate.add(derSignatureAlgorithm);
+    certificate.add(derSignatureValue);
+    DERValue derCertificate = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
+                                           certificate);
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    DERWriter.write(baos, derCertificate);
+    byte[] result = baos.toByteArray();
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getSelfSignedCertificate"); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * This method attempts to find, and return, an OID representing the digital
+   * signature algorithm used to sign the certificate. The OIDs returned are
+   * those described in RFC-2459. They are listed here for the sake of
+   * completness.
+   * 
+   * <pre>
+   *  id-dsa-with-sha1 OBJECT IDENTIFIER ::= {
+   *    iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3
+   *  }
+   *  
+   *  md2WithRSAEncryption OBJECT IDENTIFIER ::= {
+   *    iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 2
+   *  }
+   *  
+   *  md5WithRSAEncryption OBJECT IDENTIFIER ::= {
+   *    iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 4
+   *  }
+   *  
+   *  sha-1WithRSAEncryption OBJECT IDENTIFIER ::= {
+   *    iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 5
+   *  }
+   * </pre>
+   * 
+   * <b>IMPORTANT</b>: This method checks the signature algorithm name against
+   * (a) The GNU algorithm implementation's name, and (b) publicly referenced
+   * names of the same algorithm. In other words this search is not
+   * comprehensive and may fail for uncommon names of the same algorithms.
+   * 
+   * @return the OID of the signature algorithm in use.
+   * @throws InvalidParameterException if the concrete signature algorithm does
+   *           not know its name, no OID is known/supported for that name, or we
+   *           were unable to match the name to a known string for which we can
+   *           return an OID.
+   */
+  protected OID getSignatureAlgorithmOID()
+  {
+    String algorithm = signatureAlgorithm.getAlgorithm();
+    // if we already have a non-null signature then the name was valid.  the
+    // only case where algorithm is invalid would be if the implementation is
+    // flawed.  check anyway
+    if (algorithm == null || algorithm.trim().length() == 0)
+      throw new InvalidParameterException(Messages.getString("Command.52")); //$NON-NLS-1$
+
+    algorithm = algorithm.trim();
+    if (algorithm.equalsIgnoreCase(Registry.DSS_SIG)
+        || algorithm.equalsIgnoreCase("SHA1withDSA")) //$NON-NLS-1$
+      return SHA1_WITH_DSA;
+    
+    if (algorithm.equalsIgnoreCase(Registry.RSA_PKCS1_V1_5_SIG + "-" //$NON-NLS-1$
+                                   + Registry.MD2_HASH)
+        || algorithm.equalsIgnoreCase("MD2withRSA")) //$NON-NLS-1$
+      return MD2_WITH_RSA;
+
+    if (algorithm.equalsIgnoreCase(Registry.RSA_PKCS1_V1_5_SIG + "-" //$NON-NLS-1$
+                                   + Registry.MD5_HASH)
+        || algorithm.equalsIgnoreCase("MD5withRSA") //$NON-NLS-1$
+        || algorithm.equalsIgnoreCase("rsa")) //$NON-NLS-1$
+      return MD5_WITH_RSA;
+
+    if (algorithm.equalsIgnoreCase(Registry.RSA_PKCS1_V1_5_SIG + "-" //$NON-NLS-1$
+                                   + Registry.SHA160_HASH)
+        || algorithm.equalsIgnoreCase("SHA1withRSA")) //$NON-NLS-1$
+      return SHA1_WITH_RSA;
+
+    throw new InvalidParameterException(Messages.getFormattedString("Command.60", //$NON-NLS-1$
+                                                                    algorithm));
+  }
+
+  /**
+   * Saves the key store using the designated password. This operation is called
+   * by handlers if/when the key store password has changed, or amendements have
+   * been made to the contents of the store; e.g. addition of a new Key Entry or
+   * a Trusted Certificate.
+   * 
+   * @param password the password protecting the key store.
+   * @throws IOException if an I/O related exception occurs during the process.
+   * @throws CertificateException if any of the certificates in the current key
+   *           store could not be persisted.
+   * @throws NoSuchAlgorithmException if a required data integrity algorithm
+   *           implementation was not found.
+   * @throws KeyStoreException if the key store has not been loaded previously.
+   */
+  protected void saveKeyStore(char[] password) throws IOException,
+      KeyStoreException, NoSuchAlgorithmException, CertificateException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
+    URLConnection con = storeURL.openConnection();
+    con.setDoOutput(true);
+    con.setUseCaches(false);
+    OutputStream out = con.getOutputStream();
+    if (verbose)
+      System.out.println(Messages.getFormattedString("Command.63", storeURL.getPath())); //$NON-NLS-1$
+
+    store.store(out, password);
+    out.flush();
+    out.close();
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
+  }
+
+  /**
+   * Convenience method. Calls the method with the same name passing it the
+   * same password characters used to initially load the key-store. 
+   * 
+   * @throws IOException if an I/O related exception occurs during the process.
+   * @throws KeyStoreException if the key store has not been loaded previously.
+   * @throws NoSuchAlgorithmException if a required data integrity algorithm
+   *           implementation was not found.
+   * @throws CertificateException if any of the certificates in the current key
+   *           store could not be persisted.
+   */
+  protected void saveKeyStore() throws IOException, KeyStoreException,
+      NoSuchAlgorithmException, CertificateException
+  {
+    saveKeyStore(storePasswordChars);
+  }
+
+  /**
+   * Prints a human-readable form of the designated certificate to a designated
+   * {@link PrintWriter}.
+   * 
+   * @param certificate the certificate to process.
+   * @param writer where to print it.
+   * @throws CertificateEncodingException if an exception occurs while obtaining
+   *           the DER encoded form <code>certificate</code>.
+   */
+  protected void printVerbose(Certificate certificate, PrintWriter writer)
+      throws CertificateEncodingException
+  {
+    X509Certificate x509 = (X509Certificate) certificate;
+    writer.println(Messages.getFormattedString("Command.66", x509.getSubjectDN())); //$NON-NLS-1$
+    writer.println(Messages.getFormattedString("Command.67", x509.getIssuerDN())); //$NON-NLS-1$
+    writer.println(Messages.getFormattedString("Command.68", x509.getSerialNumber())); //$NON-NLS-1$
+    writer.println(Messages.getFormattedString("Command.69", x509.getNotBefore())); //$NON-NLS-1$
+    writer.println(Messages.getFormattedString("Command.70", x509.getNotAfter())); //$NON-NLS-1$
+    writer.println(Messages.getString("Command.71")); //$NON-NLS-1$
+    byte[] derBytes = certificate.getEncoded();
+    writer.println(Messages.getFormattedString("Command.72", digest(md5, derBytes))); //$NON-NLS-1$
+    writer.println(Messages.getFormattedString("Command.73", digest(sha, derBytes))); //$NON-NLS-1$
+  }
+
+  /**
+   * Convenience method. Prints a human-readable form of the designated
+   * certificate to <code>System.out</code>.
+   * 
+   * @param certificate the certificate to process.
+   * @throws CertificateEncodingException if an exception occurs while obtaining
+   *           the DER encoded form <code>certificate</code>.
+   */
+  protected void printVerbose(Certificate certificate)
+      throws CertificateEncodingException
+  {
+    printVerbose(certificate, new PrintWriter(System.out, true));
+  }
+
+  /**
+   * Digest the designated contents with MD5 and return a string representation
+   * suitable for use as a fingerprint; i.e. sequence of hexadecimal pairs of
+   * characters separated by a colon.
+   * 
+   * @param contents the non-null contents to digest.
+   * @return a sequence of hexadecimal pairs of characters separated by colons.
+   */
+  protected String digestWithMD5(byte[] contents)
+  {
+    return digest(md5, contents);
+  }
+
+  private String digest(IMessageDigest hash, byte[] encoded)
+  {
+    hash.update(encoded);
+    byte[] b = hash.digest();
+    StringBuilder sb = new StringBuilder().append(Util.toString(b, 0, 1));
+    for (int i = 1; i < b.length; i++)
+      sb.append(":").append(Util.toString(b, i, 1)); //$NON-NLS-1$
+
+    String result = sb.toString();
+    return result;
+  }
+
+  /**
+   * Ensure that the currently set Alias is contained in the currently set key
+   * store; otherwise throw an exception.
+   * 
+   * @throws KeyStoreException if the keystore has not been loaded.
+   * @throws IllegalArgumentException if the currently set alias is not known to
+   *           the currently set key store.
+   */
+  protected void ensureStoreContainsAlias() throws KeyStoreException
+  {
+    if (! store.containsAlias(alias))
+      throw new IllegalArgumentException(Messages.getFormattedString("Command.75", //$NON-NLS-1$
+                                                                     alias));
+  }
+
+  /**
+   * Ensure that the currently set Alias is associated with a Key Entry in the
+   * currently set key store; otherwise throw an exception.
+   * 
+   * @throws KeyStoreException if the keystore has not been loaded.
+   * @throws SecurityException if the currently set alias is not a Key Entry in
+   *           the currently set key store.
+   */
+  protected void ensureAliasIsKeyEntry() throws KeyStoreException
+  {
+    if (! store.isKeyEntry(alias))
+      throw new SecurityException(Messages.getFormattedString("Command.77", //$NON-NLS-1$
+                                                              alias));
+  }
+
+  protected Key getAliasPrivateKey() throws KeyStoreException,
+      NoSuchAlgorithmException, IOException, UnsupportedCallbackException,
+      UnrecoverableKeyException
+  {
+    ensureAliasIsKeyEntry();
+    Key result;
+    if (keyPasswordChars == null)
+      try
+        {
+          result = store.getKey(alias, storePasswordChars);
+          // it worked. assign to keyPasswordChars for later use
+          keyPasswordChars = storePasswordChars;
+        }
+      catch (UnrecoverableKeyException x)
+        {
+          // prompt the user to provide one
+          setKeyPasswordParam();
+          result = store.getKey(alias, keyPasswordChars);
+        }
+    else
+      result = store.getKey(alias, keyPasswordChars);
+
+    return result;
+  }
+
+  /**
+   * Return a CallbackHandler which uses the Console (System.in and System.out)
+   * for interacting with the user.
+   * <p>
+   * This method first finds all currently installed security providers capable
+   * of providing such service and then in turn attempts to instantiate the
+   * handler from those providers. As soon as one provider returns a non-null
+   * instance of the callback handler, the search stops and that instance is
+   * set to be used from now on.
+   * <p>
+   * If no installed providers were found, this method falls back on the GNU
+   * provider, by-passing the Security search mechanism. The default console
+   * callback handler implementation is {@link 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();
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java Thu Nov  8 16:56:19 2007
@@ -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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-delete</b> keytool command handler is used to delete from the key
+ * store the entry associated with a designated alias.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class DeleteCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(DeleteCmd.class.getName());
+  protected String _alias;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param alias the alias to use. */
+  public void setAlias(String alias)
+  {
+    this._alias = alias;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    setTheAlias(_alias);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-delete handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -alias=" + alias); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws KeyStoreException, NoSuchAlgorithmException,
+      CertificateException, IOException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    ensureStoreContainsAlias();
+    store.deleteEntry(alias);
+    saveKeyStore();
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.DELETE_CMD, true);
+    result.setHeader(Messages.getString("DeleteCmd.18")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("DeleteCmd.17")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("DeleteCmd.16")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("DeleteCmd.15"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.14")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("DeleteCmd.13"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.12")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("DeleteCmd.11"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("DeleteCmd.9"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("DeleteCmd.7"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("DeleteCmd.5")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * Set the alias to delete from the key store.
+   * <p>
+   * Unlike in other keytool handlers, the default value (<i>mykey</i>) for the
+   * Alias is not used. Instead, if an alias was not found on the command line,
+   * the user is prompted to enter one.
+   * 
+   * @param anAlias a possibly null Alias gleaned from the command line.
+   * @throws IOException if an I/O related exception occurs during the process.
+   * @throws UnsupportedCallbackException if no implementation of a password
+   *           callback handler was found.
+   */
+  private void setTheAlias(String anAlias) throws IOException,
+      UnsupportedCallbackException
+  {
+    if (anAlias == null || anAlias.trim().length() == 0)
+      {
+        String prompt = Messages.getString("DeleteCmd.19"); //$NON-NLS-1$
+        NameCallback ncb = new NameCallback(prompt);
+        getCallbackHandler().handle(new Callback[] { ncb });
+        anAlias = ncb.getName();
+        if (anAlias == null || anAlias.trim().length() == 0)
+          throw new SecurityException(Messages.getString("DeleteCmd.20")); //$NON-NLS-1$
+      }
+    alias = anAlias.trim();
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,328 @@
+/* ExportCmd.java -- The export 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.getopt.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.Base64;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.KeyStoreException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.util.logging.Logger;
+
+/**
+ * The <b>-export</b> keytool command handler is used to read the certificate
+ * associated with a designated alias from the key store, and write it to a
+ * designated file.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-file FILE_NAME</dt>
+ *      <dd>The fully qualified path of the file where the certificate will be
+ *      exported to. If omitted, STDOUT will be used instead.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-rfc</dt>
+ *      <dd>Use RFC-1421 specifications when encoding the output.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Output the certificate in binary DER encoding. This is the default
+ *      output format of the command if neither <code>-rfc</code> nor
+ *      <code>-v</code> options were detected on the command line. If both this
+ *      option and the <code>-rfc</code> option are detected on the command
+ *      line, the tool will opt for the RFC-1421 style encoding.</dd>
+ * </dl>
+ */
+class ExportCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(ExportCmd.class.getName());
+  protected String _alias;
+  protected String _certFileName;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  protected boolean rfc;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param alias the alias to use. */
+  public void setAlias(String alias)
+  {
+    this._alias = alias;
+  }
+
+  /** @param pathName the fully qualified path name of the file to process. */
+  public void setFile(String pathName)
+  {
+    this._certFileName = pathName;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  /**
+   * @param flag whether to use, or not, RFC-1421 format when exporting the
+   *          certificate(s).
+   */
+  public void setRfc(String flag)
+  {
+    this.rfc = Boolean.valueOf(flag).booleanValue();
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setOutputStreamParam(_certFileName);
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    setAliasParam(_alias);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-export handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -alias=" + alias); //$NON-NLS-1$
+        log.fine("  -file=" + _certFileName); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -rfc=" + rfc); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws KeyStoreException, CertificateEncodingException,
+      IOException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    ensureStoreContainsAlias();
+    Certificate certificate;
+    if (store.isCertificateEntry(alias))
+      {
+        if (Configuration.DEBUG)
+          log.fine("Alias [" + alias + "] is a trusted certificate"); //$NON-NLS-1$ //$NON-NLS-2$
+        certificate = store.getCertificate(alias);
+      }
+    else
+      {
+        if (Configuration.DEBUG)
+          log.fine("Alias [" + alias + "] is a key entry"); //$NON-NLS-1$ //$NON-NLS-2$
+        Certificate[] chain = store.getCertificateChain(alias);
+        certificate = chain[0];
+      }
+
+    byte[] derBytes = certificate.getEncoded();
+    if (rfc)
+      {
+        String encoded = Base64.encode(derBytes, 0, derBytes.length, true);
+        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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,603 @@
+/* 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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.util.Util;
+import gnu.java.security.x509.X500DistinguishedName;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.TextInputCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-genkey</b> keytool command handler is used to generate a key pair (a
+ * public, and associated private keys). It then generates a self-signed X509 v1
+ * certificate (authenticating the public key) and stores this certificate and
+ * the private key in the key store associating both to a designated alias.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-keyalg ALGORITHM</dt>
+ *      <dd>Use this option to specify the canonical name of the key-pair
+ *      generation algorithm. The default value for this option is
+ *      <code>DSS</code> (a synonym for the Digital Signature Algorithm also
+ *      known as <code>DSA</code>).
+ *      <p></dd>
+ *      
+ *      <dt>-keysize KEY_SIZE</dt>
+ *      <dd>Use this option to specify the number of bits of the shared modulus
+ *      (for both the public and private keys) to use when generating new keys.
+ *      A default value of <code>1024</code> will be used if this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-sigalg ALGORITHM</dt>
+ *      <dd>The canonical name of the digital signature algorithm to use for
+ *      signing certificates. If this option is omitted, a default value will be
+ *      chosen based on the type of the key-pair; i.e. the algorithm that ends
+ *      up being used by the <code>-keyalg</code> option. If the key-pair
+ *      generation algorithm is <code>DSA</code>, the value for the signature
+ *      algorithm will be <code>SHA1withDSA</code>. If on the other hand the
+ *      key-pair generation algorithm is <code>RSA</code>, then the tool will
+ *      use <code>MD5withRSA</code> as the signature algorithm.
+ *      <p></dd>
+ *      
+ *      <dt>-dname NAME</dt>
+ *      <dd>This a mandatory value for this command. If this option is omitted
+ *      the tool will prompt you to enter a <i>Distinguished Name</i> to use as
+ *      both the <i>Owner</i> and <i>Issuer</i> of the generated self-signed
+ *      certificate.
+ *      <p>
+ *      The syntax of a valid value for this option MUST follow RFC-2253
+ *      specifications. Namely the following components (with their accepted
+ *      meaning) will be recognized. Note that the component name is case-
+ *      insensitive:
+ *      <dl>
+ *              <dt>CN</dt>
+ *              <dd>The Common Name; e.g. "host.domain.com"</dd>
+ *              
+ *              <dt>OU</dt>
+ *              <dd>The Organizational Unit; e.g. "IT Department"</dd>
+ *              
+ *              <dt>O</dt>
+ *              <dd>The Organization Name; e.g. "The Sample Company"</dd>
+ *              
+ *              <dt>L</dt>
+ *              <dd>The Locality Name; e.g. "Sydney"</dd>
+ *              
+ *              <dt>ST</dt>
+ *              <dd>The State Name; e.g. "New South Wales"</dd>
+ *              
+ *              <dt>C</dt>
+ *              <dd>The 2-letter Country identifier; e.g. "AU"</dd>
+ *      </dl>
+ *      <p>
+ *      When specified with a <code>-dname</code> option, each pair of component
+ *      / value will be separated from the other with a comma. Each component
+ *      and value pair MUST be separated by an equal sign. For example, the
+ *      following is a valid DN value:
+ *      <pre>
+ *        CN=host.domain.com, O=The Sample Company, L=Sydney, ST=NSW, C=AU
+ *      </pre>
+ *      If this option is omitted, the tool will prompt you to enter the
+ *      information through the console.
+ *      <p></dd>
+ *      
+ *      <dt>-keypass PASSWORD</dt>
+ *      <dd>Use this option to specify the password which the tool will use to
+ *      protect the newly created Key Entry.
+ *      <p>
+ *      If this option is omitted, you will be prompted to provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-validity DAY_COUNT</dt>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class GenKeyCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(GenKeyCmd.class.getName());
+  /** Default key size in bits. */
+  private static final int DEFAULT_KEY_SIZE = 1024;
+
+  protected String _alias;
+  protected String _keyAlgorithm;
+  protected String _keySizeStr;
+  protected String _sigAlgorithm;
+  protected String _dName;
+  protected String _password;
+  protected String _validityStr;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  private int keySize;
+  private X500DistinguishedName distinguishedName;
+  private Parser cmdOptionsParser;
+
+  // 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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java Thu Nov  8 16:56:19 2007
@@ -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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.util.logging.Logger;
+
+/**
+ * <b>NOT IMPLEMENTED YET</b>
+ * <p>
+ * The <b>-identitydb</b> keytool command handler is used to read the JDK 1.1.x-
+ * style identity database and add its entries to the key store. If a key store
+ * does not exist, it is created.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-file FILE_NAME</dt>
+ *      <dd>The fully qualified path of the identity file to import. If this
+ *      option is omitted, the tool will process STDIN.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class IdentityDBCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(IdentityDBCmd.class.getName());
+  protected String _idbFileName;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param pathName the fully qualified path name of the file to process. */
+  public void setFile(String pathName)
+  {
+    this._idbFileName = pathName;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setInputStreamParam(_idbFileName);
+    setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-identitydb handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -file=" + _idbFileName); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.IDENTITYDB_CMD, true);
+    result.setHeader(Messages.getString("IdentityDBCmd.7")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("IdentityDBCmd.8")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("IdentityDBCmd.9")); //$NON-NLS-1$
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("IdentityDBCmd.10"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.11")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _idbFileName = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("IdentityDBCmd.12"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.13")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("IdentityDBCmd.14"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.15")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("IdentityDBCmd.16"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.17")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("IdentityDBCmd.18"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.19")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("IdentityDBCmd.20")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,931 @@
+/* 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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.x509.X509CertPath;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.Principal;
+import java.security.PublicKey;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertPathValidator;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.PKIXCertPathValidatorResult;
+import java.security.cert.PKIXParameters;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.DSAParams;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.RSAPublicKey;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <code>-import</code> keytool command handler is used to read an X.509
+ * certificate, or a PKCS#7 Certificate Reply from a designated input source and
+ * incorporate the certificates into the key store.
+ * <p>
+ * If the <i>Alias</i> does not already exist in the key store, the tool treats
+ * the certificate read from the input source as a new Trusted Certificate. It
+ * then attempts to discover a chain-of-trust, starting from that certificate
+ * and ending at another <i>Trusted Certificate</i>, already stored in the key
+ * store.  If the <code>-trustcacerts</code> option is present, an additional
+ * key store, of type <code>JKS</code> named <code>cacerts</code>, and assumed
+ * to be present in <code>${JAVA_HOME}/lib/security</code> will also be
+ * consulted if found --<code>${JAVA_HOME}</code> refers to the location of an
+ * installed Java Runtime Environment (JRE). If no chain-of-trust can be
+ * established, and unless the <code>-noprompt</code> option has been specified,
+ * the certificate is printed to STDOUT and the user is prompted for a
+ * confirmation.
+ * <p>
+ * If <i>Alias</i> exists in the key store, the tool will treat the
+ * certificate(s) read from the input source as a <i>Certificate Reply</i>,
+ * which can be a chain of certificates, that eventually would replace the chain
+ * of certificates associated with the <i>Key Entry</i> of that <i>Alias</i>.
+ * The substitution of the certificates only occurs if a chain-of-trust can be
+ * established between the bottom certificate of the chain read from the input
+ * file and the <i>Trusted Certificates</i> already present in the key store.
+ * Again, if the <code>-trustcacerts</code> option is specified, additional
+ * <i>Trusted Certificates</i> in the same <code>cacerts</code> key store will
+ * be considered. If no chain-of-trust can be established, the operation will
+ * abort.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-file FILE_NAME</dt>
+ *      <dd>The fully qualified path of the file to read from. If omitted, the
+ *      tool will process STDIN.
+ *      <p></dd>
+ *      
+ *      <dt>-keypass PASSWORD</dt>
+ *      <dd>Use this option to specify the password which the tool will use to
+ *      protect the <i>Key Entry</i> associated with the designated <i>Alias</i>,
+ *      when replacing this <i>Alias</i>' chain of certificates with that found
+ *      in the certificate reply.
+ *      <p>
+ *      If this option is omitted, and the chain-of-trust for the certificate
+ *      reply has been established, the tool will first attempt to unlock the
+ *      <i>Key Entry</i> using the same password protecting the key store. If
+ *      this fails, you will then be prompted to provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-noprompt</dt>
+ *      <dd>Use this option to prevent the tool from prompting the user.
+ *      <p></dd>
+ *      
+ *      <dt>-trustcacerts</dt>
+ *      <dd>Use this option to indicate to the tool that a key store, of type
+ *      <code>JKS</code>, named <code>cacerts</code>, and usually located in
+ *      <code>lib/security</code> in an installed Java Runtime Environment
+ *      should be considered when trying to establish chain-of-trusts.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class ImportCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(ImportCmd.class.getName());
+  private static final String GKR = "gkr"; //$NON-NLS-1$
+  private static final String JKS = "jks"; //$NON-NLS-1$
+  private static final String LIB = "lib"; //$NON-NLS-1$
+  private static final String SECURITY = "security"; //$NON-NLS-1$
+  private static final String CACERTS = "cacerts"; //$NON-NLS-1$
+  private static final String CACERTS_GKR = CACERTS + "." + GKR; //$NON-NLS-1$
+  protected String _alias;
+  protected String _certFileName;
+  protected String _password;
+  protected boolean noPrompt;
+  protected boolean trustCACerts;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  private CertificateFactory x509Factory;
+  private boolean imported;
+  /**
+   * Pathname to a GKR-type cacerts file to use when trustCACerts is true. This
+   * is usually a file named "cacerts.gkr" located in lib/security in the folder
+   * specified by the system-property "gnu.classpath.home".
+   */
+  private String gkrCaCertsPathName;
+  /**
+   * Pathname to a JKS-type cacerts file to use when trustCACerts is true. This
+   * is usually a file named "cacerts" located in lib/security in the folder
+   * specified by the system-property "java.home".
+   */
+  private String jksCaCertsPathName;
+  /** Alias self-signed certificate.  used when importing certificate replies. */
+  private X509Certificate selfSignedCertificate;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param alias the existing alias to use. */
+  public void setAlias(String alias)
+  {
+    this._alias = alias;
+  }
+
+  /** @param pathName the fully qualified path name of the file to process. */
+  public void setFile(String pathName)
+  {
+    this._certFileName = pathName;
+  }
+
+  /** @param password the existing (private) key password to use. */
+  public void setKeypass(String password)
+  {
+    this._password = password;
+  }
+
+  /**
+   * @param flag whether to prompt, or not, the user to verify certificate
+   *          fingerprints.
+   */
+  public void setNoprompt(String flag)
+  {
+    this.noPrompt = Boolean.valueOf(flag).booleanValue();
+  }
+
+  /**
+   * @param flag whether to trust, or not, certificates found in the
+   *          <code>cacerts</code> key store.
+   */
+  public void setTrustcacerts(String flag)
+  {
+    this.trustCACerts = Boolean.valueOf(flag).booleanValue();
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setInputStreamParam(_certFileName);
+    setKeyStoreParams(true, _providerClassName, _ksType, _ksPassword, _ksURL);
+    setAliasParam(_alias);
+    setKeyPasswordNoPrompt(_password);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-import handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -alias=" + alias); //$NON-NLS-1$
+        log.fine("  -file=" + _certFileName); //$NON-NLS-1$
+        log.fine("  -noprompt=" + noPrompt); //$NON-NLS-1$
+        log.fine("  -trustcacerts=" + trustCACerts); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws CertificateException, KeyStoreException, IOException,
+      UnsupportedCallbackException, NoSuchAlgorithmException,
+      CertPathValidatorException, UnrecoverableKeyException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    if (trustCACerts)
+      {
+        String fs = SystemProperties.getProperty("file.separator"); //$NON-NLS-1$
+        String classpathHome = SystemProperties.getProperty("gnu.classpath.home"); //$NON-NLS-1$
+        gkrCaCertsPathName = new StringBuilder(classpathHome).append(fs)
+            .append(LIB).append(fs)
+            .append(SECURITY).append(fs)
+            .append(CACERTS_GKR).toString();
+        String javaHome = SystemProperties.getProperty("java.home"); //$NON-NLS-1$
+        jksCaCertsPathName = new StringBuilder(javaHome).append(fs)
+            .append(LIB).append(fs)
+            .append(SECURITY).append(fs)
+            .append(CACERTS).toString();
+      }
+    x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
+    // the alias will tell us whether we're dealing with
+    // a new trusted certificate or a certificate reply
+    if (! store.containsAlias(alias))
+      importNewTrustedCertificate();
+    else
+      {
+        ensureAliasIsKeyEntry();
+        importCertificateReply();
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.IMPORT_CMD, true);
+    result.setHeader(Messages.getString("ImportCmd.27")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("ImportCmd.26")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("ImportCmd.25")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("ImportCmd.24"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.23")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("ImportCmd.22"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.21")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _certFileName = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("ImportCmd.20"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.19")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option("noprompt", //$NON-NLS-1$
+                           Messages.getString("ImportCmd.18")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        noPrompt = true;
+      }
+    });
+    options.add(new Option("trustcacerts", //$NON-NLS-1$
+                           Messages.getString("ImportCmd.17")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        trustCACerts = true;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("ImportCmd.16"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.15")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("ImportCmd.14"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.13")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("ImportCmd.12"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.11")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("ImportCmd.10"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("ImportCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * When importing a new trusted certificate, <i>alias</i> MUST NOT yet exist
+   * in the key store.
+   * <p>
+   * Before adding the certificate to the key store and associate it with the
+   * designated Alias, this method tries to verify it by attempting to construct
+   * a chain of trust from that certificate to a self-signed certificate
+   * (belonging to a root CA), using (already) trusted certificates that are
+   * available in the key store.
+   * <p>
+   * If the <code>-trustcacerts</code> option was detected on the command
+   * line, additional trusted certificates are considered for establishing the
+   * chain of trust. Those additional certificates are assumed to be in a key
+   * store, of type <code>JKS</code> named <code>cacerts</code> and usually
+   * located in <code>${JAVA_HOME}/lib/security</code>, where
+   * <code>${JAVA_HOME}</code> is the root folder location of a Java runtime.
+   * <p>
+   * If this method fails to establish a trust path from the certificate to be
+   * imported up to a trusted self-signed certificate, the certificate is
+   * printed to <code>STDOUT</code>, and the user is prompted to verify it,
+   * with the option of aborting the import operation. If however the option
+   * <code>-noprompt</code> was detected on the command line, no interaction
+   * with the user will take place and the import operation will abort.
+   * 
+   * @throws CertificateException
+   * @throws KeyStoreException
+   * @throws NoSuchAlgorithmException
+   * @throws UnsupportedCallbackException 
+   * @throws IOException 
+   * @throws UnrecoverableKeyException 
+   * @throws CertPathValidatorException 
+   */
+  private void importNewTrustedCertificate() throws CertificateException,
+      KeyStoreException, NoSuchAlgorithmException, IOException,
+      UnsupportedCallbackException, CertPathValidatorException,
+      UnrecoverableKeyException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$
+    Certificate certificate = x509Factory.generateCertificate(inStream);
+    if (Configuration.DEBUG)
+      log.fine("certificate = " + certificate); //$NON-NLS-1$
+    LinkedList orderedReply = new LinkedList();
+    orderedReply.addLast(certificate);
+
+    if (findTrustAndUpdate(orderedReply, ! noPrompt))
+      {
+        store.setCertificateEntry(alias, certificate);
+        System.out.println(Messages.getString("ImportCmd.29")); //$NON-NLS-1$
+        saveKeyStore();
+      }
+    else
+      System.out.println(Messages.getString("ImportCmd.28")); //$NON-NLS-1$
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "importNewTrustedCertificate"); //$NON-NLS-1$
+  }
+
+  /**
+   * A certificate reply is a certificate, whose Owner is stored in the key
+   * store associated to the designated Alias, and now signed by supposedly a
+   * trusted CA (Certificate Authority). In other words, the Subject in this
+   * certificate reply is Alias's own and the Issuer is a CA.
+   * <p>
+   * When importing a certificate reply, the reply is validated using trusted
+   * certificates from the key store, and optionally (if the option
+   * <code>-trustcacerts</code> was detected on the command line) certificates
+   * found in the key store, of type <code>JKS</code> named <code>cacerts</code>
+   * located in <code>${JAVA_HOME}/lib/security</code>, where
+   * <code>${JAVA_HOME}</code> is the root folder location of a Java runtime.
+   * 
+   * @throws CertificateException
+   * @throws UnsupportedCallbackException
+   * @throws IOException
+   * @throws KeyStoreException
+   * @throws CertPathValidatorException
+   * @throws NoSuchAlgorithmException
+   * @throws UnrecoverableKeyException
+   */
+  private void importCertificateReply() throws CertificateException,
+      IOException, UnsupportedCallbackException, KeyStoreException,
+      NoSuchAlgorithmException, CertPathValidatorException,
+      UnrecoverableKeyException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$
+    Collection certificates = x509Factory.generateCertificates(inStream);
+    ensureReplyIsOurs(certificates);
+    // we now have established that the public keys are the same.
+    // find a chain-of-trust if one exists
+    if (certificates.size() == 1)
+      importCertificate((Certificate) certificates.iterator().next());
+    else
+      importChain(certificates);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "importCertificateReply"); //$NON-NLS-1$
+  }
+
+  /**
+   * If the reply is a single X.509 certificate, keytool attempts to establish a
+   * trust chain, starting at the certificate reply and ending at a self-signed
+   * certificate (belonging to a root CA). The certificate reply and the
+   * hierarchy of certificates used to authenticate the certificate reply form
+   * the new certificate chain of alias. If a trust chain cannot be established,
+   * the certificate reply is not imported. In this case, keytool does not print
+   * out the certificate, nor does it prompt the user to verify it. This is
+   * because it is very hard (if not impossible) for a user to determine the
+   * authenticity of the certificate reply.
+   * 
+   * @param certificate the certificate reply to import into the key store.
+   * @throws NoSuchAlgorithmException 
+   * @throws CertPathValidatorException 
+   * @throws UnsupportedCallbackException 
+   * @throws IOException 
+   * @throws UnrecoverableKeyException 
+   * @throws KeyStoreException 
+   * @throws CertificateException 
+   */
+  private void importCertificate(Certificate certificate)
+      throws NoSuchAlgorithmException, CertPathValidatorException,
+      KeyStoreException, UnrecoverableKeyException, IOException,
+      UnsupportedCallbackException, CertificateException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "importCertificate", certificate); //$NON-NLS-1$
+    LinkedList reply = new LinkedList();
+    reply.addLast(certificate);
+
+    if (! findTrustAndUpdate(reply, false))
+      throw new CertPathValidatorException(Messages.getString("ImportCmd.34")); //$NON-NLS-1$
+
+    Certificate[] newChain = (Certificate[]) reply.toArray(new Certificate[0]);
+    Key privateKey = getAliasPrivateKey();
+    store.setKeyEntry(alias, privateKey, keyPasswordChars, newChain);
+    saveKeyStore();
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "importCertificate"); //$NON-NLS-1$
+  }
+
+  /**
+   * If the reply is a PKCS#7 formatted certificate chain, the chain is first
+   * ordered (with the user certificate first and the self-signed root CA
+   * certificate last), before keytool attempts to match the root CA certificate
+   * provided in the reply with any of the trusted certificates in the key store
+   * or the "cacerts" keystore file (if the -trustcacerts option was specified).
+   * If no match can be found, the information of the root CA certificate is
+   * printed out, and the user is prompted to verify it, e.g., by comparing the
+   * displayed certificate fingerprints with the fingerprints obtained from some
+   * other (trusted) source of information, which might be the root CA itself.
+   * The user then has the option of aborting the import operation. If the
+   * -noprompt option is given, however, there will be no interaction with the
+   * user.
+   * 
+   * @param chain the collection of certificates parsed from the user
+   *          designated input.
+   * @throws UnsupportedCallbackException 
+   * @throws IOException 
+   * @throws UnrecoverableKeyException 
+   * @throws KeyStoreException 
+   * @throws CertPathValidatorException 
+   * @throws NoSuchAlgorithmException 
+   * @throws CertificateException 
+   */
+  private void importChain(Collection chain) throws NoSuchAlgorithmException,
+      CertPathValidatorException, KeyStoreException, UnrecoverableKeyException,
+      IOException, UnsupportedCallbackException, CertificateException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "importChain", chain); //$NON-NLS-1$
+    LinkedList reply = orderChain(chain);
+    if (findTrustAndUpdate(reply, ! noPrompt))
+      {
+        Certificate[] newChain = (Certificate[]) reply.toArray(new Certificate[0]);
+        Key privateKey = getAliasPrivateKey();
+        store.setKeyEntry(alias, privateKey, keyPasswordChars, newChain);
+        saveKeyStore();
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "importChain"); //$NON-NLS-1$
+  }
+
+  /**
+   * Check to ensure that alias's public key is the subject of the first
+   * certificate in the passed certificate collection. Throws an exception if
+   * the public keys do not match.
+   * 
+   * @param certificates a {@link Collection} of certificate replies (either a
+   *          signle certificate reply, or a PKCS#7 certificate reply chain)
+   *          usually sent by a CA as a response to a Certificate Signing
+   *          Request (CSR).
+   * @throws IOException
+   * @throws UnsupportedCallbackException
+   * @throws KeyStoreException
+   */
+  private void ensureReplyIsOurs(Collection certificates) throws IOException,
+      UnsupportedCallbackException, KeyStoreException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$
+    Certificate certificate = (Certificate) certificates.iterator().next();
+    if (Configuration.DEBUG)
+      log.fine("certificate = " + certificate); //$NON-NLS-1$
+    Certificate[] chain = store.getCertificateChain(alias);
+    if (chain == null)
+      throw new IllegalArgumentException(Messages.getFormattedString("ImportCmd.37", //$NON-NLS-1$
+                                                                     alias));
+    selfSignedCertificate = (X509Certificate) chain[0];
+    PublicKey anchorPublicKey = selfSignedCertificate.getPublicKey();
+    PublicKey certPublicKey = certificate.getPublicKey();
+    boolean sameKey;
+    if (anchorPublicKey instanceof DSAPublicKey)
+      {
+        DSAPublicKey pk1 = (DSAPublicKey) anchorPublicKey;
+        if (!(certPublicKey instanceof DSAPublicKey))
+          throw new IllegalArgumentException(Messages.getString("ImportCmd.38")); //$NON-NLS-1$
+
+        sameKey = areEqual(pk1, (DSAPublicKey) certPublicKey);
+      }
+    else if (anchorPublicKey instanceof RSAPublicKey)
+      {
+        RSAPublicKey pk1 = (RSAPublicKey) anchorPublicKey;
+        if (!(certPublicKey instanceof RSAPublicKey))
+          throw new IllegalArgumentException(Messages.getString("ImportCmd.38")); //$NON-NLS-1$
+
+        sameKey = areEqual(pk1, (RSAPublicKey) certPublicKey);
+      }
+    else
+      throw new IllegalArgumentException(
+          Messages.getFormattedString("ImportCmd.40", //$NON-NLS-1$
+                                      new String[] { alias,
+                                                     anchorPublicKey.getClass().getName() }));
+    if (! sameKey)
+      throw new IllegalArgumentException(Messages.getString("ImportCmd.41")); //$NON-NLS-1$
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "ensureReplyIsOurs"); //$NON-NLS-1$
+  }
+
+  private boolean areEqual(DSAPublicKey pk1, DSAPublicKey pk2)
+  {
+    if (pk1.getY().compareTo(pk2.getY()) != 0)
+      return false;
+
+    DSAParams p1 = pk1.getParams();
+    DSAParams p2 = pk2.getParams();
+    if (p1.getG().compareTo(p2.getG()) != 0)
+      return false;
+
+    if (p1.getP().compareTo(p2.getP()) != 0)
+      return false;
+
+    return p1.getQ().compareTo(p2.getQ()) == 0;
+  }
+
+  private boolean areEqual(RSAPublicKey pk1, RSAPublicKey pk2)
+  {
+    if (pk1.getPublicExponent().compareTo(pk2.getPublicExponent()) != 0)
+      return false;
+
+    return pk1.getModulus().compareTo(pk2.getModulus()) == 0;
+  }
+
+  /**
+   * Given a collection of certificates returned as a certificate-reply, this
+   * method sorts the certificates in the collection so that the <i>Issuer</i>
+   * of the certificate at position <code>i</code> is the <i>Subject</i> of
+   * the certificate at position <code>i + 1</code>.
+   * <p>
+   * This method uses <code>selfSignedCertificate</code> to discover the first
+   * certificate in the chain. The <i>Trust Anchor</i> of the chain; i.e. the
+   * self-signed CA certificate, if it exsits, will be discovered/established
+   * later by an appropriate <i>Certificate Path Validator</i>.
+   * <p>
+   * An exception is thrown if (a) no initial certificate is found in the
+   * designated collection which can be used as the start of the chain, or (b)
+   * if a chain can not be constructed using all the certificates in the
+   * designated collection.
+   * 
+   * @param chain a collection of certificates, not necessarily ordered, but
+   *          assumed to include a CA certificate authenticating our alias
+   *          public key, which is the subject of the alias self-signed
+   *          certificate.
+   * @return the input collection, ordered with own certificate first, and CA's
+   *         self-signed certificate last.
+   */
+  private LinkedList orderChain(Collection chain)
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "orderChain"); //$NON-NLS-1$
+    LinkedList in = new LinkedList(chain);
+    int initialCount = in.size();
+    LinkedList result = new LinkedList();
+    Principal issuer = selfSignedCertificate.getIssuerDN();
+    ListIterator it;
+    outer: while (in.size() > 0)
+      {
+        for (it = in.listIterator(); it.hasNext();)
+          {
+            X509Certificate certificate = (X509Certificate) it.next();
+            if (issuer.equals(certificate.getSubjectDN()))
+              {
+                it.remove();
+                result.addLast(certificate);
+                issuer = certificate.getIssuerDN();
+                continue outer;
+              }
+          }
+        throw new IllegalArgumentException(
+            Messages.getFormattedString(Messages.getString("ImportCmd.7"), //$NON-NLS-1$
+                                        new Object[] { Integer.valueOf(result.size()),
+                                                       Integer.valueOf(initialCount) }));
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "orderChain", result); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * Given an ordered list of certificates, this method attempts to validate the
+   * chain, and if successful, updates the key store entry for the designated
+   * alias. The list of certificates is expected to be ordered as a chain, where
+   * the first is the alias's own certificate and the last being a self-signed
+   * CA certificate.
+   * <p>
+   * if <code>promptUser</code> is <code>true</code>, then even if no
+   * anchor trust certificate is found, the user is prompted to approve, or not,
+   * the import operation. On the other hand if the <code>promptUser</code>
+   * parameter is <code>false</code> then this method will throw an exception
+   * if no trust anchor is to be found.
+   * 
+   * @param reply an ordered certificate path, where the last entry is the CA's
+   *          self-signed certificate.
+   * @param promptUser a boolean flag indicating whether or not to prompt the
+   *          user for explicit trust in a CA certificate.
+   * @return <code>true</code> if the validation succeeds; or <code>false</code>
+   *         otherwise.
+   * @throws NoSuchAlgorithmException
+   * @throws CertPathValidatorException
+   * @throws UnsupportedCallbackException
+   * @throws IOException
+   * @throws UnrecoverableKeyException
+   * @throws KeyStoreException
+   * @throws CertificateEncodingException
+   */
+  private boolean findTrustAndUpdate(LinkedList reply, boolean promptUser)
+      throws IOException, NoSuchAlgorithmException, CertPathValidatorException,
+      KeyStoreException, UnrecoverableKeyException, UnsupportedCallbackException,
+      CertificateEncodingException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "findTrustAndUpdate"); //$NON-NLS-1$
+    CertPathValidator validator = CertPathValidator.getInstance("PKIX"); //$NON-NLS-1$
+    X509CertPath certPath = new X509CertPath(reply);
+    PKIXCertPathValidatorResult cpvr = findTrustInStore(certPath, validator);
+    if (cpvr == null && trustCACerts) // try cacerts.gkr - a GKR key store
+      {
+        PKIXParameters params = getCertPathParameters(GKR, gkrCaCertsPathName);
+        cpvr = validate(validator, certPath, params);
+        if (cpvr == null) // try cacerts - a JKS key store
+          {
+            params = getCertPathParameters(JKS, jksCaCertsPathName);
+            cpvr = validate(validator, certPath, params);
+          }
+      }
+    boolean result = false;
+    if (cpvr == null)
+      {
+        if (promptUser)
+          {
+            printVerbose((Certificate) reply.getLast());
+            ConfirmationCallback ccb;
+            ccb = new ConfirmationCallback(Messages.getString("ImportCmd.32"), //$NON-NLS-1$
+                                           ConfirmationCallback.INFORMATION,
+                                           ConfirmationCallback.YES_NO_OPTION,
+                                           ConfirmationCallback.NO);
+            getCallbackHandler().handle(new Callback[] { ccb });
+            int answer = ccb.getSelectedIndex();
+            result = answer == ConfirmationCallback.YES;
+          }
+      }
+    else
+      {
+        TrustAnchor anchor = cpvr.getTrustAnchor();
+        log.fine("Found a chain-of-trust anchored by " + anchor); //$NON-NLS-1$
+        Certificate trustedCert = anchor.getTrustedCert();
+        reply.addLast(trustedCert);
+        result = true;
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "findTrustAndUpdate", //$NON-NLS-1$
+                  Boolean.valueOf(result));
+    return result;
+  }
+
+  private PKIXCertPathValidatorResult findTrustInStore(X509CertPath certPath,
+                                                       CertPathValidator validator)
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "findTrustInStore"); //$NON-NLS-1$
+    PKIXCertPathValidatorResult result;
+    try
+      {
+        PKIXParameters params = new PKIXParameters(store);
+        result = (PKIXCertPathValidatorResult) validator.validate(certPath, params);
+      }
+    catch (Exception x)
+      {
+        log.log(Level.FINE,
+                "Exception in findTrustInStore(). Ignore + Return NULL", //$NON-NLS-1$
+                x);
+        result = null;
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "findTrustInStore", result); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * Return an instance of {@link PKIXParameters} constructed using a key store
+   * of the designated type and located at the designated path.
+   * 
+   * @param type the type of the key-store to load.
+   * @param pathName the local File System fully qualified path name to the key
+   *          store.
+   * @return an instance of <code>CertPathParameters</code> to use for
+   *         validating certificates and certificate replies.
+   */
+  private PKIXParameters getCertPathParameters(String type, String pathName)
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getCertPathParameters", //$NON-NLS-1$
+                   new Object[] { type, pathName });
+    FileInputStream stream = null;
+    PKIXParameters result = null;
+    try
+      {
+        KeyStore cacerts = KeyStore.getInstance(type);
+        stream = new FileInputStream(pathName);
+        cacerts.load(stream, "changeit".toCharArray()); //$NON-NLS-1$
+        result = new PKIXParameters(cacerts);
+      }
+    catch (Exception x)
+      {
+        if (Configuration.DEBUG)
+          log.log(Level.FINE, "Exception in getCertPathParameters(). Ignore", x); //$NON-NLS-1$
+      }
+    finally
+      {
+        if (stream != null)
+          try
+            {
+              stream.close();
+            }
+          catch (Exception ignored)
+            {
+            }
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getCertPathParameters", result); //$NON-NLS-1$
+    return result;
+  }
+
+  private PKIXCertPathValidatorResult validate(CertPathValidator validator,
+                                               X509CertPath certPath,
+                                               PKIXParameters params)
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "validate"); //$NON-NLS-1$
+    PKIXCertPathValidatorResult result = null;
+    if (params != null)
+      try
+        {
+          result = (PKIXCertPathValidatorResult) validator.validate(certPath,
+                                                                    params);
+        }
+      catch (Exception x)
+        {
+          if (Configuration.DEBUG)
+            log.log(Level.FINE, "Exception in validate(). Ignore", x); //$NON-NLS-1$
+        }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "validate", result); //$NON-NLS-1$
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java Thu Nov  8 16:56:19 2007
@@ -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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.IOException;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-keyclone</b> keytool command handler is used to clone an existing
+ * key store entry associated with a designated alias, with its private key and
+ * chain of certificates.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-dest ALIAS</dt>
+ *      <dd>Use this option to specify the new <i>Alias</i> which will be used
+ *      to identify the cloned copy of the <i>Key Entry</i>.
+ *      <p></dd>
+ *      
+ *      <dt>-keypass PASSWORD</dt>
+ *      <dd>Use this option to specify the password which the tool will use to
+ *      unlock the <i>Key Entry</i> associated with the designated <i>Alias</i>.
+ *      <p>
+ *      If this option is omitted, the tool will first attempt to unlock the
+ *      <i>Key Entry</i> using the same password protecting the key store. If
+ *      this fails, you will then be prompted to provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-new PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the private key
+ *      material of the newly cloned copy of the <i>Key Entry</i>.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class KeyCloneCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(KeyCloneCmd.class.getName());
+  protected String _alias;
+  protected String _destAlias;
+  protected String _password;
+  protected String _newPassword;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  private String destinationAlias;
+  private char[] newKeyPasswordChars;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param alias the existing alias to use. */
+  public void setAlias(String alias)
+  {
+    this._alias = alias;
+  }
+
+  /** @param alias the new alias to use. */
+  public void setDest(String alias)
+  {
+    this._destAlias = alias;
+  }
+
+  /** @param password the existing (private) key password to use. */
+  public void setKeypass(String password)
+  {
+    this._password = password;
+  }
+
+  /** @param password the new (private) key password to use. */
+  public void setNew(String password)
+  {
+    this._newPassword = password;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    setAliasParam(_alias);
+    setKeyPasswordNoPrompt(_password);
+    setDestinationAlias(_destAlias);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-keyclone handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -alias=" + alias); //$NON-NLS-1$
+        log.fine("  -dest=" + destinationAlias); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
+      UnsupportedCallbackException, UnrecoverableKeyException,
+      CertificateException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    if (store.containsAlias(destinationAlias))
+      throw new SecurityException(Messages.getString("KeyCloneCmd.23")); //$NON-NLS-1$
+
+    Key privateKey = getAliasPrivateKey();
+
+    setNewKeyPassword(_newPassword);
+    Certificate[] chain = store.getCertificateChain(alias);
+
+    store.setKeyEntry(destinationAlias, privateKey, newKeyPasswordChars, chain);
+
+    saveKeyStore();
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.KEYCLONE_CMD, true);
+    result.setHeader(Messages.getString("KeyCloneCmd.22")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("KeyCloneCmd.21")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("KeyCloneCmd.20")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("KeyCloneCmd.19"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.16")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.DEST_OPT,
+                           Messages.getString("KeyCloneCmd.17"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.16")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _destAlias = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("KeyCloneCmd.15"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option(Main.NEW_OPT,
+                           Messages.getString("KeyCloneCmd.13"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _newPassword = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("KeyCloneCmd.11"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("KeyCloneCmd.9"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("KeyCloneCmd.7"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("KeyCloneCmd.5"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.4")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("KeyCloneCmd.3")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  private void setDestinationAlias(String name) throws IOException,
+      UnsupportedCallbackException
+  {
+    if (name == null || name.trim().length() == 0) // ask user to provide one
+      {
+        NameCallback ncb = new NameCallback(Messages.getString("KeyCloneCmd.26")); //$NON-NLS-1$
+        getCallbackHandler().handle(new Callback[] { ncb });
+        name = ncb.getName();
+        if (name == null || name.trim().length() == 0)
+          throw new IllegalArgumentException(Messages.getString("KeyCloneCmd.27")); //$NON-NLS-1$
+      }
+
+    destinationAlias = name.trim();
+  }
+
+  private void setNewKeyPassword(String password) throws IOException,
+      UnsupportedCallbackException
+  {
+    if (password != null)
+      newKeyPasswordChars = password.toCharArray();
+    else // ask user to provide one
+      {
+        boolean ok = false;
+        Callback[] prompts = new Callback[1];
+        Callback[] errors = new Callback[1];
+        for (int i = 0; i < 3; i++)
+          if (prompt4NewPassword(getCallbackHandler(), prompts, errors))
+            {
+              ok = true;
+              break;
+            }
+        if (! ok)
+          throw new SecurityException(Messages.getString("StorePasswdCmd.19")); //$NON-NLS-1$
+      }
+  }
+
+  private boolean prompt4NewPassword(CallbackHandler handler,
+                                     Callback[] prompts, Callback[] errors)
+      throws IOException, UnsupportedCallbackException
+  {
+    String p = Messages.getFormattedString("KeyCloneCmd.28", //$NON-NLS-1$
+                                           new String[] { destinationAlias,
+                                                          String.valueOf(keyPasswordChars) });
+    PasswordCallback pcb = new PasswordCallback(p, false);
+    prompts[0] = pcb;
+    handler.handle(prompts);
+    char[] pwd1 = pcb.getPassword();
+    pcb.clearPassword();
+    if (pwd1 == null || pwd1.length == 0)
+      {
+        newKeyPasswordChars = (char[]) keyPasswordChars.clone();
+        return true;
+      }
+
+    if (pwd1.length < 6)
+      {
+        errors[0] = new TextOutputCallback(TextOutputCallback.ERROR,
+                                           Messages.getString("StorePasswdCmd.21")); //$NON-NLS-1$
+        handler.handle(errors);
+        return false;
+      }
+
+    newKeyPasswordChars = pwd1;
+    return true;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java Thu Nov  8 16:56:19 2007
@@ -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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.IOException;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-keypasswd</b> keytool command handler is used to change the password
+ * protecting the private key associated to a designated alias.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-keypass PASSWORD</dt>
+ *      <dd>Use this option to specify the password which the tool will use to
+ *      unlock the <i>Key Entry</i> associated with the designated <i>Alias</i>.
+ *      <p>
+ *      If this option is omitted, the tool will first attempt to unlock the
+ *      <i>Key Entry</i> using the same password protecting the key store. If
+ *      this fails, you will then be prompted to provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-new PASSWORD</dt>
+ *      <dd>The new, and different, password which will be used to protect the
+ *      private key material of the designated Key Entry.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class KeyPasswdCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(KeyPasswdCmd.class.getName());
+  protected String _alias;
+  protected String _password;
+  protected String _newPassword;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  private char[] newPasswordChars;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param alias the alias to use. */
+  public void setAlias(String alias)
+  {
+    this._alias = alias;
+  }
+
+  /** @param password the existing (private) key password to use. */
+  public void setKeypass(String password)
+  {
+    this._password = password;
+  }
+
+  /** @param password the new (private) key password to use. */
+  public void setNew(String password)
+  {
+    this._newPassword = password;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    setAliasParam(_alias);
+    setKeyPasswordNoPrompt(_password);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-keypasswd handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -alias=" + alias); //$NON-NLS-1$
+        log.fine("  -new=" + _newPassword); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws KeyStoreException, NoSuchAlgorithmException, IOException,
+      UnsupportedCallbackException, UnrecoverableKeyException,
+      CertificateException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    // 1. get the key entry and certificate chain associated to alias
+    Key privateKey = getAliasPrivateKey();
+    Certificate[] chain = store.getCertificateChain(alias);
+
+    // 2. replace the old entry
+    setNewKeyPassword(_newPassword);
+    store.setKeyEntry(alias, privateKey, newPasswordChars, chain);
+
+    // 3. persist the key store
+    saveKeyStore();
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.KEYPASSWD_CMD, true);
+    result.setHeader(Messages.getString("KeyPasswdCmd.23")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("KeyPasswdCmd.22")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("KeyPasswdCmd.21")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("KeyPasswdCmd.20"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.19")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("KeyPasswdCmd.18"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option(Main.NEW_OPT,
+                           Messages.getString("KeyPasswdCmd.16"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _newPassword = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("KeyPasswdCmd.14"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.13")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("KeyPasswdCmd.12"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.11")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("KeyPasswdCmd.10"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("KeyPasswdCmd.8"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.7")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("KeyPasswdCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * Set the new password to use for protecting Alias's private key.
+   * 
+   * @param password the new key password. if <code>null</code> prompt the
+   *          user to provide one. When prompting, the password is entered twice
+   *          and compared for a match.
+   * @throws IOException if an I/O related exception occurs during the process.
+   * @throws UnsupportedCallbackException if no implementation of a password
+   *           callback handler was found.
+   */
+  private void setNewKeyPassword(String password) throws IOException,
+      UnsupportedCallbackException
+  {
+    if (password != null)
+      newPasswordChars = password.toCharArray();
+    else
+      {
+        boolean ok = false;
+        Callback[] prompts = new Callback[1];
+        Callback[] errors = new Callback[1];
+        for (int i = 0; i < 3; i++)
+          if (prompt4NewPassword(getCallbackHandler(), prompts, errors))
+            {
+              ok = true;
+              break;
+            }
+        if (! ok)
+          throw new SecurityException(Messages.getString("StorePasswdCmd.19")); //$NON-NLS-1$
+      }
+  }
+
+  private boolean prompt4NewPassword(CallbackHandler handler,
+                                     Callback[] prompts, Callback[] errors)
+      throws IOException, UnsupportedCallbackException
+  {
+    // prompt user (1st time) to provide one
+    String p = Messages.getFormattedString("KeyPasswdCmd.24", alias); //$NON-NLS-1$
+    PasswordCallback pcb = new PasswordCallback(p, false);
+    prompts[0] = pcb;
+    handler.handle(prompts);
+    char[] pwd1 = pcb.getPassword();
+    pcb.clearPassword();
+    String ls = SystemProperties.getProperty("line.separator"); //$NON-NLS-1$
+    if (pwd1 == null || pwd1.length < 6)
+      {
+        String m = Messages.getString("StorePasswdCmd.21") + ls; //$NON-NLS-1$
+        errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+        handler.handle(errors);
+        return false;
+      }
+
+    if (Arrays.equals(keyPasswordChars, pwd1))
+      {
+        String m = Messages.getString("StorePasswdCmd.22") + ls; //$NON-NLS-1$
+        errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+        handler.handle(errors);
+        return false;
+      }
+
+    // prompt user (2nd time) for confirmation
+    p = Messages.getFormattedString("KeyPasswdCmd.28", alias); //$NON-NLS-1$
+    pcb = new PasswordCallback(p, false);
+    prompts[0] = pcb;
+    handler.handle(prompts);
+    char[] pwd2 = pcb.getPassword();
+    pcb.clearPassword();
+    if (! Arrays.equals(pwd1, pwd2))
+      {
+        String m = Messages.getString("StorePasswdCmd.24") + ls; //$NON-NLS-1$
+        errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+        handler.handle(errors);
+        return false;
+      }
+
+    newPasswordChars = pwd2;
+    return true;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,432 @@
+/* ListCmd.java -- The list 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.getopt.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.Base64;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.KeyStoreException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.util.Enumeration;
+import java.util.logging.Logger;
+
+/**
+ * The <b>-list</b> keytool command handler is used to output one or all key
+ * store entries.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-rfc</dt>
+ *      <dd>Use RFC-1421 specifications when encoding the output.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Output the certificate in human-readable format. If both this option
+ *      and the <code>-rfc</code> option are detected on the command line, the
+ *      tool will opt for the human-readable form and will not abort the
+ *      command.</dd>
+ * </dl>
+ */
+class ListCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(ListCmd.class.getName());
+  protected String _alias;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  protected boolean rfc;
+  private boolean all;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param alias the alias to use. */
+  public void setAlias(String alias)
+  {
+    this._alias = alias;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  /**
+   * @param flag whether to use, or not, RFC-1421 format when listing the
+   *          certificate(s).
+   */
+  public void setRfc(String flag)
+  {
+    this.rfc = Boolean.valueOf(flag).booleanValue();
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setOutputStreamParam(null); // use stdout
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    all = _alias == null;
+    if (! all)
+      setAliasParam(_alias);
+
+    if (verbose & rfc)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Both -v and -rfc options were found on the command line. " //$NON-NLS-1$
+                   + "Only the former will be considered"); //$NON-NLS-1$
+        rfc = false;
+      }
+    if (Configuration.DEBUG)
+      {
+        log.fine("-list handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -alias=" + alias); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+        log.fine("  -rfc=" + rfc); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws KeyStoreException, CertificateEncodingException,
+      IOException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    PrintWriter writer = new PrintWriter(outStream, true);
+    writer.println(Messages.getFormattedString("ListCmd.21", store.getType())); //$NON-NLS-1$
+    writer.println(Messages.getFormattedString("ListCmd.22", //$NON-NLS-1$
+                                               store.getProvider().getName()));
+    if (all)
+      {
+        if (Configuration.DEBUG)
+          log.fine("About to list all aliases in key store..."); //$NON-NLS-1$
+        writer.println();
+        writer.println(Messages.getFormattedString("ListCmd.24", //$NON-NLS-1$
+                                                   Integer.valueOf(store.size())));
+        for (Enumeration e = store.aliases(); e.hasMoreElements(); )
+          {
+            String anAlias = (String) e.nextElement();
+            if (anAlias != null)
+              list1Alias(anAlias, writer);
+          }
+      }
+    else
+      list1Alias(alias, writer);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.LIST_CMD, true);
+    result.setHeader(Messages.getString("ListCmd.20")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("ListCmd.19")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("ListCmd.18")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("ListCmd.17"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.16")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("ListCmd.15"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.14")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("ListCmd.13"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.12")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("ListCmd.11"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("ListCmd.9"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("ListCmd.7")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    options.add(new Option(Main.RFC_OPT,
+                           Messages.getString("ListCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        rfc = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  /**
+   * Prints the certificate(s) associated with the designated alias.
+   * 
+   * @param anAlias a non-null string denoting an alias in the key-store.
+   * @param writer where to print.
+   * @throws KeyStoreException if an exception occurs while obtaining the
+   *           certificate associated to the designated alias.
+   * @throws CertificateEncodingException if an exception occurs while obtaining
+   *           the DER encoded form of the certificate.
+   * @throws IOException if an I/O related exception occurs during the process.
+   */
+  private void list1Alias(String anAlias, PrintWriter writer)
+      throws KeyStoreException, CertificateEncodingException, IOException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "list1Alias", anAlias); //$NON-NLS-1$
+    writer.println();
+    writer.println(Messages.getFormattedString("ListCmd.30", anAlias)); //$NON-NLS-1$
+    writer.println(Messages.getFormattedString("ListCmd.31", //$NON-NLS-1$
+                                               store.getCreationDate(anAlias)));
+    if (store.isCertificateEntry(anAlias))
+      {
+        writer.println(Messages.getString("ListCmd.32")); //$NON-NLS-1$
+        Certificate certificate = store.getCertificate(anAlias);
+        print1Certificate(certificate, writer);
+      }
+    else if (store.isKeyEntry(anAlias))
+      {
+        writer.println(Messages.getString("ListCmd.33")); //$NON-NLS-1$
+        Certificate[] chain = store.getCertificateChain(anAlias);
+        print1Chain(chain, writer);
+      }
+    else
+      throw new IllegalArgumentException(Messages.getFormattedString("ListCmd.34", //$NON-NLS-1$
+                                                                     anAlias));
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "list1Alias"); //$NON-NLS-1$
+  }
+
+  /**
+   * Prints the designated certificate chain, or a fingerprint of the first
+   * certificate (bottom) in the chain, depending on the values of the flags
+   * <code>v</code> (for verbose) and <code>rfc</code>.
+   * <p>
+   * If both flags are <code>false</code>, only the fingerprint is generated,
+   * otherwise, if the <code>v</code> flag is set, then a human readable output
+   * is generated. If <code>rfc</code> is set, then an RFC-1421 like output
+   * is generated.
+   * <p>Note that both <code>v</code> and <code>rfc</code> cannot both be
+   * <code>true</code> at the same time.
+   * 
+   * @param chain the certificate chain to process.
+   * @param writer where to print.
+   * @throws CertificateEncodingException if an exception occurs while obtaining
+   *           the DER encoded form of the certificate.
+   */
+  private void print1Chain(Certificate[] chain, PrintWriter writer)
+      throws CertificateEncodingException
+  {
+    if (! verbose && ! rfc)
+      fingerprint(chain[0], writer);
+    else
+      {
+        int limit = chain.length;
+        writer.println(Messages.getFormattedString("ListCmd.38", //$NON-NLS-1$
+                                                   Integer.valueOf(limit)));
+        writer.println(Messages.getString("ListCmd.39")); //$NON-NLS-1$
+        print1Certificate(chain[0], writer);
+        for (int i = 1; i < limit; i++)
+          {
+            writer.println();
+            writer.println(Messages.getFormattedString("ListCmd.40", //$NON-NLS-1$
+                                                       Integer.valueOf(i + 1)));
+            print1Certificate(chain[i], writer);
+          }
+        writer.println();
+        writer.println(Messages.getString("ListCmd.42")); //$NON-NLS-1$
+      }
+  }
+
+  /**
+   * Prints the designated certificate, or its fingerprint, depending on the
+   * values of the flags <code>v</code> (for verbose) and <code>rfc</code>.
+   * <p>
+   * If both flags are <code>false</code>, only a fingerprint is generated,
+   * otherwise, if the <code>v</code> flag is set, then a human readable output
+   * is generated. If <code>rfc</code> is set, then an RFC-1421 like output
+   * is generated.
+   * <p>Note that both <code>v</code> and <code>rfc</code> cannot both be
+   * <code>true</code> at the same time.
+   * 
+   * @param certificate the certificate to process.
+   * @param writer where to print.
+   * @throws CertificateEncodingException if an exception occurs while obtaining
+   *           the DER encoded form of the certificate.
+   */
+  private void print1Certificate(Certificate certificate, PrintWriter writer)
+      throws CertificateEncodingException
+  {
+    if (verbose)
+      printVerbose(certificate, writer);
+    else if (rfc)
+      printRFC1421(certificate, writer);
+    else
+      fingerprint(certificate, writer);
+  }
+
+  private void printRFC1421(Certificate certificate, PrintWriter writer)
+      throws CertificateEncodingException
+  {
+    byte[] derBytes = certificate.getEncoded();
+    String encoded = Base64.encode(derBytes, 0, derBytes.length, true);
+    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$
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,337 @@
+/* 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.ProviderUtil;
+import gnu.classpath.tools.getopt.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.Registry;
+import gnu.javax.crypto.jce.GnuCrypto;
+import gnu.javax.security.auth.callback.GnuCallbacks;
+
+import java.util.logging.Logger;
+
+/**
+ * The GNU Classpath implementation of the keytool security tool.
+ * <p>
+ * Except for the <code>-identitydb</code> command, available for importing
+ * JDK 1.1 <i>identities</i> into a key store, this implementation is intended
+ * to be compatible with the behaviour described in the public documentation of
+ * the same tool included in JDK 1.4.
+ */
+public class Main
+{
+  private static final Logger log = Logger.getLogger(Main.class.getName());
+  static final String KEYTOOL_TOOL = "keytool"; //$NON-NLS-1$
+  static final String GENKEY_CMD = "genkey"; //$NON-NLS-1$
+  static final String IMPORT_CMD = "import"; //$NON-NLS-1$
+  static final String SELFCERT_CMD = "selfcert"; //$NON-NLS-1$
+  static final String IDENTITYDB_CMD = "identitydb"; //$NON-NLS-1$
+  static final String CERTREQ_CMD = "certreq"; //$NON-NLS-1$
+  static final String EXPORT_CMD = "export"; //$NON-NLS-1$
+  static final String LIST_CMD = "list"; //$NON-NLS-1$
+  static final String PRINTCERT_CMD = "printcert"; //$NON-NLS-1$
+  static final String KEYCLONE_CMD = "keyclone"; //$NON-NLS-1$
+  static final String STOREPASSWD_CMD = "storepasswd"; //$NON-NLS-1$
+  static final String KEYPASSWD_CMD = "keypasswd"; //$NON-NLS-1$
+  static final String DELETE_CMD = "delete"; //$NON-NLS-1$
+  static final String CACERT_CMD = "cacert"; //$NON-NLS-1$
+
+  static final String _GENKEY = "-" + GENKEY_CMD; //$NON-NLS-1$
+  static final String _IMPORT = "-" + IMPORT_CMD; //$NON-NLS-1$
+  static final String _SELFCERT = "-" + SELFCERT_CMD; //$NON-NLS-1$
+  static final String _IDENTITYDB = "-" + IDENTITYDB_CMD; //$NON-NLS-1$
+  static final String _CERTREQ = "-" + CERTREQ_CMD; //$NON-NLS-1$
+  static final String _EXPORT = "-" + EXPORT_CMD; //$NON-NLS-1$
+  static final String _LIST = "-" + LIST_CMD; //$NON-NLS-1$
+  static final String _PRINTCERT = "-" + PRINTCERT_CMD; //$NON-NLS-1$
+  static final String _KEYCLONE = "-" + KEYCLONE_CMD; //$NON-NLS-1$
+  static final String _STOREPASSWD = "-" + STOREPASSWD_CMD; //$NON-NLS-1$
+  static final String _KEYPASSWD = "-" + KEYPASSWD_CMD; //$NON-NLS-1$
+  static final String _DELETE = "-" + DELETE_CMD; //$NON-NLS-1$
+  static final String _HELP = "-help"; //$NON-NLS-1$
+  static final String _CACERT = "-" + CACERT_CMD; //$NON-NLS-1$
+
+  static final String ALIAS_OPT = "alias"; //$NON-NLS-1$
+  static final String SIGALG_OPT = "sigalg"; //$NON-NLS-1$
+  static final String KEYALG_OPT = "keyalg"; //$NON-NLS-1$
+  static final String KEYSIZE_OPT = "keysize"; //$NON-NLS-1$
+  static final String KEYPASS_OPT = "keypass"; //$NON-NLS-1$
+  static final String VALIDITY_OPT = "validity"; //$NON-NLS-1$
+  static final String STORETYPE_OPT = "storetype"; //$NON-NLS-1$
+  static final String STOREPASS_OPT = "storepass"; //$NON-NLS-1$
+  static final String KEYSTORE_OPT = "keystore"; //$NON-NLS-1$
+  static final String PROVIDER_OPT = "provider"; //$NON-NLS-1$
+  static final String FILE_OPT = "file"; //$NON-NLS-1$
+  static final String VERBOSE_OPT = "v"; //$NON-NLS-1$
+  static final String DEST_OPT = "dest"; //$NON-NLS-1$
+  static final String NEW_OPT = "new"; //$NON-NLS-1$
+  static final String RFC_OPT = "rfc"; //$NON-NLS-1$
+  static final String DNAME_OPT = "dname"; //$NON-NLS-1$
+
+  /** The Preferences key name for the last issued certificate serial nbr. */
+  static final String LAST_SERIAL_NUMBER = "lastSerialNumber"; //$NON-NLS-1$
+  /** Constant denoting the X.509 certificate type. */
+  static final String X_509 = "X.509"; //$NON-NLS-1$
+
+  /** Whether we have already printed the help text or not. */
+  private boolean helpPrinted;
+  /** The new position of GnuCRYPTO provider if it is not already installed. */
+  private int gnuCryptoProviderNdx = -2;
+  /** The new position of GNU Callbacks provider if it is not already installed. */
+  private int gnuCallbacksNdx = -2;
+  /** The command line parser. */
+  private Parser cmdLineParser;
+  /** The shutdown hook. */
+  private ShutdownHook shutdownThread;
+
+  private Main()
+  {
+    super();
+    shutdownThread = new ShutdownHook();
+    Runtime.getRuntime().addShutdownHook(shutdownThread);
+  }
+
+  public static final void main(String[] args)
+  {
+    if (Configuration.DEBUG)
+      log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
+    Main tool = new Main();
+    int result = 1;
+    try
+      {
+        tool.setup();
+        tool.start(args);
+        result = 0;
+      }
+    catch (OptionException x)
+      {
+        System.err.println(x.getMessage());
+        if (tool.cmdLineParser != null)
+          tool.cmdLineParser.printHelp();
+      }
+    catch (SecurityException x)
+      {
+        if (Configuration.DEBUG)
+          log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+        System.err.println(Messages.getFormattedString("Main.6", //$NON-NLS-1$
+                                                       x.getMessage()));
+      }
+    catch (Exception x)
+      {
+        if (Configuration.DEBUG)
+          log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
+        System.err.println(Messages.getFormattedString("Main.8", x)); //$NON-NLS-1$
+      }
+    finally
+      {
+        tool.teardown();
+        if (tool.shutdownThread != null)
+          Runtime.getRuntime().removeShutdownHook(tool.shutdownThread);
+      }
+    if (Configuration.DEBUG)
+      log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
+    System.exit(result);
+  }
+
+  // helper methods -----------------------------------------------------------
+
+  private void setup()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "setup"); //$NON-NLS-1$
+    cmdLineParser = getParser();
+    gnuCryptoProviderNdx = ProviderUtil.addProvider(new GnuCrypto());
+    gnuCallbacksNdx = ProviderUtil.addProvider(new GnuCallbacks());
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "setup"); //$NON-NLS-1$
+  }
+
+  private void start(String[] args) throws Exception
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    if (args == null || args.length == 0)
+      throw new OptionException(""); //$NON-NLS-1$
+
+    String opt;
+    Command cmd;
+    while (args.length > 0)
+      {
+        opt = args[0];
+        cmd = null;
+        if (_GENKEY.equals(opt))
+          cmd = new GenKeyCmd();
+        else if (_IMPORT.equals(opt))
+          cmd = new ImportCmd();
+        else if (_SELFCERT.equals(opt))
+          cmd = new SelfCertCmd();
+        else if (_IDENTITYDB.equals(opt))
+          cmd = new IdentityDBCmd();
+        else if (_CERTREQ.equals(opt))
+          cmd = new CertReqCmd();
+        else if (_EXPORT.equals(opt))
+          cmd = new ExportCmd();
+        else if (_LIST.equals(opt))
+          cmd = new ListCmd();
+        else if (_PRINTCERT.equals(opt))
+          cmd = new PrintCertCmd();
+        else if (_KEYCLONE.equals(opt))
+          cmd = new KeyCloneCmd();
+        else if (_STOREPASSWD.equals(opt))
+          cmd = new StorePasswdCmd();
+        else if (_KEYPASSWD.equals(opt))
+          cmd = new KeyPasswdCmd();
+        else if (_DELETE.equals(opt))
+          cmd = new DeleteCmd();
+        else if (_CACERT.equals(opt))
+          cmd = new CACertCmd();
+        else if (_HELP.equals(opt))
+          throw new OptionException(""); //$NON-NLS-1$
+        else
+          throw new OptionException(Messages.getFormattedString("Main.18", //$NON-NLS-1$
+                                                                opt));
+
+        String[] cmdArgs = new String[args.length - 1];
+        System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
+        args = cmd.processArgs(cmdArgs);
+        cmd.doCommand();
+      }
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  private Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(KEYTOOL_TOOL, true);
+    result.setHeader(Messages.getString("Main.19")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("Main.20")); //$NON-NLS-1$
+    OptionGroup cmdGroup = new OptionGroup(Messages.getString("Main.21")); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(GENKEY_CMD,
+                                   Messages.getString("Main.22"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(IMPORT_CMD,
+                                   Messages.getString("Main.23"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(SELFCERT_CMD,
+                                   Messages.getString("Main.24"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(IDENTITYDB_CMD,
+                                   Messages.getString("Main.25"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(CERTREQ_CMD,
+                                   Messages.getString("Main.26"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(EXPORT_CMD,
+                                   Messages.getString("Main.27"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(LIST_CMD,
+                                   Messages.getString("Main.28"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(PRINTCERT_CMD,
+                                   Messages.getString("Main.29"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(KEYCLONE_CMD,
+                                   Messages.getString("Main.30"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(STOREPASSWD_CMD,
+                                   Messages.getString("Main.31"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(KEYPASSWD_CMD,
+                                   Messages.getString("Main.32"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(DELETE_CMD,
+                                   Messages.getString("Main.33"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(CACERT_CMD,
+                                   Messages.getString("Main.5"))); //$NON-NLS-1$
+    result.add(cmdGroup);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  void teardown()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+    // if we added our own providers remove them
+    if (gnuCryptoProviderNdx > 0)
+      ProviderUtil.removeProvider(Registry.GNU_CRYPTO);
+
+    if (gnuCallbacksNdx > 0)
+      ProviderUtil.removeProvider("GNU-CALLBACKS"); //$NON-NLS-1$
+
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "teardown"); //$NON-NLS-1$
+  }
+
+  private void printHelp()
+  {
+    if (helpPrinted)
+      return;
+
+    helpPrinted = true;
+  }
+
+  // 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();
+    }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* Messages.java -- I18N related helper class
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING.  If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library.  Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module.  An independent module is a module which is not derived from
+ or based on this library.  If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so.  If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.keytool;
+
+import gnu.classpath.Configuration;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+/**
+ * An initially generated Eclipse helper class to ease the use of localized
+ * messages.
+ * <p>
+ * Enriched to handle localized message formats.
+ */
+class Messages
+{
+  private static final Logger log = Logger.getLogger(Messages.class.getName());
+  private static final String BUNDLE_NAME = "gnu.classpath.tools.keytool.messages";
+  private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+  private static final Map CACHED_FORMATS = new HashMap(5);
+
+  private Messages()
+  {
+    super();
+  }
+
+  public static String getString(String key)
+  {
+    try
+      {
+        return RESOURCE_BUNDLE.getString(key);
+      }
+    catch (MissingResourceException e)
+      {
+        return constructMessage(key, null);
+      }
+  }
+
+  public static String getFormattedString(String key, Object args)
+  {
+    MessageFormat mf = (MessageFormat) CACHED_FORMATS.get(key);
+    if (mf == null)
+      {
+        String formatString = getString(key);
+        if (formatString.startsWith("!"))
+          return constructMessage(key, args);
+
+          mf = new MessageFormat(formatString);
+          CACHED_FORMATS.put(key, mf);
+      }
+
+    // if the argument is not an array, then build one consisting of the
+    // sole argument before passing it to the format() method
+    try
+      {
+        if (args instanceof Object[])
+          return mf.format(args);
+
+        return mf.format(new Object[] { args });
+      }
+    catch (IllegalArgumentException x)
+      {
+        if (Configuration.DEBUG)
+          log.fine("Exception while rendering a message format keyed by ["
+                   + key + "]: " + mf.toPattern());
+        return constructMessage(mf.toPattern(), args);
+      }
+  }
+
+  private static final String constructMessage(String m, Object args)
+  {
+    if (args == null)
+      return '!' + m + '!';
+
+    return '!' + m + '!' + String.valueOf(args) + '!';
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java Thu Nov  8 16:56:19 2007
@@ -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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.PrintWriter;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.util.logging.Logger;
+
+/**
+ * The <b>-printcert</b> keytool command handler is used to read a certificate
+ * from a designated file, and print its contents in a human-readable format.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-file FILE_NAME</dt>
+ *      <dd>The fully qualified path of the file to read the certificate from.
+ *      If this option is omitted, the tool will process STDIN.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class PrintCertCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(PrintCertCmd.class.getName());
+  protected String _certFileName;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param pathName the fully qualified path name of the file to process. */
+  public void setFile(String pathName)
+  {
+    this._certFileName = pathName;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setInputStreamParam(_certFileName);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-printcert handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -file=" + _certFileName); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws CertificateException
+  {
+    if (Configuration.DEBUG)
+      log.entering(getClass().getName(), "start"); //$NON-NLS-1$
+    CertificateFactory x509Factory = CertificateFactory.getInstance(Main.X_509);
+    Certificate certificate = x509Factory.generateCertificate(inStream);
+    PrintWriter writer = new PrintWriter(System.out, true);
+    writer.println();
+    printVerbose(certificate, writer);
+    if (Configuration.DEBUG)
+      log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.PRINTCERT_CMD, true);
+    result.setHeader(Messages.getString("PrintCertCmd.5")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("PrintCertCmd.6")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("PrintCertCmd.7")); //$NON-NLS-1$
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("PrintCertCmd.8"), //$NON-NLS-1$
+                           Messages.getString("PrintCertCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _certFileName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("PrintCertCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java Thu Nov  8 16:56:19 2007
@@ -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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.security.x509.X500DistinguishedName;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.x500.X500Principal;
+
+/**
+ * The <b>-selfcert</b> keytool command handler is used to generate a self-
+ * signed X.509 version 1 certificate using key store credentials stored under a
+ * designated alias.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-alias ALIAS</dt>
+ *      <dd>Every entry, be it a <i>Key Entry</i> or a <i>Trusted
+ *      Certificate</i>, in a key store is uniquely identified by a user-defined
+ *      <i>Alias</i> string. Use this option to specify the <i>Alias</i> to use
+ *      when referring to an entry in the key store. Unless specified otherwise,
+ *      a default value of <code>mykey</code> shall be used when this option is
+ *      omitted from the command line.
+ *      <p></dd>
+ *      
+ *      <dt>-sigalg ALGORITHM</dt>
+ *      <dd>The canonical name of the digital signature algorithm to use for
+ *      signing the certificate. If this option is omitted, a default value will
+ *      be chosen based on the type of the private key associated with the
+ *      designated <i>Alias</i>. If the private key is a <code>DSA</code> one,
+ *      the value for the signature algorithm will be <code>SHA1withDSA</code>.
+ *      If on the other hand the private key is an <code>RSA</code> one, then
+ *      the tool will use <code>MD5withRSA</code> as the signature algorithm.
+ *      <p></dd>
+ *      
+ *      <dt>-dname NAME</dt>
+ *      <dd>Use this option to specify the <i>Distinguished Name</i> of the
+ *      newly generated self-signed certificate. If this option is omitted, the
+ *      existing <i>Distinguished Name</i> of the base certificate in the chain
+ *      associated with the designated <i>Alias</i> will be used instead.
+ *      <p>
+ *      The syntax of a valid value for this option MUST follow RFC-2253
+ *      specifications. Namely the following components (with their accepted
+ *      meaning) will be recognized. Note that the component name is case-
+ *      insensitive:
+ *      <dl>
+ *              <dt>CN</dt>
+ *              <dd>The Common Name; e.g. "host.domain.com"</dd>
+ *              
+ *              <dt>OU</dt>
+ *              <dd>The Organizational Unit; e.g. "IT Department"</dd>
+ *              
+ *              <dt>O</dt>
+ *              <dd>The Organization Name; e.g. "The Sample Company"</dd>
+ *              
+ *              <dt>L</dt>
+ *              <dd>The Locality Name; e.g. "Sydney"</dd>
+ *              
+ *              <dt>ST</dt>
+ *              <dd>The State Name; e.g. "New South Wales"</dd>
+ *              
+ *              <dt>C</dt>
+ *              <dd>The 2-letter Country identifier; e.g. "AU"</dd>
+ *      </dl>
+ *      <p>
+ *      When specified with a <code>-dname</code> option, each pair of component
+ *      / value will be separated from the other with a comma. Each component
+ *      and value pair MUST be separated by an equal sign. For example, the
+ *      following is a valid DN value:
+ *      <pre>
+ *        CN=host.domain.com, O=The Sample Company, L=Sydney, ST=NSW, C=AU
+ *      </pre>
+ *      <p></dd>
+ *      
+ *      <dt>-validity DAY_COUNT</dt>
+ *      
+ *      <dt>-keypass PASSWORD</dt>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class SelfCertCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(SelfCertCmd.class.getName());
+  protected String _alias;
+  protected String _sigAlgorithm;
+  protected String _dName;
+  protected String _password;
+  protected String _validityStr;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  private X500DistinguishedName distinguishedName;
+  private int validityInDays;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param alias the alias to use. */
+  public void setAlias(String alias)
+  {
+    this._alias = alias;
+  }
+
+  /**
+   * @param algorithm the canonical name of the digital signature algorithm to
+   *          use.
+   */
+  public void setSigalg(String algorithm)
+  {
+    this._sigAlgorithm = algorithm;
+  }
+
+  /**
+   * @param name the distiniguished name of both the issuer and subject (since
+   *          we are dealing with a self-signed certificate) to use.
+   */
+  public void setDname(String name)
+  {
+    this._dName = name;
+  }
+
+  /**
+   * @param days the string representation of the number of days (a decimal,
+   *          positive integer) to assign to the generated (self-signed)
+   *          certificate.
+   */
+  public void setValidity(String days)
+  {
+    this._validityStr = days;
+  }
+
+  /** @param password the (private) key password to use. */
+  public void setKeypass(String password)
+  {
+    this._password = password;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    setAliasParam(_alias);
+    setKeyPasswordNoPrompt(_password);
+    setValidityParam(_validityStr);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-selfcert handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -alias=" + alias); //$NON-NLS-1$
+        log.fine("  -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
+        log.fine("  -dname=" + _dName); //$NON-NLS-1$
+        log.fine("  -validity=" + validityInDays); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws KeyStoreException, NoSuchAlgorithmException,
+      UnrecoverableKeyException, IOException, UnsupportedCallbackException,
+      InvalidKeyException, SignatureException, CertificateException
+  {
+    if (Configuration.DEBUG)
+      log.entering(getClass().getName(), "start"); //$NON-NLS-1$
+    // 1. get the key entry and certificate chain associated to alias
+    Key privateKey = getAliasPrivateKey();
+    Certificate[] chain = store.getCertificateChain(alias);
+
+    // 2. if the user has not supplied a DN use one from the certificate chain
+    X509Certificate bottomCertificate = (X509Certificate) chain[0];
+    X500Principal defaultPrincipal = bottomCertificate.getIssuerX500Principal();
+    setDName(_dName, defaultPrincipal);
+
+    // 4. get alias's public key from certificate's SubjectPublicKeyInfo
+    PublicKey publicKey = bottomCertificate.getPublicKey();
+
+    // 5. issue the self-signed certificate
+    setSignatureAlgorithmParam(_sigAlgorithm, privateKey);
+
+    byte[] derBytes = getSelfSignedCertificate(distinguishedName,
+                                               publicKey,
+                                               (PrivateKey) privateKey);
+    CertificateFactory x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
+    ByteArrayInputStream bais = new ByteArrayInputStream(derBytes);
+    Certificate certificate = x509Factory.generateCertificate(bais);
+
+    // 6. store it, w/ its private key, associating them to alias
+    chain = new Certificate[] { certificate };
+    store.setKeyEntry(alias, privateKey, keyPasswordChars, chain);
+
+    // 7. persist the key store
+    saveKeyStore();
+    if (Configuration.DEBUG)
+      log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.SELFCERT_CMD, true);
+    result.setHeader(Messages.getString("SelfCertCmd.14")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("SelfCertCmd.15")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("SelfCertCmd.16")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("SelfCertCmd.17"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.18")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.SIGALG_OPT,
+                           Messages.getString("SelfCertCmd.19"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.20")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _sigAlgorithm = argument;
+      }
+    });
+    options.add(new Option(Main.DNAME_OPT,
+                           Messages.getString("SelfCertCmd.21"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.22")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _dName = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("SelfCertCmd.23"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.24")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option(Main.VALIDITY_OPT,
+                           Messages.getString("SelfCertCmd.25"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.26")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _validityStr = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("SelfCertCmd.27"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.28")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("SelfCertCmd.29"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.30")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("SelfCertCmd.31"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.32")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("SelfCertCmd.33"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.34")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("SelfCertCmd.35")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  private void setDName(String name, X500Principal defaultName)
+  {
+    if (name != null && name.trim().length() > 0)
+      name = name.trim();
+    else
+      {
+        // If dname is supplied at the command line, it is used as the X.500
+        // Distinguished Name for both the issuer and subject of the certificate.
+        // Otherwise, the X.500 Distinguished Name associated with alias (at the
+        // bottom of its existing certificate chain) is used.
+        name = defaultName.toString().trim();
+      }
+
+    distinguishedName = new X500DistinguishedName(name);
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java Thu Nov  8 16:56:19 2007
@@ -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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.IOException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.Arrays;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * The <b>-storepasswd</b> keytool command handler is used to change the
+ * password which protects the integrity of the key store.
+ * <p>
+ * Possible options for this command are:
+ * <p>
+ * <dl>
+ *      <dt>-new PASSWORD</dt>
+ *      <dd>The new, and different, password which will be used to protect the
+ *      designated key store.
+ *      <p></dd>
+ *      
+ *      <dt>-storetype STORE_TYPE</dt>
+ *      <dd>Use this option to specify the type of the key store to use. The
+ *      default value, if this option is omitted, is that of the property
+ *      <code>keystore.type</code> in the security properties file, which is
+ *      obtained by invoking the {@link java.security.KeyStore#getDefaultType()}
+ *      static method.
+ *      <p></dd>
+ *      
+ *      <dt>-keystore URL</dt>
+ *      <dd>Use this option to specify the location of the key store to use.
+ *      The default value is a file {@link java.net.URL} referencing the file
+ *      named <code>.keystore</code> located in the path returned by the call to
+ *      {@link java.lang.System#getProperty(String)} using <code>user.home</code>
+ *      as argument.
+ *      <p>
+ *      If a URL was specified, but was found to be malformed --e.g. missing
+ *      protocol element-- the tool will attempt to use the URL value as a file-
+ *      name (with absolute or relative path-name) of a key store --as if the
+ *      protocol was <code>file:</code>.
+ *      <p></dd>
+ *      
+ *      <dt>-storepass PASSWORD</dt>
+ *      <dd>Use this option to specify the password protecting the key store. If
+ *      this option is omitted from the command line, you will be prompted to
+ *      provide a password.
+ *      <p></dd>
+ *      
+ *      <dt>-provider PROVIDER_CLASS_NAME</dt>
+ *      <dd>A fully qualified class name of a Security Provider to add to the
+ *      current list of Security Providers already installed in the JVM in-use.
+ *      If a provider class is specified with this option, and was successfully
+ *      added to the runtime --i.e. it was not already installed-- then the tool
+ *      will attempt to removed this Security Provider before exiting.
+ *      <p></dd>
+ *      
+ *      <dt>-v</dt>
+ *      <dd>Use this option to enable more verbose output.</dd>
+ * </dl>
+ */
+class StorePasswdCmd extends Command
+{
+  private static final Logger log = Logger.getLogger(StorePasswdCmd.class.getName());
+  protected String _newPassword;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  private char[] newStorePasswordChars;
+
+  // default 0-arguments constructor
+
+  // public setters -----------------------------------------------------------
+
+  /** @param password the new key-store password to use. */
+  public void setNew(String password)
+  {
+    this._newPassword = password;
+  }
+
+  /** @param type the key-store type to use. */
+  public void setStoretype(String type)
+  {
+    this._ksType = type;
+  }
+
+  /** @param url the key-store URL to use. */
+  public void setKeystore(String url)
+  {
+    this._ksURL = url;
+  }
+
+  /** @param password the key-store password to use. */
+  public void setStorepass(String password)
+  {
+    this._ksPassword = password;
+  }
+
+  /** @param className a security provider fully qualified class name to use. */
+  public void setProvider(String className)
+  {
+    this._providerClassName = className;
+  }
+
+  // life-cycle methods -------------------------------------------------------
+
+  void setup() throws Exception
+  {
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    setNewKeystorePassword(_newPassword);
+    if (Configuration.DEBUG)
+      {
+        log.fine("-storepasswd handler will use the following options:"); //$NON-NLS-1$
+        log.fine("  -storetype=" + storeType); //$NON-NLS-1$
+        log.fine("  -keystore=" + storeURL); //$NON-NLS-1$
+        log.fine("  -provider=" + provider); //$NON-NLS-1$
+        log.fine("  -v=" + verbose); //$NON-NLS-1$
+      }
+  }
+
+  void start() throws KeyStoreException, NoSuchAlgorithmException,
+      CertificateException, IOException
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
+    saveKeyStore(newStorePasswordChars);
+    if (Configuration.DEBUG)
+      log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    if (Configuration.DEBUG)
+      log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+    Parser result = new ClasspathToolParser(Main.STOREPASSWD_CMD, true);
+    result.setHeader(Messages.getString("StorePasswdCmd.18")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("StorePasswdCmd.17")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("StorePasswdCmd.16")); //$NON-NLS-1$
+    options.add(new Option(Main.NEW_OPT,
+                           Messages.getString("StorePasswdCmd.15"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _newPassword = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("StorePasswdCmd.13"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.12")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("StorePasswdCmd.11"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("StorePasswdCmd.9"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("StorePasswdCmd.7"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("StorePasswdCmd.5")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+    if (Configuration.DEBUG)
+      log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
+  protected void setNewKeystorePassword(String password) throws IOException,
+      UnsupportedCallbackException
+  {
+    if (password != null)
+      newStorePasswordChars = password.toCharArray();
+    else
+      {
+        boolean ok = false;
+        Callback[] prompts = new Callback[1];
+        Callback[] errors = new Callback[1];
+        for (int i = 0; i < 3; i++)
+          if (prompt4NewPassword(getCallbackHandler(), prompts, errors))
+            {
+              ok = true;
+              break;
+            }
+        if (! ok)
+          throw new SecurityException(Messages.getString("StorePasswdCmd.19")); //$NON-NLS-1$
+      }
+  }
+
+  private boolean prompt4NewPassword(CallbackHandler handler,
+                                     Callback[] prompts, Callback[] errors)
+      throws IOException, UnsupportedCallbackException
+  {
+    // prompt user (1st time) to provide one
+    String p = Messages.getString("StorePasswdCmd.20"); //$NON-NLS-1$
+    PasswordCallback pcb = new PasswordCallback(p, false);
+    prompts[0] = pcb;
+    handler.handle(prompts);
+    char[] pwd1 = pcb.getPassword();
+    pcb.clearPassword();
+    String ls = SystemProperties.getProperty("line.separator"); //$NON-NLS-1$
+    if (pwd1 == null || pwd1.length < 6)
+      {
+        String m = Messages.getString("StorePasswdCmd.21") + ls; //$NON-NLS-1$
+        errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+        handler.handle(errors);
+        return false;
+      }
+
+    if (Arrays.equals(storePasswordChars, pwd1))
+      {
+        String m = Messages.getString("StorePasswdCmd.22") + ls; //$NON-NLS-1$
+        errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+        handler.handle(errors);
+        return false;
+      }
+
+    // prompt user (2nd time) for confirmation
+    pcb = new PasswordCallback(Messages.getString("StorePasswdCmd.23"), false); //$NON-NLS-1$
+    prompts[0] = pcb;
+    handler.handle(prompts);
+    char[] pwd2 = pcb.getPassword();
+    pcb.clearPassword();
+    if (! Arrays.equals(pwd1, pwd2))
+      {
+        String m = Messages.getString("StorePasswdCmd.24") + ls; //$NON-NLS-1$
+        errors[0] = new TextOutputCallback(TextOutputCallback.ERROR, m);
+        handler.handle(errors);
+        return false;
+      }
+
+    newStorePasswordChars = pwd2;
+    return true;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/keytool/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.classpath.tools.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. -->
+
+<html>
+<head>
+<title>GNU Classpath - gnu.classpath.tools.keytool</title>
+</head>
+
+<body>
+This package contains the classes that provide an implementation of the
+Security Tool: <code>keytool</code>. The behaviour of these classes should
+match that of the same tool provided in the RI version 1.4.2, except for the
+following:
+
+<ul>
+  <li>The RI tool accepts -J<i>javaoption</i> options which it then passes to
+  the underlying JVM.  This is because the RI tool acts as a <i>wrapper</i>
+  around the JVM launcher.
+  <p>
+  This implementation DOES NOT support these options.
+  </li>
+
+  <li>The RI tool is capable of importing JDK-1.1 style <i>identities</i>.
+  <p>
+  This implementation does not offer this feature.
+  </li>
+</ul>
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java Thu Nov  8 16:56:19 2007
@@ -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 + '!';
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,185 @@
+/* Native2ASCII.java - native2ascii program
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library.  Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module.  An independent module is a module which is not derived from
+ or based on this library.  If you modify this library, you may extend
+ this exception to your version of the library, but you are 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.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+/**
+ * Native2ASCII main program.
+ * @author Ito Kazumitsu <kaz at maczuka.gcd.org>
+ */
+public class Native2ASCII
+{
+  // Input file.
+  String input;
+  // Output file.
+  String output;
+  // Encoding to use.
+  String encoding;
+  // True for reverse operation.
+  boolean reversed;
+
+  private class HandleFile extends FileArgumentCallback
+  {
+    public HandleFile()
+    {
+    }
+
+    public void notifyFile(String fileArgument)
+      throws OptionException
+    {
+      if (input == null)
+        input = fileArgument;
+      else if (output == null)
+        output = fileArgument;
+      else
+        throw new OptionException(Messages.getString("Native2ASCII.TooManyFiles")); //$NON-NLS-1$
+    }
+  }
+
+  private Parser createParser()
+  {
+    Parser result = new ClasspathToolParser("native2ascii", true); //$NON-NLS-1$
+    result.setHeader(Messages.getString("Native2ASCII.Usage")); //$NON-NLS-1$
+
+    result.add(new Option("encoding", Messages.getString("Native2ASCII.EncodingHelp"), Messages.getString("Native2ASCII.EncodingArgName")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        if (encoding != null)
+          throw new OptionException(Messages.getString("Native2ASCII.EncodingSpecified")); //$NON-NLS-1$
+        encoding = argument;
+      }
+    });
+    result.add(new Option("reversed", Messages.getString("Native2ASCII.ReversedHelp")) //$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;
+            StringBuffer sb = new StringBuffer(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);
+    String encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/Persistent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/Persistent.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/Persistent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/Persistent.java Thu Nov  8 16:56:19 2007
@@ -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.rmi;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * The static fields, shared by the multiple classes, implementing the
+ * persistent work.
+ * 
+ * @author Audrius Meskauskas (audriusa at 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();  
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,268 @@
+/* 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.rmi;
+
+import gnu.classpath.tools.rmi.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 at 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();
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/PersistentHashTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/PersistentHashTable.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/PersistentHashTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/PersistentHashTable.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,246 @@
+/* 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.rmi;
+
+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 at 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;
+        if (file.exists())
+          {
+            if (coldStart)
+              {
+                file.delete();
+                k2v = new PersistentHashTable(file);
+              }
+            else
+              {
+                FileInputStream fi = new FileInputStream(file);
+                BufferedInputStream b = new BufferedInputStream(fi);
+                ObjectInputStream oin = new ObjectInputStream(b);
+
+                k2v = (PersistentHashTable) oin.readObject();
+                oin.close();
+              }
+          }
+        else
+          k2v = new PersistentHashTable(file);
+        
+        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;
+  }
+
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/REGISTRY.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/REGISTRY.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/REGISTRY.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/REGISTRY.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,165 @@
+/* REGISTY.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.rmi;
+
+import gnu.classpath.tools.HelpPrinter;
+import gnu.classpath.tools.rmi.registry.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 at bioinformatics.org)
+ */
+public class REGISTRY
+{
+  /**
+   * 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;
+  
+  /**
+   * The RMI registry implementation entry point.
+   */
+  public static void main(String[] args)
+  {
+    String HelpPath = "rmi/REGISTRY.txt";
+    HelpPrinter.checkHelpKey(args, HelpPath);
+    
+    // Parse parameters:
+    String folder = ".";
+    boolean cold = false;
+    boolean trans = false;
+    boolean stop = false;
+
+    int port = Registry.REGISTRY_PORT;
+    RMIServerSocketFactory ssf = null;
+
+    for (int i = 0; i < args.length; i++)
+      {
+        String a = args[i];
+        if (a.equals("-restart"))
+          cold = true;
+        else if (a.equals("-transient"))
+          trans = true;
+        else if (a.equals("-verbose"))
+          verbose = true;
+        else if (a.equals("-stop"))          
+          stop = true;
+        else if (i < args.length - 1)
+          {
+            // The additional key parameter is possible.
+            if (a.equals("-port"))
+              port = Integer.parseInt(args[++i]);
+            else if (a.equals("-folder"))
+              folder = args[++i];
+          }
+      }
+
+    if (!stop)
+      {
+        Map table;
+        if (trans)
+          table = new Hashtable();
+        else
+          {
+            // Start the system.
+            File dataFolder = new File(folder);
+            if (!dataFolder.exists())
+              dataFolder.mkdirs();
+            table = PersistentHashTable.createInstance(
+              new File(dataFolder, "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 "+
+                               REGISTRY.class.getName());
+        }
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/REGISTRY.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/REGISTRY.txt?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/REGISTRY.txt (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/REGISTRY.txt Thu Nov  8 16:56:19 2007
@@ -0,0 +1,28 @@
+The persistent RMI naming service, required for the remote method invocations
+(packages java.rmi.*, java.rmi.Registry.*).
+
+Copyright 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+
+Usage: rmiregistry <options>
+
+ where <options> includes:
+  -port N        Start the registry on the given local port. If this key
+                 is not specified, the service starts on the port 1099.
+  -verbose       Log binding events to stdout.                
+  -stop          Stop the running naming service at the given port.
+  
+  -transient     Start transient registry service that does not write any
+                 data to the disk. Such service looses the stored bindings if
+                 restarted. If this key is not specified, the 
+                 persistent naming service is started.
+  -restart       "Cold start:, clear the persistent naming database, if any.
+  -folder Folder Store the persistent binding file in the given folder. If this
+                 key is not specified, the file with persistent bindings is 
+                 stored into the current folder.
+                 
+                                
+                

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,186 @@
+/* RMIC.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.
+*/
+
+
+package gnu.classpath.tools.rmi;
+
+import gnu.classpath.tools.HelpPrinter;
+import gnu.classpath.tools.giop.GRMIC;
+import gnu.classpath.tools.rmi.rmic.RmicCompiler;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Generates the ordinary stubs (not GIOP based) for java.rmi.*  package.
+ * 
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org) 
+ */
+public class RMIC
+{
+  /**
+   * The version of the compiler.
+   */
+  public static String VERSION = "0.01 alpha pre";
+  
+  /**
+   * The GRMIC compiler methods
+   * 
+   * @param args the compiler parameters.
+   */
+  public static void main(String[] args)
+  {
+    // Check for the -iiop or -giop keys. If one of these keys is present,
+    // forward all call to GRMIC.
+    for (int i = 0; i < args.length; i++)
+      {
+        if (args[i].equals("-giop") || args[i].equals("-iiop"))
+          {
+            GRMIC.main(args);
+            return;
+          }
+      }
+    
+    boolean noWrite = false;
+    boolean verbose = false;
+
+    String HelpPath = "rmi/RMIC.txt";
+
+    HelpPrinter.checkHelpKey(args, HelpPath);
+
+    File output = new File(".");
+
+    if (args.length == 0)
+      {
+        HelpPrinter.printHelpAndExit(HelpPath);
+      }
+    else
+      {
+        RmicCompiler compiler = new RmicCompiler();
+
+        int cl = - 1;
+
+        Options: for (int i = 0; i < args.length; i++)
+          {
+            String c = args[i];
+            if (c.equals("-v"))
+              {
+                printVersion();
+                System.exit(0);
+              }
+            else if (c.equals("-nowrite"))
+              noWrite = true;
+            else if (c.equals("-nowarn"))
+              compiler.setWarnings(false);
+            else if (c.equals("-verbose"))
+              {
+                verbose = true;
+                compiler.setVerbose(true);
+              }
+            else if (c.equals("-force"))
+              {
+                compiler.setForce(true);
+              }            
+            else if (c.equals("-d"))
+              {
+                int f = i + 1;
+                if (f < args.length)
+                  {
+                    output = new File(args[f]);
+                    i++;
+                  }
+                else
+                  HelpPrinter.printHelpAndExit(HelpPath);
+              }
+            else if (c.equals("-classpath"))
+              {
+                int f = i + 1;
+                if (f < args.length)
+                  {
+                    compiler.setClassPath(args[f]);
+                    i++;
+                  }
+                else
+                  HelpPrinter.printHelpAndExit(HelpPath);
+              }
+            else if (c.charAt(0) != '-')
+            // No more options - start of class list.
+              {
+                cl = i;
+                break Options;
+              }
+          }
+
+        if (cl < 0)
+          HelpPrinter.printHelpAndExit(HelpPath);
+
+        if (verbose)
+          System.out.println("Compiling to " + output.getAbsolutePath());
+
+        // Compile classes
+        Compile: for (int i = cl; i < args.length; i++)
+          {
+            if (args[i].charAt(0) != '-')
+              {
+                compiler.reset();
+                Class c = compiler.loadClass(args[i]);
+
+                compiler.compile(c);
+                String packag = compiler.getPackageName().replace('.', '/');
+                File fw = new File(output, packag);
+
+                // Generate stub.
+                String stub = compiler.generateStub();
+                String subName = compiler.getStubName() + "_Stub.java";
+
+                if (noWrite)
+                  continue Compile;
+
+                try
+                  {
+                    fw.mkdirs();
+                    OutputStream out = new FileOutputStream(new File(fw,
+                                                                     subName));
+                    out.write(stub.getBytes());
+                    out.close();
+                  }
+                catch (IOException ioex)
+                  {
+                    System.err.println("Output path not accessible");
+                    ioex.printStackTrace();
+                    System.exit(1);
+                  }
+              }
+          }
+      }
+  }
+  
+  /**
+   * Print the version information.
+   */
+  public static void printVersion()
+  {
+    System.out.println
+      ("rmic v "+VERSION+" - RMI stub generator for java.rmi.* ");
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.txt?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.txt (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.txt Thu Nov  8 16:56:19 2007
@@ -0,0 +1,45 @@
+RMI stub and tie source code generator for java.rmi.*, javax.rmi.*
+
+Copyright 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+
+Usage: rmic <options> <class names>
+
+ where <options> includes:
+  -nowarn            Show no warnings
+  -nowrite           Do not write any files (check for errors only)
+  -d <folder>        Place generated files into the given folder
+  -classpath <path>  Specifies the path, where to find the classes being 
+                     compiled
+  
+  -help              Print this help text
+  -v                 Print version
+  -verbose           Verbose output
+  -force             Try to generate code even if the input classes seem not
+                     consistent with RMI specification.
+  
+  -1.2               Generate v 1.2 stubs (default)*
+  
+  -iiop              Generate stubs and ties for the GIOP based RMI package 
+                     extension, javax.rmi. With this key, the two additional 
+                     keys are accepted:
+    -poa               Generate the Servant based ties (default)
+    -impl              Generate the obsoleted ObjectImpl based ties
+                        (for backward compatibility)
+    -help            Show more details on the giop stub and tie generator 
+                      options.                
+  -giop              Same as -iiop*                    
+                
+  
+ and <class names> can include one or more non abstract classes that implement
+ Remote and are accessible via current class path.
+
+* This tool generates the source code that must be compiled with java compiler.
+* The deprecated 1.1 version stubs are currently not supported (the v 1.2
+  style stubs are always generated).
+* -iiop is a standard key for this tool, but it is also a registered OMG mark
+  when giop is not.
+

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMID.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMID.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMID.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMID.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,189 @@
+/* RMID.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.rmi;
+
+import gnu.classpath.tools.HelpPrinter;
+import gnu.classpath.tools.rmi.rmid.ActivationSystemImpl;
+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 at bioinformatics.org)
+ */
+public class RMID
+{
+  /**
+   * 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";
+  
+  /**
+   * The RMI activation daemon entry point.
+   */
+  public static void main(String[] args)
+  {
+    String HelpPath = "rmi/RMID.txt";
+    HelpPrinter.checkHelpKey(args, HelpPath);
+    
+    // Parse parameters:
+    boolean stop = false;
+    String folder = ".";
+    boolean cold = false;
+    boolean trans = false;
+    
+    for (int i = 0; i < args.length; i++)
+      {
+        String a = args[i];
+        if (a.equals("-verbose"))
+          ActivationSystemTransient.debug = true;
+        else if (a.equals("-stop"))
+          stop = true;
+        else if (a.equals("-restart"))
+          cold = true;
+        else if (a.equals("-transient"))
+          trans = true;
+        else if (i < args.length - 1)
+          {
+            // The additional key parameter is possible.
+            if (a.equals("-port"))
+              ACTIVATION_REGISTRY_PORT = Integer.parseInt(args[++i]);
+            else if (a.equals("-folder"))
+              folder = args[++i];
+          }
+      }
+
+    try
+      {
+        if (!stop)
+          {
+            // Start the system.
+            File dataFolder = new File(folder);
+            if (!dataFolder.exists())
+              dataFolder.mkdirs();
+            ActivationSystem system;
+            
+            if (trans)
+              system = ActivationSystemTransient.getInstance();
+            else
+              system = ActivationSystemImpl.getInstance(dataFolder, 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();
+      }
+  } 
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMID.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMID.txt?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMID.txt (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/RMID.txt Thu Nov  8 16:56:19 2007
@@ -0,0 +1,30 @@
+The persistent RMI activation daemon, support RMI object activation
+(package java.rmi.activation.*).
+
+Copyright 2006 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+Please report bugs at http://www.gnu.org/software/classpath/bugs.html
+
+Usage: rmid <options>
+
+ where <options> includes:
+  -port N        Start the service on the given local port. If this key
+                 is not specified, the service starts on the port 1098.
+  -verbose       Log registration events to stdout.                
+  -stop          Stop the running  activation service at the given port.
+  
+  -transient     Start transient activation service that does not write any
+                 data to the disk. Such service looses the stored activation
+                 descriptors, if restarted. If this key is not specified, the 
+                 persistent naming service is started.
+  -restart       "Cold start:, clear the activation descriptor database, if any.
+  -folder Folder Store the persistent descriptor file in the given folder. If this
+                 key is not specified, the file with persistent activation 
+                 information is stored into the current folder.
+                 
+All activation groups are activated on the same virtual machine, where the
+daemon is running. For security reasons, all the classes, required for 
+activation, must be available in the classpath of that machine. 
+                 
\ No newline at end of file

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,139 @@
+/* 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.rmi.registry;
+
+import gnu.classpath.tools.rmi.Persistent;
+import gnu.classpath.tools.rmi.REGISTRY;
+
+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 at 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 (REGISTRY.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(REGISTRY.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 (REGISTRY.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 (REGISTRY.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;
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java Thu Nov  8 16:56:19 2007
@@ -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.rmi.registry;
+
+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");
+      }
+  }
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java Thu Nov  8 16:56:19 2007
@@ -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.rmi.registry;
+
+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;
+      }
+  }
+   
+    
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/package.html?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/package.html Thu Nov  8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.rmi.registry package.
+   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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.classpath.tools.rmi.registry</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,287 @@
+/* MethodGenerator.java -- Generates methods for rmi compiler.
+ Copyright (C) 2006 Free Software Foundation
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING.  If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library.  Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+*/
+
+
+package gnu.classpath.tools.rmi.rmic;
+
+import gnu.classpath.tools.AbstractMethodGenerator;
+import gnu.java.rmi.server.RMIHashes;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+/**
+ * Keeps information about the single method and generates the code fragments,
+ * related to that method.
+ * 
+ * @author Audrius Meskauskas, Lithuania (audriusa at Bioinformatics.org)
+ */
+public class RmiMethodGenerator
+    implements AbstractMethodGenerator
+{
+  /**
+   * The method being defined.
+   */
+  Method method;
+
+  /**
+   * The parent code generator.
+   */
+  RmicCompiler rmic;
+  
+  /**
+   * Create the new method generator for the given method.
+   * 
+   * @param aMethod the related method.
+   * @param aRmic the Rmic generator instance, where more class - related
+   *          information is defined.
+   */
+  public RmiMethodGenerator(Method aMethod, RmicCompiler aRmic)
+  {
+    method = aMethod;
+    rmic = aRmic;
+    if (method.getParameterTypes().length == 0)
+      rmic.addZeroSizeObjecArray = true;
+  }
+
+  /**
+   * Get the method parameter declaration.
+   * 
+   * @return the string - method parameter declaration.
+   */
+  public String getArgumentList()
+  {
+    StringBuffer b = new StringBuffer();
+
+    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()
+  {
+    StringBuffer b = new StringBuffer();
+
+    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()
+  {
+    StringBuffer b = new StringBuffer();
+
+    Class[] args = method.getExceptionTypes();
+
+    for (int i = 0; i < args.length; i++)
+      {
+        b.append(rmic.name(args[i]));
+        if (i < args.length - 1)
+          b.append(", ");
+      }
+    return b.toString();
+  }
+
+  /**
+   * Generate this method for the Stub class.
+   * 
+   * @return the method body for the stub class.
+   */
+  public String generateStubMethod()
+  {
+    String templateName;
+
+    Properties vars = new Properties(rmic.vars);
+    vars.put("#return_type", rmic.name(method.getReturnType()));
+    vars.put("#method_name", method.getName());
+    vars.put("#method_hash", getMethodHashCode());
+    vars.put("#argument_list", getArgumentList());
+    vars.put("#object_arg_list", getArgListAsObjectArray());
+    vars.put("#declaring_class", rmic.name(method.getDeclaringClass()));
+    vars.put("#class_arg_list", getArgListAsClassArray());
+
+    String thr = getThrows();
+    if (thr.length() > 0)
+      vars.put("#throws", "\n    throws " + thr);
+    else
+      vars.put("#throws", "");
+
+    if (method.getReturnType().equals(void.class))
+      templateName = "Stub_12MethodVoid.jav";
+    else
+      {
+        templateName = "Stub_12Method.jav";
+        vars.put("#return_statement", getReturnStatement());
+      }
+
+    String template = rmic.getResource(templateName);
+    String generated = rmic.replaceAll(template, vars);
+    return generated;
+  }
+
+  /**
+   * Generate sentences for Reading and Defining Arguments.
+   * 
+   * @return the sequence of sentences for reading and defining arguments.
+   */
+  public String getStaticMethodDeclarations()
+  {
+    StringBuffer b = new StringBuffer();
+    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";
+    
+    StringBuffer b = new StringBuffer("new Object[] {");
+
+    for (int i = 0; i < args.length; i++)
+      {
+        if (!args[i].isPrimitive())
+          b.append("p"+i);
+        else
+          {
+            b.append("new "+rmic.name(WrapUnWrapper.getWrappingClass(args[i])));
+            b.append("(p"+i+")");
+          }
+        if (i<args.length-1)
+          b.append(", ");
+      }
+    b.append("}");
+    return b.toString();
+  }
+  
+  /**
+   * Get the return statement, assuming that the returned object is placed into
+   * the variable "result".
+   */
+  public String getReturnStatement()
+  {
+    Class r = method.getReturnType();
+    if (r.equals(void.class))
+      return "";
+    else
+      {
+        if (r.isPrimitive())
+          {
+            String wcd = rmic.name(WrapUnWrapper.getWrappingClass(r));
+            return "return ((" + wcd + ") result)."
+                   + WrapUnWrapper.getUnwrappingMethod(r) + ";";
+          }
+        else
+          return "return (" + rmic.name(r) + ") result;";
+      }
+  }
+  
+  /**
+   * Get argument list as class array.
+   */
+  public String getArgListAsClassArray()
+  {
+    StringBuffer b = new StringBuffer();
+    Class[] args = method.getParameterTypes();
+
+    for (int i = 0; i < args.length; i++)
+      {
+        b.append(rmic.name(args[i]));
+        b.append(".class");
+        if (i < args.length - 1)
+          b.append(", ");
+      }
+    return b.toString();
+  }
+
+  /**
+   * RMI ties (previously named Skeletons) are no longer used since v 1.2. This
+   * method should never be called.
+   */
+  public String generateTieMethod()
+  {
+    throw new InternalError();
+  }
+
+  /**
+   * Get the method hash code.
+   */
+  public String getMethodHashCode()
+  {
+    return RMIHashes.getMethodHash(method)+"L";
+  }
+  
+  /**
+   * Additional processing of the stub name (nothing to do for JRMP stubs).
+   */
+  public String convertStubName(String name)
+  {
+    return name;
+  }
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/RmicCompiler.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/RmicCompiler.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/RmicCompiler.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/RmicCompiler.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* RmicCompiler.java -- RMI stub generator for java.rmi.*
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+*/
+
+
+package gnu.classpath.tools.rmi.rmic;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+
+import gnu.classpath.tools.AbstractMethodGenerator;
+import gnu.classpath.tools.giop.grmic.GiopRmicCompiler;
+
+/**
+ * RMI stub source code generator, required to support java.rmi.*
+ *
+ * @author Audrius Meskauskas (AudriusA at Bioinformatics.org) 
+ */
+public class RmicCompiler extends GiopRmicCompiler
+{
+  /**
+   * If true, the zero size object array is declared in the stub to reduce
+   * garbage generation.
+   */
+  public boolean addZeroSizeObjecArray;
+  
+  /**
+   * Generate a RMI stub.
+   * 
+   * @return the string, containing the text of the generated stub.
+   */
+  public String generateStub()
+  {
+    String template = getResource("Stub_12.jav");
+
+    // Generate methods.
+    StringBuffer b = new StringBuffer();
+    Iterator iter = methods.iterator();
+    while (iter.hasNext())
+      {
+        RmiMethodGenerator m = (RmiMethodGenerator) iter.next();
+        b.append(m.generateStubMethod());
+      }
+
+    vars.put("#stub_methods", b.toString());
+    vars.put("#imports", getImportStatements());
+    vars.put("#interfaces", getAllInterfaces());
+    vars.put("#stub_method_declarations", getStubMethodDeclarations());
+    vars.put("#stub_method_initializations", getStubMethodInitializations());
+    if (addZeroSizeObjecArray)
+      {
+        vars.put("#zeroSizeObjecArray",
+               "private static final Object[] NO_ARGS = new Object[0];");
+        vars.put("#zeroSizeClassArray",
+               "final Class[]  NO_ARGSc = new Class[0];");
+      }
+    else
+      {
+        vars.put("#zeroSizeObjecArray","");
+        vars.put("#zeroSizeClassArray","");        
+      }
+
+    String output = replaceAll(template, vars);
+    return output;
+  }
+
+  /**
+   * Create a method generator, applicable for RMI stub methods.
+   */
+  protected AbstractMethodGenerator createMethodGenerator(Method m)
+  {
+    return new RmiMethodGenerator(m, this);
+  } 
+  
+  /**
+   * Get the stub method declarations.
+   */
+  public String getStubMethodDeclarations()
+  {
+    StringBuffer b = new StringBuffer();
+    
+    Iterator iter = methods.iterator();
+     
+    while (iter.hasNext())
+      {
+        RmiMethodGenerator method = (RmiMethodGenerator) iter.next();
+        b.append("    ");
+        b.append("private static final Method met_");
+        b.append(method.method.getName());
+        b.append(';');
+        if (iter.hasNext())
+          b.append('\n');
+      }
+    return b.toString();
+  }
+  
+  /**
+   * Get stub method initializations. These must be done in a try-catch
+   * statement to catch {@link NoSuchMethodException}.
+   */
+  public String getStubMethodInitializations()
+  {
+    StringBuffer b = new StringBuffer();
+    
+    Iterator iter = methods.iterator();
+     
+    while (iter.hasNext())
+      {
+        RmiMethodGenerator method = (RmiMethodGenerator) iter.next();
+        b.append("             ");
+        b.append("met_");
+        b.append(method.method.getName());
+        b.append(" =\n               ");
+        b.append(name(method.method.getDeclaringClass()));
+        b.append(".class.getMethod(");
+        b.append('"');
+        b.append(method.method.getName());
+        b.append("\", ");        
+        if (method.method.getParameterTypes().length == 0)
+          b.append("NO_ARGSc);");
+        else
+          {
+            b.append("new Class[]\n                 {\n                   ");
+            b.append(method.getArgListAsClassArray());
+            b.append("\n                 }");
+            b.append(");");
+          }
+        b.append('\n');
+      }
+    return b.toString();
+  }
+
+  /**
+   * Prepare for the compilation of the next class.
+   */
+  public void reset()
+  {
+    addZeroSizeObjecArray = false;
+    super.reset();
+  }
+
+  /**
+   * Additional processing of the stub name (nothing to do for JRMP stubs).
+   */
+  public String convertStubName(String name)
+  {
+    return name;
+  }  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/WrapUnWrapper.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/WrapUnWrapper.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/WrapUnWrapper.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/WrapUnWrapper.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,83 @@
+/* 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.
+*/
+
+
+package gnu.classpath.tools.rmi.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;    
+  }
+  
+  
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12.jav Thu Nov  8 16:56:19 2007
@@ -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    
+}

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12Method.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12Method.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12Method.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12Method.jav Thu Nov  8 16:56:19 2007
@@ -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

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12MethodVoid.jav
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12MethodVoid.jav?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12MethodVoid.jav (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12MethodVoid.jav Thu Nov  8 16:56:19 2007
@@ -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

Added: llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl.java?rev=43913&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl.java Thu Nov  8 16:56:19 2007
@@ -0,0 +1,244 @@
+/* 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.rmi.rmid;
+
+import gnu.classpath.tools.rmi.Persistent;
+import gnu.classpath.tools.rmi.PersistentBidiHashTable;
+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 at 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.
+  };  
+  
+}





More information about the llvm-commits mailing list