--- a/corba/make/CompileCorba.gmk Wed Feb 05 11:04:21 2014 +0100
+++ b/corba/make/CompileCorba.gmk Thu Feb 13 16:38:49 2014 +0100
@@ -37,8 +37,7 @@
$(eval $(call SetupJavaCompilation,BUILD_CORBA, \
SETUP := GENERATE_NEWBYTECODE, \
SRC := $(CORBA_TOPDIR)/src/share/classes $(CORBA_OUTPUTDIR)/gensrc, \
- EXCLUDES := com/sun/corba/se/PortableActivationIDL \
- com/sun/tools/corba/se/logutil, \
+ EXCLUDES := com/sun/corba/se/PortableActivationIDL, \
EXCLUDE_FILES := com/sun/corba/se/impl/presentation/rmi/JNDIStateFactoryImpl.java \
com/sun/corba/se/spi/presentation/rmi/StubWrapper.java \
com/sun/org/omg/CORBA/IDLTypeOperations.java \
--- a/corba/make/GensrcCorba.gmk Wed Feb 05 11:04:21 2014 +0100
+++ b/corba/make/GensrcCorba.gmk Thu Feb 13 16:38:49 2014 +0100
@@ -34,14 +34,17 @@
################################################################################
-$(eval $(call SetupJavaCompilation,BUILD_STRIPPROP, \
+$(eval $(call SetupJavaCompilation,BUILD_TOOLS, \
SETUP := GENERATE_OLDBYTECODE, \
- SRC := $(CORBA_TOPDIR)/make/tools/src, \
- BIN := $(CORBA_OUTPUTDIR)/stripprop_classes))
+ SRC := $(CORBA_TOPDIR)/make/src/classes, \
+ BIN := $(CORBA_OUTPUTDIR)/tools_classes))
-TOOL_STRIPPROP_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/stripprop_classes \
+TOOL_STRIPPROP_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/tools_classes \
build.tools.stripproperties.StripPropertiesCorba
+TOOL_LOGUTIL_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/tools_classes \
+ build.tools.logutil.MC
+
$(eval $(call SetupJavaCompilation,BUILD_IDLJ, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(CORBA_TOPDIR)/src/share/classes, \
@@ -53,21 +56,12 @@
TOOL_IDLJ_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/idlj_classes \
com.sun.tools.corba.se.idl.toJavaPortable.Compile
-$(eval $(call SetupJavaCompilation,BUILD_LOGUTIL, \
- SETUP := GENERATE_OLDBYTECODE, \
- SRC := $(CORBA_TOPDIR)/src/share/classes, \
- BIN := $(CORBA_OUTPUTDIR)/logutil_classes, \
- INCLUDES := com/sun/tools/corba/se/logutil))
-
-TOOL_LOGUTIL_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/logutil_classes \
- com.sun.tools.corba.se.logutil.MC
-
################################################################################
# Generate LogWrapper classes
$(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/%SystemException.java: \
$(CORBA_TOPDIR)/src/share/classes/com/sun/corba/se/spi/logging/data/%.mc \
- $(BUILD_LOGUTIL)
+ $(BUILD_TOOLS)
$(MKDIR) -p $(@D)
$(RM) -f $(@D)/_the_wrappers.d
$(ECHO) $(LOG_INFO) Generating class file from $*.mc
@@ -90,7 +84,7 @@
# The resources files are generated from lisp-like .mc files.
$(CORBA_OUTPUTDIR)/logwrappers/%SystemException.resource: \
$(CORBA_TOPDIR)/src/share/classes/com/sun/corba/se/spi/logging/data/%.mc \
- $(BUILD_LOGUTIL)
+ $(BUILD_TOOLS)
$(MKDIR) -p $(@D)
$(RM) -f $(@D)/_the_wrappers.d
$(ECHO) $(LOG_INFO) Generating resource file from $*.mc
@@ -111,6 +105,115 @@
################################################################################
# Build the IDLs.
+IDL_DELETES := \
+ org/omg/DynamicAny/*POA* \
+ org/omg/DynamicAny/*Holder* \
+ org/omg/DynamicAny/DynValueBoxHelper.java \
+ org/omg/DynamicAny/DynValueCommonHelper.java \
+ org/omg/DynamicAny/_DynValueCommonStub.java \
+ org/omg/DynamicAny/_DynValueBoxStub.java \
+ org/omg/DynamicAny/DynAnyPackage/TypeMismatchHolder.java \
+ org/omg/DynamicAny/DynAnyPackage/InvalidValueHolder.java \
+ org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHolder.java \
+ org/omg/IOP/BI_DIR_IIOP.java \
+ org/omg/IOP/ChainBypassCheck.java \
+ org/omg/IOP/ChainBypassInfo.java \
+ org/omg/IOP/FORWARDED_IDENTITY.java \
+ org/omg/IOP/INVOCATION_POLICIES.java \
+ org/omg/IOP/LogicalThreadId.java \
+ org/omg/IOP/SendingContextRunTime.java \
+ org/omg/IOP/UnknownExceptionInfo.java \
+ org/omg/IOP/TaggedComponentSeqHolder.java \
+ org/omg/PortableServer/CurrentPackage/NoContextHolder.java \
+ org/omg/PortableServer/ForwardRequestHolder.java \
+ org/omg/PortableServer/IdAssignmentPolicyValueHelper.java \
+ org/omg/PortableServer/IdAssignmentPolicyValueHolder.java \
+ org/omg/PortableServer/IdUniquenessPolicyValueHelper.java \
+ org/omg/PortableServer/IdUniquenessPolicyValueHolder.java \
+ org/omg/PortableServer/ImplicitActivationPolicyValueHelper.java \
+ org/omg/PortableServer/ImplicitActivationPolicyValueHolder.java \
+ org/omg/PortableServer/LifespanPolicyValueHelper.java \
+ org/omg/PortableServer/LifespanPolicyValueHolder.java \
+ org/omg/PortableServer/ServantRetentionPolicyValueHelper.java \
+ org/omg/PortableServer/ServantRetentionPolicyValueHolder.java \
+ org/omg/PortableServer/ObjectIdHelper.java \
+ org/omg/PortableServer/ObjectIdHolder.java \
+ org/omg/PortableServer/POAListHelper.java \
+ org/omg/PortableServer/POAListHolder.java \
+ org/omg/PortableServer/POAManagerPackage/AdapterInactiveHolder.java \
+ org/omg/PortableServer/POAManagerPackage/StateHelper.java \
+ org/omg/PortableServer/POAManagerPackage/StateHolder.java \
+ org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHolder.java \
+ org/omg/PortableServer/POAPackage/AdapterNonExistentHolder.java \
+ org/omg/PortableServer/POAPackage/InvalidPolicyHolder.java \
+ org/omg/PortableServer/POAPackage/NoServantHolder.java \
+ org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHolder.java \
+ org/omg/PortableServer/POAPackage/ObjectNotActiveHolder.java \
+ org/omg/PortableServer/POAPackage/ServantAlreadyActiveHolder.java \
+ org/omg/PortableServer/POAPackage/ServantNotActiveHolder.java \
+ org/omg/PortableServer/POAPackage/WrongAdapterHolder.java \
+ org/omg/PortableServer/POAPackage/WrongPolicyHolder.java \
+ org/omg/PortableServer/RequestProcessingPolicyValueHelper.java \
+ org/omg/PortableServer/RequestProcessingPolicyValueHolder.java \
+ org/omg/PortableServer/ServantActivatorHolder.java \
+ org/omg/PortableServer/ServantLocatorHolder.java \
+ org/omg/PortableServer/ThreadPolicyValueHelper.java \
+ org/omg/PortableServer/ThreadPolicyValueHolder.java \
+ org/omg/PortableInterceptor/ClientRequestInfoHelper.java \
+ org/omg/PortableInterceptor/ClientRequestInterceptorHelper.java \
+ org/omg/PortableInterceptor/IORInfoHelper.java \
+ org/omg/PortableInterceptor/IORInterceptorHelper.java \
+ org/omg/PortableInterceptor/InterceptorHelper.java \
+ org/omg/PortableInterceptor/ORBInitInfoHelper.java \
+ org/omg/PortableInterceptor/ORBInitializerHelper.java \
+ org/omg/PortableInterceptor/PolicyFactoryHelper.java \
+ org/omg/PortableInterceptor/ReplyStatusHelper.java \
+ org/omg/PortableInterceptor/RequestInfoHelper.java \
+ org/omg/PortableInterceptor/ServerRequestInfoHelper.java \
+ org/omg/PortableInterceptor/ServerRequestInterceptorHelper.java \
+ org/omg/PortableInterceptor/SlotIdHelper.java \
+ org/omg/PortableInterceptor/ClientRequestInfoHolder.java \
+ org/omg/PortableInterceptor/ClientRequestInterceptorHolder.java \
+ org/omg/PortableInterceptor/CurrentHolder.java \
+ org/omg/PortableInterceptor/ForwardRequestHolder.java \
+ org/omg/PortableInterceptor/IORInfoHolder.java \
+ org/omg/PortableInterceptor/IORInterceptorHolder.java \
+ org/omg/PortableInterceptor/InterceptorHolder.java \
+ org/omg/PortableInterceptor/InvalidSlotHolder.java \
+ org/omg/PortableInterceptor/ORBInitInfoHolder.java \
+ org/omg/PortableInterceptor/ORBInitializerHolder.java \
+ org/omg/PortableInterceptor/PolicyFactoryHolder.java \
+ org/omg/PortableInterceptor/RequestInfoHolder.java \
+ org/omg/PortableInterceptor/ServerRequestInfoHolder.java \
+ org/omg/PortableInterceptor/ServerRequestInterceptorHolder.java \
+ org/omg/PortableInterceptor/TaggedComponentSeqHolder.java \
+ org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHolder.java \
+ org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHolder.java \
+ org/omg/IOP/CodecPackage/FormatMismatchHolder.java \
+ org/omg/IOP/CodecPackage/InvalidTypeForEncodingHolder.java \
+ org/omg/IOP/CodecPackage/TypeMismatchHolder.java \
+ org/omg/IOP/CodecHelper.java \
+ org/omg/IOP/EncodingFormatHelper.java \
+ org/omg/IOP/EncodingHelper.java \
+ org/omg/IOP/CodecFactoryPackage/UnknownEncodingHolder.java \
+ org/omg/IOP/CodecFactoryHolder.java \
+ org/omg/IOP/CodecHolder.java \
+ org/omg/IOP/EncodingHolder.java \
+ org/omg/IOP/TaggedComponentSeqHelper.java \
+ org/omg/Dynamic/ContextListHelper.java \
+ org/omg/Dynamic/ExceptionListHelper.java \
+ org/omg/Dynamic/ParameterHolder.java \
+ org/omg/Dynamic/ParameterListHolder.java \
+ org/omg/Dynamic/ExceptionListHolder.java \
+ org/omg/Dynamic/ParameterHelper.java \
+ org/omg/Dynamic/ParameterListHelper.java \
+ org/omg/Dynamic/RequestContextHelper.java \
+ org/omg/CORBA/OctetSeqHelper.java \
+ org/omg/CORBA/OctetSeqHolder.java \
+ org/omg/CORBA/PolicyError.java \
+ org/omg/CORBA/RepositoryIdHelper.java \
+ #
+
$(eval $(call SetupIdlCompilation,BUILD_IDLS, \
IDLJ := $(TOOL_IDLJ_CMD), \
SRC := $(CORBA_TOPDIR)/src/share/classes, \
@@ -122,7 +225,7 @@
INCLUDES := %, \
OLDIMPLBASES := com/sun/corba/se/PortableActivationIDL/activation.idl \
com/sun/corba/se/spi/activation/activation.idl, \
- DELETES := DYNANYDELETEFILES org/omg/DynamicAny/*POA* org/omg/DynamicAny/*Holder* org/omg/DynamicAny/DynValueBoxHelper.java org/omg/DynamicAny/DynValueCommonHelper.java org/omg/DynamicAny/_DynValueCommonStub.java org/omg/DynamicAny/_DynValueBoxStub.java org/omg/DynamicAny/DynAnyPackage/TypeMismatchHolder.java org/omg/DynamicAny/DynAnyPackage/InvalidValueHolder.java org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHolder.java IOPDELETEFILES org/omg/IOP/BI_DIR_IIOP.java org/omg/IOP/ChainBypassCheck.java org/omg/IOP/ChainBypassInfo.java org/omg/IOP/FORWARDED_IDENTITY.java org/omg/IOP/INVOCATION_POLICIES.java org/omg/IOP/LogicalThreadId.java org/omg/IOP/SendingContextRunTime.java org/omg/IOP/UnknownExceptionInfo.java org/omg/IOP/TaggedComponentSeqHolder.java POAHELHOLFILES org/omg/PortableServer/CurrentPackage/NoContextHolder.java org/omg/PortableServer/ForwardRequestHolder.java org/omg/PortableServer/IdAssignmentPolicyValueHelper.java org/omg/PortableServer/IdAssignmentPolicyValueHolder.java org/omg/PortableServer/IdUniquenessPolicyValueHelper.java org/omg/PortableServer/IdUniquenessPolicyValueHolder.java org/omg/PortableServer/ImplicitActivationPolicyValueHelper.java org/omg/PortableServer/ImplicitActivationPolicyValueHolder.java org/omg/PortableServer/LifespanPolicyValueHelper.java org/omg/PortableServer/LifespanPolicyValueHolder.java org/omg/PortableServer/ServantRetentionPolicyValueHelper.java org/omg/PortableServer/ServantRetentionPolicyValueHolder.java org/omg/PortableServer/ObjectIdHelper.java org/omg/PortableServer/ObjectIdHolder.java org/omg/PortableServer/POAListHelper.java org/omg/PortableServer/POAListHolder.java org/omg/PortableServer/POAManagerPackage/AdapterInactiveHolder.java org/omg/PortableServer/POAManagerPackage/StateHelper.java org/omg/PortableServer/POAManagerPackage/StateHolder.java org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHolder.java org/omg/PortableServer/POAPackage/AdapterNonExistentHolder.java org/omg/PortableServer/POAPackage/InvalidPolicyHolder.java org/omg/PortableServer/POAPackage/NoServantHolder.java org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHolder.java org/omg/PortableServer/POAPackage/ObjectNotActiveHolder.java org/omg/PortableServer/POAPackage/ServantAlreadyActiveHolder.java org/omg/PortableServer/POAPackage/ServantNotActiveHolder.java org/omg/PortableServer/POAPackage/WrongAdapterHolder.java org/omg/PortableServer/POAPackage/WrongPolicyHolder.java org/omg/PortableServer/RequestProcessingPolicyValueHelper.java org/omg/PortableServer/RequestProcessingPolicyValueHolder.java org/omg/PortableServer/ServantActivatorHolder.java org/omg/PortableServer/ServantLocatorHolder.java org/omg/PortableServer/ThreadPolicyValueHelper.java org/omg/PortableServer/ThreadPolicyValueHolder.java PIHELHOLFILES org/omg/PortableInterceptor/ClientRequestInfoHelper.java org/omg/PortableInterceptor/ClientRequestInterceptorHelper.java org/omg/PortableInterceptor/IORInfoHelper.java org/omg/PortableInterceptor/IORInterceptorHelper.java org/omg/PortableInterceptor/InterceptorHelper.java org/omg/PortableInterceptor/ORBInitInfoHelper.java org/omg/PortableInterceptor/ORBInitializerHelper.java org/omg/PortableInterceptor/PolicyFactoryHelper.java org/omg/PortableInterceptor/ReplyStatusHelper.java org/omg/PortableInterceptor/RequestInfoHelper.java org/omg/PortableInterceptor/ServerRequestInfoHelper.java org/omg/PortableInterceptor/ServerRequestInterceptorHelper.java org/omg/PortableInterceptor/SlotIdHelper.java org/omg/PortableInterceptor/ClientRequestInfoHolder.java org/omg/PortableInterceptor/ClientRequestInterceptorHolder.java org/omg/PortableInterceptor/CurrentHolder.java org/omg/PortableInterceptor/ForwardRequestHolder.java org/omg/PortableInterceptor/IORInfoHolder.java org/omg/PortableInterceptor/IORInterceptorHolder.java org/omg/PortableInterceptor/InterceptorHolder.java org/omg/PortableInterceptor/InvalidSlotHolder.java org/omg/PortableInterceptor/ORBInitInfoHolder.java org/omg/PortableInterceptor/ORBInitializerHolder.java org/omg/PortableInterceptor/PolicyFactoryHolder.java org/omg/PortableInterceptor/RequestInfoHolder.java org/omg/PortableInterceptor/ServerRequestInfoHolder.java org/omg/PortableInterceptor/ServerRequestInterceptorHolder.java org/omg/PortableInterceptor/TaggedComponentSeqHolder.java org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHolder.java org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHolder.java org/omg/IOP/CodecPackage/FormatMismatchHolder.java org/omg/IOP/CodecPackage/InvalidTypeForEncodingHolder.java org/omg/IOP/CodecPackage/TypeMismatchHolder.java org/omg/IOP/CodecHelper.java org/omg/IOP/EncodingFormatHelper.java org/omg/IOP/EncodingHelper.java org/omg/IOP/CodecFactoryPackage/UnknownEncodingHolder.java org/omg/IOP/CodecFactoryHolder.java org/omg/IOP/CodecHolder.java org/omg/IOP/EncodingHolder.java org/omg/IOP/TaggedComponentSeqHelper.java org/omg/Dynamic/ContextListHelper.java org/omg/Dynamic/ExceptionListHelper.java org/omg/Dynamic/ParameterHolder.java org/omg/Dynamic/ParameterListHolder.java org/omg/Dynamic/ExceptionListHolder.java org/omg/Dynamic/ParameterHelper.java org/omg/Dynamic/ParameterListHelper.java org/omg/Dynamic/RequestContextHelper.java CORBAX org/omg/CORBA/OctetSeqHelper.java org/omg/CORBA/OctetSeqHolder.java org/omg/CORBA/PolicyError.java org/omg/CORBA/RepositoryIdHelper.java))
+ DELETES := $(IDL_DELETES)))
$(BUILD_IDLS): $(BUILD_IDLJ)
@@ -142,7 +245,7 @@
$(addprefix _SPACE_, $(STRIP_PROP_FILES))))
$(CORBA_OUTPUTDIR)/_the.stripped_properties: $(STRIP_PROP_SRC_FILES) \
- $(BUILD_STRIPPROP)
+ $(BUILD_TOOLS)
$(MKDIR) -p $(sort $(dir $(STRIP_PROP_FILES)))
$(call ListPathsSafely,STRIP_PROP_CMDLINE,\n, >> $(CORBA_OUTPUTDIR)/_the.strip_prop.cmdline)
$(TOOL_STRIPPROP_CMD) @$(CORBA_OUTPUTDIR)/_the.strip_prop.cmdline
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/make/src/classes/build/tools/logutil/IndentingPrintWriter.java Thu Feb 13 16:38:49 2014 +0100
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package build.tools.logutil;
+
+import java.io.PrintWriter ;
+import java.io.Writer ;
+import java.io.OutputStream ;
+import java.io.BufferedWriter ;
+import java.io.OutputStreamWriter ;
+import java.util.StringTokenizer ;
+
+public class IndentingPrintWriter extends PrintWriter {
+ private int level = 0 ;
+ private int indentWidth = 4 ;
+ private String indentString = "" ;
+
+ public void printMsg( String msg, Object... data )
+ {
+ // System.out.println( "printMsg called with msg=" + msg + " data=" + data ) ;
+ StringTokenizer st = new StringTokenizer( msg, "@", true ) ;
+ StringBuffer result = new StringBuffer() ;
+ String token = null ;
+ int pos = 0;
+
+ while (st.hasMoreTokens()) {
+ token = st.nextToken() ;
+ if (token.equals("@")) {
+ if (pos < data.length) {
+ result.append( data[pos] );
+ ++pos;
+ } else {
+ throw new Error( "List too short for message" ) ;
+ }
+ } else {
+ result.append( token ) ;
+ }
+ }
+
+ // System.out.println( "Printing result " + result + " to file" ) ;
+ print( result ) ;
+ println() ;
+ }
+
+ public IndentingPrintWriter (Writer out) {
+ super( out, true ) ;
+ // System.out.println( "Constructing a new IndentingPrintWriter with Writer " + out ) ;
+ }
+
+ public IndentingPrintWriter(Writer out, boolean autoFlush) {
+ super( out, autoFlush ) ;
+ // System.out.println( "Constructing a new IndentingPrintWriter with Writer " + out ) ;
+ }
+
+ public IndentingPrintWriter(OutputStream out) {
+ super(out, true);
+ // System.out.println( "Constructing a new IndentingPrintWriter with OutputStream " + out ) ;
+ }
+
+ public IndentingPrintWriter(OutputStream out, boolean autoFlush) {
+ super(new BufferedWriter(new OutputStreamWriter(out)), autoFlush);
+ // System.out.println( "Constructing a new IndentingPrintWriter with OutputStream " + out ) ;
+ }
+
+ public void setIndentWidth( int indentWidth )
+ {
+ this.indentWidth = indentWidth ;
+ updateIndentString() ;
+ }
+
+ public void indent()
+ {
+ level++ ;
+ updateIndentString() ;
+ }
+
+ public void undent()
+ {
+ if (level > 0) {
+ level-- ;
+ updateIndentString() ;
+ }
+ }
+
+ private void updateIndentString()
+ {
+ int size = level * indentWidth ;
+ StringBuffer sbuf = new StringBuffer( size ) ;
+ for (int ctr = 0; ctr<size; ctr++ )
+ sbuf.append( " " ) ;
+ indentString = sbuf.toString() ;
+ }
+
+ // overridden from PrintWriter
+ public void println()
+ {
+ super.println() ;
+
+ print( indentString ) ;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/make/src/classes/build/tools/logutil/Input.java Thu Feb 13 16:38:49 2014 +0100
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package build.tools.logutil;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStreamReader;
+import java.io.IOException;
+
+import java.util.LinkedList;
+import java.util.Queue;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Input {
+
+ /**
+ * The name of the package this class will inhabit.
+ */
+ private String packageName;
+
+ /**
+ * The name of the generated class.
+ */
+ private String className;
+
+ /**
+ * The name of the group of exceptions handled by the class.
+ */
+ private String groupName;
+
+ /**
+ * The group of exceptions.
+ */
+ private Queue<InputException> exceptions;
+
+ /**
+ * Represents the current state of parsing the input.
+ */
+ private enum State
+ {
+ OUTER,
+ IN_CLASS,
+ IN_EXCEPTION_LIST
+ };
+
+ /**
+ * Regular expression to match each code line.
+ */
+ private static final Pattern EXCEPTION_INFO_REGEX =
+ Pattern.compile("(\\w+)\\s*(\\d+)\\s*(\\w+)");
+
+ /**
+ * Parses the specified file to create a new {@link Input}
+ * object.
+ *
+ * @param filename the file to parse.
+ * @throws FileNotFoundException if the file can't be found.
+ * @throws IOException if an I/O error occurs.
+ */
+ public Input(final String filename)
+ throws FileNotFoundException, IOException {
+ BufferedReader r =
+ new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
+ State state = State.OUTER;
+ InputException current = null;
+ exceptions = new LinkedList<InputException>();
+ String line;
+ while ((line = r.readLine()) != null) {
+ // Skip ; comments
+ if (line.startsWith(";"))
+ continue;
+
+ int index = line.indexOf("(");
+ if (index == -1)
+ continue;
+
+ switch (state) {
+ case OUTER:
+ state = State.IN_CLASS;
+ String[] classInfo = line.substring(index).split(" ");
+ packageName = classInfo[0].substring(2, classInfo[0].length() - 1);
+ className = classInfo[1].substring(1, classInfo[1].length() - 1);
+ groupName = classInfo[2];
+ break;
+ case IN_CLASS:
+ state = State.IN_EXCEPTION_LIST;
+ break;
+ case IN_EXCEPTION_LIST:
+ boolean inQuote = false;
+ boolean inCode = false;
+ boolean end = false;
+ int start = index + 1;
+ Queue<String> lines = new LinkedList<String>();
+ for (int a = start; a < line.length(); ++a) {
+ if (line.charAt(a) == '(' && !inCode && !inQuote) {
+ if (current == null)
+ current =
+ new InputException(line.substring(start, a).trim());
+ start = a + 1;
+ inCode = true;
+ }
+ if (line.charAt(a) == '"')
+ inQuote = !inQuote;
+ if (line.charAt(a) == ')' && !inQuote) {
+ if (inCode) {
+ lines.offer(line.substring(start, a));
+ inCode = false;
+ } else
+ end = true;
+ }
+ if (!end && a == line.length() - 1)
+ line += r.readLine();
+ }
+ for (String l : lines) {
+ int stringStart = l.indexOf("\"") + 1;
+ int stringEnd = l.indexOf("\"", stringStart);
+ Matcher matcher = EXCEPTION_INFO_REGEX.matcher(l.substring(0, stringStart));
+ if (matcher.find())
+ current.add(new InputCode(matcher.group(1),
+ Integer.parseInt(matcher.group(2)),
+ matcher.group(3),
+ l.substring(stringStart, stringEnd)));
+ }
+ exceptions.offer(current);
+ current = null;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Returns the name of this group of exceptions.
+ *
+ * @return the name of this group of exceptions.
+ */
+ public String getGroupName()
+ {
+ return groupName;
+ }
+
+ /**
+ * Returns the name of the package this class will go in.
+ *
+ * @return the name of the package.
+ */
+ public String getPackageName()
+ {
+ return packageName;
+ }
+
+ /**
+ * Returns the name of the generated class.
+ *
+ * @return the name of the class.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Returns the exceptions contained in this class.
+ *
+ * @return the exceptions.
+ */
+ public Queue<InputException> getExceptions() {
+ return exceptions;
+ }
+
+ /**
+ * Returns a textual representation of this input.
+ *
+ * @return a textual representation.
+ */
+ public String toString() {
+ return getClass().getName() +
+ "[packageName=" + packageName +
+ ",className=" + className +
+ ",groupName=" + groupName +
+ ",exceptions=" + exceptions +
+ "]";
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/make/src/classes/build/tools/logutil/InputCode.java Thu Feb 13 16:38:49 2014 +0100
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package build.tools.logutil;
+
+public class InputCode {
+
+ /**
+ * The name of this code.
+ */
+ private final String name;
+
+ /**
+ * The code.
+ */
+ private final int code;
+
+ /**
+ * The log level for this code.
+ */
+ private final String logLevel;
+
+ /**
+ * The error message for this code.
+ */
+ private final String message;
+
+ /**
+ * Creates a new error code with the specified name, code,
+ * log level and error message.
+ *
+ * @param name the name of the new code.
+ * @param code the code itself.
+ * @param logLevel the level of severity of this error.
+ * @param message the error message for this code.
+ */
+ public InputCode(final String name, final int code,
+ final String logLevel, final String message) {
+ this.name = name;
+ this.code = code;
+ this.logLevel = logLevel;
+ this.message = message;
+ }
+
+ /**
+ * Returns the name of this code.
+ *
+ * @return the name of the code.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the code.
+ *
+ * @return the code.
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /**
+ * Returns the severity of this code.
+ *
+ * @return the log level severity of the code.
+ */
+ public String getLogLevel() {
+ return logLevel;
+ }
+
+ /**
+ * Returns the error message for this code.
+ *
+ * @return the error message for this code.
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Returns a textual representation of this code.
+ *
+ * @return a textual representation.
+ */
+ public String toString() {
+ return getClass().getName() +
+ "[name=" + name +
+ ",code=" + code +
+ ",logLevel=" + logLevel +
+ ",message=" + message +
+ "]";
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/make/src/classes/build/tools/logutil/InputException.java Thu Feb 13 16:38:49 2014 +0100
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package build.tools.logutil;
+
+import java.util.LinkedList;
+import java.util.Queue;
+
+public class InputException {
+
+ /**
+ * The name of this exception.
+ */
+ private final String name;
+
+ /**
+ * The codes associated with this exception.
+ */
+ private final Queue<InputCode> codes;
+
+ /**
+ * Constructs a new {@link InputException} with the
+ * specified name.
+ *
+ * @param name the name of the new exception;
+ */
+ public InputException(final String name) {
+ this.name = name;
+ codes = new LinkedList<InputCode>();
+ }
+
+ /**
+ * Adds a new code to this exception.
+ *
+ * @param c the code to add.
+ */
+ public void add(InputCode c)
+ {
+ codes.offer(c);
+ }
+
+ /**
+ * Returns the name of this exception.
+ *
+ * @return the exception's name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the codes associated with this exception.
+ *
+ * @return the exception's codes.
+ */
+ public Queue<InputCode> getCodes() {
+ return codes;
+ }
+
+ /**
+ * Returns a textual representation of this exception.
+ *
+ * @return a textual representation.
+ */
+ public String toString() {
+ return getClass().getName()
+ + "[name=" + name
+ + ",codes=" + codes
+ + "]";
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/make/src/classes/build/tools/logutil/MC.java Thu Feb 13 16:38:49 2014 +0100
@@ -0,0 +1,559 @@
+/*
+ * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package build.tools.logutil;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Formatter;
+import java.util.List;
+import java.util.Queue;
+
+public class MC {
+
+ private static final String VERSION = "1.0";
+
+ private static final List<String> SUN_EXCEPTION_GROUPS = Arrays.asList(new String[]
+ { "SUNBASE", "ORBUTIL", "ACTIVATION", "NAMING", "INTERCEPTORS", "POA", "IOR", "UTIL" });
+
+ private static final List<String> EXCEPTIONS = Arrays.asList(new String[]
+ { "UNKNOWN", "BAD_PARAM", "NO_MEMORY", "IMP_LIMIT", "COMM_FAILURE", "INV_OBJREF", "NO_PERMISSION",
+ "INTERNAL", "MARSHAL", "INITIALIZE", "NO_IMPLEMENT", "BAD_TYPECODE", "BAD_OPERATION", "NO_RESOURCES",
+ "NO_RESPONSE", "PERSIST_STORE", "BAD_INV_ORDER", "TRANSIENT", "FREE_MEM", "INV_IDENT", "INV_FLAG",
+ "INTF_REPOS", "BAD_CONTEXT", "OBJ_ADAPTER", "DATA_CONVERSION", "OBJECT_NOT_EXIST", "TRANSACTION_REQUIRED",
+ "TRANSACTION_ROLLEDBACK", "INVALID_TRANSACTION", "INV_POLICY", "CODESET_INCOMPATIBLE", "REBIND",
+ "TIMEOUT", "TRANSACTION_UNAVAILABLE", "BAD_QOS", "INVALID_ACTIVITY", "ACTIVITY_COMPLETED",
+ "ACTIVITY_REQUIRED" });
+
+ /**
+ * Read the minor codes from the input file and
+ * write out a resource file.
+ *
+ * @param inFile the file to read the codes from.
+ * @param outDir the directory to write the resource file to.
+ * @throws FileNotFoundException if the input file can not be found.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void makeResource(String inFile, String outDir)
+ throws FileNotFoundException, IOException {
+ writeResource(outDir, new Input(inFile));
+ }
+
+ /**
+ * Create a new Java source file using the specified Scheme input file,
+ * and writing the result to the given output directory.
+ *
+ * @param inFile the file to read the data from.
+ * @param outDir the directory to write the Java class to.
+ * @throws FileNotFoundException if the input file can not be found.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void makeClass(String inFile, String outDir)
+ throws FileNotFoundException, IOException {
+ writeClass(inFile, outDir, new Input(inFile));
+ }
+
+ /**
+ * Writes out a Java source file using the data from the given
+ * {@link Input} object. The result is written to {@code outDir}.
+ * The name of the input file is just used in the header of the
+ * resulting source file.
+ *
+ * @param inFile the name of the file the data was read from.
+ * @param outDir the directory to write the Java class to.
+ * @param input the parsed input data.
+ * @throws FileNotFoundException if the output file can't be written.
+ */
+ private void writeClass(String inFile, String outDir, Input input)
+ throws FileNotFoundException {
+ String packageName = input.getPackageName();
+ String className = input.getClassName();
+ String groupName = input.getGroupName();
+ Queue<InputException> exceptions = input.getExceptions();
+ FileOutputStream file = new FileOutputStream(outDir + File.separator + className + ".java");
+ IndentingPrintWriter pw = new IndentingPrintWriter(file);
+
+ writeClassHeader(inFile, groupName, pw);
+ pw.printMsg("package @ ;", packageName);
+ pw.println();
+ pw.println("import java.util.logging.Logger ;");
+ pw.println("import java.util.logging.Level ;");
+ pw.println();
+ pw.println("import org.omg.CORBA.OMGVMCID ;");
+ pw.println( "import com.sun.corba.se.impl.util.SUNVMCID ;");
+ pw.println( "import org.omg.CORBA.CompletionStatus ;");
+ pw.println( "import org.omg.CORBA.SystemException ;");
+ pw.println();
+ pw.println( "import com.sun.corba.se.spi.orb.ORB ;");
+ pw.println();
+ pw.println( "import com.sun.corba.se.spi.logging.LogWrapperFactory;");
+ pw.println();
+ pw.println( "import com.sun.corba.se.spi.logging.LogWrapperBase;");
+ pw.println();
+ writeImports(exceptions, pw);
+ pw.println();
+ pw.indent();
+ pw.printMsg("public class @ extends LogWrapperBase {", className);
+ pw.println();
+ pw.printMsg("public @( Logger logger )", className);
+ pw.indent();
+ pw.println( "{");
+ pw.undent();
+ pw.println( "super( logger ) ;");
+ pw.println( "}");
+ pw.println();
+ pw.flush();
+ writeFactoryMethod(className, groupName, pw);
+ writeExceptions(groupName, exceptions, className, pw);
+ pw.undent();
+ pw.println( );
+ pw.println( "}");
+ pw.flush();
+ pw.close();
+ }
+
+ /**
+ * Writes out the header of a Java source file.
+ *
+ * @param inFile the input file the file was generated from.
+ * @param groupName the group of exceptions the Java source file is for.
+ * @param pw the print writer used to write the output.
+ */
+ private void writeClassHeader(String inFile, String groupName,
+ IndentingPrintWriter pw) {
+ if (groupName.equals("OMG"))
+ pw.println("// Log wrapper class for standard exceptions");
+ else
+ pw.printMsg("// Log wrapper class for Sun private system exceptions in group @",
+ groupName);
+ pw.println("//");
+ pw.printMsg("// Generated by MC.java version @, DO NOT EDIT BY HAND!", VERSION);
+ pw.printMsg("// Generated from input file @ on @", inFile, new Date());
+ pw.println();
+ }
+
+ /**
+ * Write out the import list for the exceptions.
+ *
+ * @param groups the exceptions that were parsed.
+ * @param pw the {@link IndentingPrintWriter} for writing to the file.
+ */
+ private void writeImports(Queue<InputException> exceptions,
+ IndentingPrintWriter pw) {
+ if (exceptions == null)
+ return;
+ for (InputException e : exceptions)
+ pw.println("import org.omg.CORBA." + e.getName() + " ;");
+ }
+
+ /**
+ * Write out the factory method for this group of exceptions.
+ *
+ * @param className the name of the generated class.
+ * @param groupName the name of this group of exceptions.
+ * @param pw the {@link IndentingPrintWriter} for writing to the file.
+ */
+ private void writeFactoryMethod(String className, String groupName,
+ IndentingPrintWriter pw) {
+ pw.indent();
+ pw.println( "private static LogWrapperFactory factory = new LogWrapperFactory() {");
+ pw.println( "public LogWrapperBase create( Logger logger )" );
+ pw.indent();
+ pw.println( "{");
+ pw.undent();
+ pw.printMsg("return new @( logger ) ;", className);
+ pw.undent();
+ pw.println( "}" );
+ pw.println( "} ;" );
+ pw.println();
+ pw.printMsg("public static @ get( ORB orb, String logDomain )", className);
+ pw.indent();
+ pw.println( "{");
+ pw.indent();
+ pw.printMsg( "@ wrapper = ", className);
+ pw.indent();
+ pw.printMsg( "(@) orb.getLogWrapper( logDomain, ", className);
+ pw.undent();
+ pw.undent();
+ pw.printMsg( "\"@\", factory ) ;", groupName);
+ pw.undent();
+ pw.println( "return wrapper ;" );
+ pw.println( "} " );
+ pw.println();
+ pw.printMsg( "public static @ get( String logDomain )", className);
+ pw.indent();
+ pw.println( "{");
+ pw.indent();
+ pw.printMsg( "@ wrapper = ", className);
+ pw.indent();
+ pw.printMsg( "(@) ORB.staticGetLogWrapper( logDomain, ", className);
+ pw.undent();
+ pw.undent();
+ pw.printMsg( "\"@\", factory ) ;", groupName);
+ pw.undent();
+ pw.println( "return wrapper ;" );
+ pw.println( "} " );
+ pw.println();
+ }
+
+ /**
+ * Writes out the exceptions themselves.
+ *
+ * @param groupName the name of this group of exceptions.
+ * @param exceptions the exceptions to write out.
+ * @param className the name of the generated class.
+ * @param pw the {@link IndentingPrintWriter} for writing to the file.
+ */
+ private void writeExceptions(String groupName, Queue<InputException> exceptions,
+ String className, IndentingPrintWriter pw) {
+ for (InputException e : exceptions) {
+ pw.println("///////////////////////////////////////////////////////////");
+ pw.printMsg("// @", e.getName());
+ pw.println("///////////////////////////////////////////////////////////");
+ pw.println();
+ for (InputCode c : e.getCodes())
+ writeMethods(groupName, e.getName(), c.getName(), c.getCode(),
+ c.getLogLevel(), className, StringUtil.countArgs(c.getMessage()), pw);
+ pw.flush();
+ }
+ }
+
+ /**
+ * Writes out the methods for a particular error.
+ *
+ * @param groupName the name of this group of exceptions.
+ * @param exceptionName the name of this particular exception.
+ * @param errorName the name of this particular error.
+ * @param code the minor code for this particular error.
+ * @param ident the name of the error in mixed-case identifier form.
+ * @param level the level at which to place log messages.
+ * @param className the name of the class for this group of exceptions.
+ * @param numParams the number of parameters the detail message takes.
+ * @param pw the print writer for writing to the file.
+ */
+ private void writeMethods(String groupName, String exceptionName, String errorName,
+ int code, String level, String className, int numParams,
+ IndentingPrintWriter pw) {
+ String ident = StringUtil.toMixedCase(errorName);
+ pw.printMsg("public static final int @ = @ ;", errorName, getBase(groupName, code));
+ pw.println();
+ pw.flush();
+ writeMethodStatusCause(groupName, exceptionName, errorName, ident, level,
+ numParams, className, pw);
+ pw.println();
+ pw.flush();
+ writeMethodStatus(exceptionName, ident, numParams, pw);
+ pw.println();
+ pw.flush();
+ writeMethodCause(exceptionName, ident, numParams, pw);
+ pw.println();
+ pw.flush();
+ writeMethodNoArgs(exceptionName, ident, numParams, pw);
+ pw.println();
+ pw.flush();
+ }
+
+ /**
+ * Writes out a method for an error that takes a
+ * {@link org.omg.CORBA.CompletionStatus} and a cause.
+ *
+ * @param groupName the name of this group of exceptions.
+ * @param exceptionName the name of this particular exception.
+ * @param errorName the name of this particular error.
+ * @param ident the name of the error in mixed-case identifier form.
+ * @param logLevel the level at which to place log messages.
+ * @param numParams the number of parameters the detail message takes.
+ * @param className the name of the class for this group of exceptions.
+ * @param pw the print writer for writing to the file.
+ */
+ private void writeMethodStatusCause(String groupName, String exceptionName,
+ String errorName, String ident,
+ String logLevel, int numParams,
+ String className, IndentingPrintWriter pw) {
+ pw.indent();
+ pw.printMsg( "public @ @( CompletionStatus cs, Throwable t@) {", exceptionName,
+ ident, makeDeclArgs(true, numParams));
+ pw.printMsg( "@ exc = new @( @, cs ) ;", exceptionName, exceptionName, errorName);
+ pw.indent();
+ pw.println( "if (t != null)" );
+ pw.undent();
+ pw.println( "exc.initCause( t ) ;" );
+ pw.println();
+ pw.indent();
+ pw.printMsg( "if (logger.isLoggable( Level.@ )) {", logLevel);
+ if (numParams > 0) {
+ pw.printMsg( "Object[] parameters = new Object[@] ;", numParams);
+ for (int a = 0; a < numParams; ++a)
+ pw.printMsg("parameters[@] = arg@ ;", a, a);
+ } else
+ pw.println( "Object[] parameters = null ;");
+ pw.indent();
+ pw.printMsg( "doLog( Level.@, \"@.@\",", logLevel, groupName, ident);
+ pw.undent();
+ pw.undent();
+ pw.printMsg( "parameters, @.class, exc ) ;", className);
+ pw.println( "}");
+ pw.println();
+
+ pw.undent();
+ pw.println( "return exc ;");
+ pw.println( "}");
+ }
+
+ /**
+ * Writes out a method for an error that takes a
+ * {@link org.omg.CORBA.CompletionStatus}.
+ *
+ * @param exceptionName the name of this particular exception.
+ * @param ident the name of the error in mixed-case identifier form.
+ * @param numParams the number of parameters the detail message takes.
+ * @param pw the print writer for writing to the file.
+ */
+ private void writeMethodStatus(String exceptionName, String ident,
+ int numParams, IndentingPrintWriter pw) {
+ pw.indent();
+ pw.printMsg("public @ @( CompletionStatus cs@) {", exceptionName,
+ ident, makeDeclArgs(true, numParams));
+ pw.undent();
+ pw.printMsg("return @( cs, null@ ) ;", ident, makeCallArgs(true, numParams));
+ pw.println("}");
+ }
+
+ /**
+ * Writes out a method for an error that takes a cause.
+ *
+ * @param exceptionName the name of this particular exception.
+ * @param ident the name of the error in mixed-case identifier form.
+ * @param numParams the number of parameters the detail message takes.
+ * @param pw the print writer for writing to the file.
+ */
+ private void writeMethodCause(String exceptionName, String ident,
+ int numParams, IndentingPrintWriter pw) {
+ pw.indent();
+ pw.printMsg("public @ @( Throwable t@) {", exceptionName, ident,
+ makeDeclArgs(true, numParams));
+ pw.undent();
+ pw.printMsg("return @( CompletionStatus.COMPLETED_NO, t@ ) ;", ident,
+ makeCallArgs(true, numParams));
+ pw.println("}");
+ }
+
+ /**
+ * Writes out a method for an error that takes no arguments.
+ *
+ * @param exceptionName the name of this particular exception.
+ * @param ident the name of the error in mixed-case identifier form.
+ * @param numParams the number of parameters the detail message takes.
+ * @param pw the print writer for writing to the file.
+ */
+ private void writeMethodNoArgs(String exceptionName, String ident,
+ int numParams, IndentingPrintWriter pw) {
+
+ pw.indent();
+ pw.printMsg("public @ @( @) {", exceptionName, ident,
+ makeDeclArgs(false, numParams));
+ pw.undent();
+ pw.printMsg("return @( CompletionStatus.COMPLETED_NO, null@ ) ;",
+ ident, makeCallArgs(true, numParams));
+ pw.println("}");
+ }
+
+ /**
+ * Returns a list of comma-separated arguments with type declarations.
+ *
+ * @param leadingComma true if the list should start with a comma.
+ * @param numArgs the number of arguments to generate.
+ * @return the generated string.
+ */
+ private String makeDeclArgs(boolean leadingComma, int numArgs) {
+ return makeArgString("Object arg", leadingComma, numArgs);
+ }
+
+ /**
+ * Returns a list of comma-separated arguments without type declarations.
+ *
+ * @param leadingComma true if the list should start with a comma.
+ * @param numArgs the number of arguments to generate.
+ * @return the generated string.
+ */
+ private String makeCallArgs(boolean leadingComma, int numArgs) {
+ return makeArgString("arg", leadingComma, numArgs);
+ }
+
+ /**
+ * Returns a list of comma-separated arguments.
+ *
+ * @param prefixString the string with which to prefix each argument.
+ * @param leadingComma true if the list should start with a comma.
+ * @param numArgs the number of arguments to generate.
+ * @return the generated string.
+ */
+ private String makeArgString(String prefixString, boolean leadingComma,
+ int numArgs) {
+ if (numArgs == 0)
+ return " ";
+ if (numArgs == 1) {
+ if (leadingComma)
+ return ", " + prefixString + (numArgs - 1);
+ else
+ return " " + prefixString + (numArgs - 1);
+ }
+ return makeArgString(prefixString, leadingComma, numArgs - 1) +
+ ", " + prefixString + (numArgs - 1);
+ }
+
+ /**
+ * Returns the {@link String} containing the calculation of the
+ * error code.
+ *
+ * @param groupName the group of exception to which the code belongs.
+ * @param code the minor code number representing the exception within the group.
+ * @return the unique error code.
+ */
+ private String getBase(String groupName, int code) {
+ if (groupName.equals("OMG"))
+ return "OMGVMCID.value + " + code;
+ else
+ return "SUNVMCID.value + " + (code + getSunBaseNumber(groupName));
+ }
+
+ /**
+ * Returns the base number for Sun-specific exceptions.
+ *
+ * @return the base number.
+ */
+ private int getSunBaseNumber(String groupName) {
+ return 200 * SUN_EXCEPTION_GROUPS.indexOf(groupName);
+ }
+
+ /**
+ * Writes out a resource file using the data from the given
+ * {@link Input} object. The result is written to {@code outDir}.
+ *
+ * @param outDir the directory to write the Java class to.
+ * @param input the parsed input data.
+ * @throws FileNotFoundException if the output file can't be written.
+ */
+ private void writeResource(String outDir, Input input)
+ throws FileNotFoundException {
+ FileOutputStream file = new FileOutputStream(outDir + File.separator +
+ input.getClassName() + ".resource");
+ IndentingPrintWriter pw = new IndentingPrintWriter(file);
+ String groupName = input.getGroupName();
+ for (InputException e : input.getExceptions()) {
+ String exName = e.getName();
+ for (InputCode c : e.getCodes()) {
+ String ident = StringUtil.toMixedCase(c.getName());
+ pw.printMsg("@.@=\"@: (@) @\"", groupName, ident,
+ getMessageID(groupName, exName, c.getCode()), exName, c.getMessage());
+ }
+ pw.flush();
+ }
+ pw.close();
+ }
+
+ /**
+ * Returns the message ID corresponding to the given group name,
+ * exception name and error code.
+ *
+ * @param groupName the name of the group of exceptions.
+ * @param exception the name of the particular exception.
+ * @param code an error code from the given exception.
+ * @return the message ID.
+ */
+ private String getMessageID(String groupName, String exceptionName, int code) {
+ if (groupName.equals("OMG"))
+ return getStandardMessageID(exceptionName, code);
+ else
+ return getSunMessageID(groupName, exceptionName, code);
+ }
+
+ /**
+ * Returns the standard (OMG) message ID corresponding to the given
+ * exception name and error code.
+ *
+ * @param exceptionName the name of the particular exception.
+ * @param code an error code from the given exception.
+ * @return the message ID.
+ */
+ private String getStandardMessageID(String exceptionName, int code) {
+ return new Formatter().format("IOP%s0%04d", getExceptionID(exceptionName),
+ code).toString();
+ }
+
+ /**
+ * Returns the Sun message ID corresponding to the given group name,
+ * exception name and error code.
+ *
+ * @param groupName the name of the group of exceptions.
+ * @param exceptionName the name of the particular exception.
+ * @param code an error code from the given exception.
+ * @return the message ID.
+ */
+ private String getSunMessageID(String groupName, String exceptionName, int code) {
+ return new Formatter().format("IOP%s1%04d", getExceptionID(exceptionName),
+ getSunBaseNumber(groupName) + code).toString();
+ }
+
+ /**
+ * Returns the exception ID corresponding to the given exception name.
+ *
+ * @param exceptionName the name of the particular exception.
+ * @return the message ID.
+ */
+ private String getExceptionID(String exceptionName) {
+ return new Formatter().format("%03d", EXCEPTIONS.indexOf(exceptionName)).toString();
+ }
+
+ /**
+ * Entry point for running the generator from the command
+ * line. Users can specify either "make-class" or "make-resource"
+ * as the first argument to generate the specified type of file.
+ *
+ * @param args the command-line arguments.
+ * @throws FileNotFoundException if the input file can not be found.
+ * @throws IOException if an I/O error occurs.
+ */
+ public static void main(String[] args)
+ throws FileNotFoundException, IOException
+ {
+ if (args.length < 3)
+ {
+ System.err.println("(make-class|make-resource) <input file> <output dir>");
+ System.exit(-1);
+ }
+ if (args[0].equals("make-class"))
+ new MC().makeClass(args[1], args[2]);
+ else if (args[0].equals("make-resource"))
+ new MC().makeResource(args[1], args[2]);
+ else
+ System.err.println("Invalid command: " + args[0]);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/make/src/classes/build/tools/logutil/StringUtil.java Thu Feb 13 16:38:49 2014 +0100
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package build.tools.logutil;
+
+public abstract class StringUtil {
+ /** Take a string containing underscores, and return a string
+ * with the underscore removed, and all characters exception in lower
+ * case except the characters after the underscores.
+ */
+ public static String toMixedCase( String str )
+ {
+ StringBuffer sbuf = new StringBuffer( str.length() ) ;
+ boolean uppercaseNext = false ;
+ for (int ctr=0; ctr<str.length(); ctr++) {
+ char ch = str.charAt( ctr ) ;
+
+ if (ch == '_') {
+ uppercaseNext = true ;
+ } else if (uppercaseNext) {
+ sbuf.append( Character.toUpperCase( ch ) ) ;
+ uppercaseNext = false ;
+ } else {
+ sbuf.append( Character.toLowerCase( ch ) ) ;
+ }
+ }
+
+ return sbuf.toString() ;
+ }
+
+ public static int countArgs( String str )
+ {
+ int result = 0 ;
+ for( int ctr = 0; ctr<str.length(); ctr++ )
+ if (str.charAt(ctr) == '{')
+ result++ ;
+
+ return result ;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/make/src/classes/build/tools/stripproperties/StripPropertiesCorba.java Thu Feb 13 16:38:49 2014 +0100
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package build.tools.stripproperties;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedWriter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Reads a properties file from standard input and writes an equivalent
+ * properties file without comments to standard output.
+ */
+public class StripPropertiesCorba {
+
+ private static void error(String msg, Exception e) {
+ System.err.println("ERROR: stripproperties: " + msg);
+ if ( e != null ) {
+ System.err.println("EXCEPTION: " + e.toString());
+ e.printStackTrace();
+ }
+ }
+
+ private static List<String> infiles = new ArrayList<String>();
+ private static List<String> outfiles = new ArrayList<String>();
+
+ private static boolean parseOptions(String args[]) {
+ boolean ok = true;
+
+ for ( int i = 0; i < args.length ; i++ ) {
+ if ( "-clean".equals(args[i]) && i+2 < args.length ) {
+ infiles.add(args[++i]);
+ outfiles.add(args[++i]);
+ } else if ( args[i].charAt(0)=='@') {
+ String filename = args[i].substring(1);
+ FileInputStream finput = null;
+ byte contents[] = null;
+ try {
+ finput = new FileInputStream(filename);
+ int byteCount = finput.available();
+ if ( byteCount <= 0 ) {
+ error("The @file is empty", null);
+ ok = false;
+ } else {
+ contents = new byte[byteCount];
+ int bytesRead = finput.read(contents);
+ if ( byteCount != bytesRead ) {
+ error("Cannot read all of @file", null);
+ ok = false;
+ }
+ }
+ } catch ( IOException e ) {
+ error("cannot open " + filename, e);
+ ok = false;
+ }
+ if ( finput != null ) {
+ try {
+ finput.close();
+ } catch ( IOException e ) {
+ ok = false;
+ error("cannot close " + filename, e);
+ }
+ }
+ if ( ok && contents != null ) {
+ String tokens[] = (new String(contents)).split("\\s+");
+ if ( tokens.length > 0 ) {
+ ok = parseOptions(tokens);
+ }
+ }
+ if ( !ok ) {
+ break;
+ }
+ } else {
+ infiles.add(args[i]);
+ outfiles.add(args[i]);
+ }
+ }
+ return ok;
+ }
+
+ private static boolean stripFiles(List<String> infiles, List<String> outfiles) {
+ boolean ok = true;
+ Iterator<String> inIter = infiles.iterator();
+ Iterator<String> outIter = outfiles.iterator();
+
+ for (; inIter.hasNext(); ) {
+ String infile = inIter.next();
+ String outfile = outIter.next();
+
+ Properties prop = new Properties();
+ InputStream in = null;
+ try {
+ in = new BufferedInputStream(new FileInputStream(infile));
+ prop.load(in);
+ } catch ( FileNotFoundException e ) {
+ error("Cannot access file " + infile, e);
+ ok = false;
+ } catch ( IOException e ) {
+ error("IO exception processing file " + infile, e);
+ ok = false;
+ }
+ if ( in != null ) {
+ try {
+ in.close();
+ } catch ( IOException e ) {
+ error("IO exception closing file " + infile, e);
+ ok = false;
+ }
+ }
+ if ( !ok ) {
+ break;
+ }
+
+ OutputStream out = null;
+ try {
+ out = new FileOutputStream(outfile);
+ storeProperties(prop, out);
+ out.flush();
+ } catch ( IOException e ) {
+ error("IO exception processing file " + outfile, e);
+ ok = false;
+ }
+ if ( out != null ) {
+ try {
+ out.close();
+ } catch ( IOException e ) {
+ error("IO exception closing file " + outfile, e);
+ ok = false;
+ }
+ }
+ if ( !ok ) {
+ break;
+ }
+
+ }
+ return ok;
+ }
+
+ /**
+ * Strip the properties filenames supplied, replacing their contents.
+ * @param args Names of properties files to process and replace contents
+ */
+ public static void main(String args[]) {
+ boolean ok = parseOptions(args);
+ if ( !ok || !stripFiles(infiles, outfiles) ) {
+ System.exit(1);
+ }
+ }
+
+ // --- code below here is adapted from java.util.Properties ---
+
+ private static final String specialSaveChars = "=: \t\r\n\f#!";
+
+ /*
+ * Converts unicodes to encoded \uxxxx
+ * and writes out any of the characters in specialSaveChars
+ * with a preceding slash
+ */
+ private static String saveConvert(String theString, boolean escapeSpace) {
+ int len = theString.length();
+ StringBuffer outBuffer = new StringBuffer(len*2);
+
+ for(int x=0; x<len; x++) {
+ char aChar = theString.charAt(x);
+ switch(aChar) {
+ case ' ':
+ if (x == 0 || escapeSpace) {
+ outBuffer.append('\\');
+ }
+ outBuffer.append(' ');
+ break;
+ case '\\':
+ outBuffer.append('\\');
+ outBuffer.append('\\');
+ break;
+ case '\t':
+ outBuffer.append('\\');
+ outBuffer.append('t');
+ break;
+ case '\n':
+ outBuffer.append('\\');
+ outBuffer.append('n');
+ break;
+ case '\r':
+ outBuffer.append('\\');
+ outBuffer.append('r');
+ break;
+ case '\f':
+ outBuffer.append('\\');
+ outBuffer.append('f');
+ break;
+ default:
+ if ((aChar < 0x0020) || (aChar == 0x007e) || (aChar > 0x00ff)) {
+ outBuffer.append('\\');
+ outBuffer.append('u');
+ outBuffer.append(toHex((aChar >> 12) & 0xF));
+ outBuffer.append(toHex((aChar >> 8) & 0xF));
+ outBuffer.append(toHex((aChar >> 4) & 0xF));
+ outBuffer.append(toHex( aChar & 0xF));
+ } else {
+ if (specialSaveChars.indexOf(aChar) != -1) {
+ outBuffer.append('\\');
+ }
+ outBuffer.append(aChar);
+ }
+ }
+ }
+ return outBuffer.toString();
+ }
+
+ /**
+ * Writes the content of <code>properties</code> to <code>out</code>.
+ * The format is that of Properties.store with the following modifications:
+ * <ul>
+ * <li>No header or date is written
+ * <li>Latin-1 characters are written as single bytes, not escape sequences
+ * <li>Line breaks are indicated by a single \n independent of platform
+ * <ul>
+ */
+ private static void storeProperties(Properties properties, OutputStream out)
+ throws IOException {
+ BufferedWriter awriter;
+ awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
+ for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) {
+ String key = (String)e.nextElement();
+ String val = (String)properties.get(key);
+ key = saveConvert(key, true);
+
+ /* No need to escape embedded and trailing spaces for value, hence
+ * pass false to flag.
+ */
+ val = saveConvert(val, false);
+ writeln(awriter, key + "=" + val);
+ }
+ awriter.flush();
+ }
+
+ private static void writeln(BufferedWriter bw, String s) throws IOException {
+ bw.write(s);
+ bw.write("\n");
+ }
+
+ /**
+ * Convert a nibble to a hex character
+ * @param nibble the nibble to convert.
+ */
+ private static char toHex(int nibble) {
+ return hexDigit[(nibble & 0xF)];
+ }
+
+ /** A table of hex digits */
+ private static final char[] hexDigit = {
+ '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
+ };
+}
--- a/corba/make/tools/src/build/tools/stripproperties/StripPropertiesCorba.java Wed Feb 05 11:04:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package build.tools.stripproperties;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedWriter;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * Reads a properties file from standard input and writes an equivalent
- * properties file without comments to standard output.
- */
-public class StripPropertiesCorba {
-
- private static void error(String msg, Exception e) {
- System.err.println("ERROR: stripproperties: " + msg);
- if ( e != null ) {
- System.err.println("EXCEPTION: " + e.toString());
- e.printStackTrace();
- }
- }
-
- private static List<String> infiles = new ArrayList<String>();
- private static List<String> outfiles = new ArrayList<String>();
-
- private static boolean parseOptions(String args[]) {
- boolean ok = true;
-
- for ( int i = 0; i < args.length ; i++ ) {
- if ( "-clean".equals(args[i]) && i+2 < args.length ) {
- infiles.add(args[++i]);
- outfiles.add(args[++i]);
- } else if ( args[i].charAt(0)=='@') {
- String filename = args[i].substring(1);
- FileInputStream finput = null;
- byte contents[] = null;
- try {
- finput = new FileInputStream(filename);
- int byteCount = finput.available();
- if ( byteCount <= 0 ) {
- error("The @file is empty", null);
- ok = false;
- } else {
- contents = new byte[byteCount];
- int bytesRead = finput.read(contents);
- if ( byteCount != bytesRead ) {
- error("Cannot read all of @file", null);
- ok = false;
- }
- }
- } catch ( IOException e ) {
- error("cannot open " + filename, e);
- ok = false;
- }
- if ( finput != null ) {
- try {
- finput.close();
- } catch ( IOException e ) {
- ok = false;
- error("cannot close " + filename, e);
- }
- }
- if ( ok && contents != null ) {
- String tokens[] = (new String(contents)).split("\\s+");
- if ( tokens.length > 0 ) {
- ok = parseOptions(tokens);
- }
- }
- if ( !ok ) {
- break;
- }
- } else {
- infiles.add(args[i]);
- outfiles.add(args[i]);
- }
- }
- return ok;
- }
-
- private static boolean stripFiles(List<String> infiles, List<String> outfiles) {
- boolean ok = true;
- Iterator<String> inIter = infiles.iterator();
- Iterator<String> outIter = outfiles.iterator();
-
- for (; inIter.hasNext(); ) {
- String infile = inIter.next();
- String outfile = outIter.next();
-
- Properties prop = new Properties();
- InputStream in = null;
- try {
- in = new BufferedInputStream(new FileInputStream(infile));
- prop.load(in);
- } catch ( FileNotFoundException e ) {
- error("Cannot access file " + infile, e);
- ok = false;
- } catch ( IOException e ) {
- error("IO exception processing file " + infile, e);
- ok = false;
- }
- if ( in != null ) {
- try {
- in.close();
- } catch ( IOException e ) {
- error("IO exception closing file " + infile, e);
- ok = false;
- }
- }
- if ( !ok ) {
- break;
- }
-
- OutputStream out = null;
- try {
- out = new FileOutputStream(outfile);
- storeProperties(prop, out);
- out.flush();
- } catch ( IOException e ) {
- error("IO exception processing file " + outfile, e);
- ok = false;
- }
- if ( out != null ) {
- try {
- out.close();
- } catch ( IOException e ) {
- error("IO exception closing file " + outfile, e);
- ok = false;
- }
- }
- if ( !ok ) {
- break;
- }
-
- }
- return ok;
- }
-
- /**
- * Strip the properties filenames supplied, replacing their contents.
- * @param args Names of properties files to process and replace contents
- */
- public static void main(String args[]) {
- boolean ok = parseOptions(args);
- if ( !ok || !stripFiles(infiles, outfiles) ) {
- System.exit(1);
- }
- }
-
- // --- code below here is adapted from java.util.Properties ---
-
- private static final String specialSaveChars = "=: \t\r\n\f#!";
-
- /*
- * Converts unicodes to encoded \uxxxx
- * and writes out any of the characters in specialSaveChars
- * with a preceding slash
- */
- private static String saveConvert(String theString, boolean escapeSpace) {
- int len = theString.length();
- StringBuffer outBuffer = new StringBuffer(len*2);
-
- for(int x=0; x<len; x++) {
- char aChar = theString.charAt(x);
- switch(aChar) {
- case ' ':
- if (x == 0 || escapeSpace) {
- outBuffer.append('\\');
- }
- outBuffer.append(' ');
- break;
- case '\\':
- outBuffer.append('\\');
- outBuffer.append('\\');
- break;
- case '\t':
- outBuffer.append('\\');
- outBuffer.append('t');
- break;
- case '\n':
- outBuffer.append('\\');
- outBuffer.append('n');
- break;
- case '\r':
- outBuffer.append('\\');
- outBuffer.append('r');
- break;
- case '\f':
- outBuffer.append('\\');
- outBuffer.append('f');
- break;
- default:
- if ((aChar < 0x0020) || (aChar == 0x007e) || (aChar > 0x00ff)) {
- outBuffer.append('\\');
- outBuffer.append('u');
- outBuffer.append(toHex((aChar >> 12) & 0xF));
- outBuffer.append(toHex((aChar >> 8) & 0xF));
- outBuffer.append(toHex((aChar >> 4) & 0xF));
- outBuffer.append(toHex( aChar & 0xF));
- } else {
- if (specialSaveChars.indexOf(aChar) != -1) {
- outBuffer.append('\\');
- }
- outBuffer.append(aChar);
- }
- }
- }
- return outBuffer.toString();
- }
-
- /**
- * Writes the content of <code>properties</code> to <code>out</code>.
- * The format is that of Properties.store with the following modifications:
- * <ul>
- * <li>No header or date is written
- * <li>Latin-1 characters are written as single bytes, not escape sequences
- * <li>Line breaks are indicated by a single \n independent of platform
- * <ul>
- */
- private static void storeProperties(Properties properties, OutputStream out)
- throws IOException {
- BufferedWriter awriter;
- awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
- for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) {
- String key = (String)e.nextElement();
- String val = (String)properties.get(key);
- key = saveConvert(key, true);
-
- /* No need to escape embedded and trailing spaces for value, hence
- * pass false to flag.
- */
- val = saveConvert(val, false);
- writeln(awriter, key + "=" + val);
- }
- awriter.flush();
- }
-
- private static void writeln(BufferedWriter bw, String s) throws IOException {
- bw.write(s);
- bw.write("\n");
- }
-
- /**
- * Convert a nibble to a hex character
- * @param nibble the nibble to convert.
- */
- private static char toHex(int nibble) {
- return hexDigit[(nibble & 0xF)];
- }
-
- /** A table of hex digits */
- private static final char[] hexDigit = {
- '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
- };
-}
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/IndentingPrintWriter.java Wed Feb 05 11:04:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.corba.se.logutil;
-
-import java.io.PrintWriter ;
-import java.io.Writer ;
-import java.io.OutputStream ;
-import java.io.BufferedWriter ;
-import java.io.OutputStreamWriter ;
-import java.util.StringTokenizer ;
-
-public class IndentingPrintWriter extends PrintWriter {
- private int level = 0 ;
- private int indentWidth = 4 ;
- private String indentString = "" ;
-
- public void printMsg( String msg, Object... data )
- {
- // System.out.println( "printMsg called with msg=" + msg + " data=" + data ) ;
- StringTokenizer st = new StringTokenizer( msg, "@", true ) ;
- StringBuffer result = new StringBuffer() ;
- String token = null ;
- int pos = 0;
-
- while (st.hasMoreTokens()) {
- token = st.nextToken() ;
- if (token.equals("@")) {
- if (pos < data.length) {
- result.append( data[pos] );
- ++pos;
- } else {
- throw new Error( "List too short for message" ) ;
- }
- } else {
- result.append( token ) ;
- }
- }
-
- // System.out.println( "Printing result " + result + " to file" ) ;
- print( result ) ;
- println() ;
- }
-
- public IndentingPrintWriter (Writer out) {
- super( out, true ) ;
- // System.out.println( "Constructing a new IndentingPrintWriter with Writer " + out ) ;
- }
-
- public IndentingPrintWriter(Writer out, boolean autoFlush) {
- super( out, autoFlush ) ;
- // System.out.println( "Constructing a new IndentingPrintWriter with Writer " + out ) ;
- }
-
- public IndentingPrintWriter(OutputStream out) {
- super(out, true);
- // System.out.println( "Constructing a new IndentingPrintWriter with OutputStream " + out ) ;
- }
-
- public IndentingPrintWriter(OutputStream out, boolean autoFlush) {
- super(new BufferedWriter(new OutputStreamWriter(out)), autoFlush);
- // System.out.println( "Constructing a new IndentingPrintWriter with OutputStream " + out ) ;
- }
-
- public void setIndentWidth( int indentWidth )
- {
- this.indentWidth = indentWidth ;
- updateIndentString() ;
- }
-
- public void indent()
- {
- level++ ;
- updateIndentString() ;
- }
-
- public void undent()
- {
- if (level > 0) {
- level-- ;
- updateIndentString() ;
- }
- }
-
- private void updateIndentString()
- {
- int size = level * indentWidth ;
- StringBuffer sbuf = new StringBuffer( size ) ;
- for (int ctr = 0; ctr<size; ctr++ )
- sbuf.append( " " ) ;
- indentString = sbuf.toString() ;
- }
-
- // overridden from PrintWriter
- public void println()
- {
- super.println() ;
-
- print( indentString ) ;
- }
-}
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/Input.java Wed Feb 05 11:04:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,211 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.corba.se.logutil;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStreamReader;
-import java.io.IOException;
-
-import java.util.LinkedList;
-import java.util.Queue;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class Input {
-
- /**
- * The name of the package this class will inhabit.
- */
- private String packageName;
-
- /**
- * The name of the generated class.
- */
- private String className;
-
- /**
- * The name of the group of exceptions handled by the class.
- */
- private String groupName;
-
- /**
- * The group of exceptions.
- */
- private Queue<InputException> exceptions;
-
- /**
- * Represents the current state of parsing the input.
- */
- private enum State
- {
- OUTER,
- IN_CLASS,
- IN_EXCEPTION_LIST
- };
-
- /**
- * Regular expression to match each code line.
- */
- private static final Pattern EXCEPTION_INFO_REGEX =
- Pattern.compile("(\\w+)\\s*(\\d+)\\s*(\\w+)");
-
- /**
- * Parses the specified file to create a new {@link Input}
- * object.
- *
- * @param filename the file to parse.
- * @throws FileNotFoundException if the file can't be found.
- * @throws IOException if an I/O error occurs.
- */
- public Input(final String filename)
- throws FileNotFoundException, IOException {
- BufferedReader r =
- new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
- State state = State.OUTER;
- InputException current = null;
- exceptions = new LinkedList<InputException>();
- String line;
- while ((line = r.readLine()) != null) {
- // Skip ; comments
- if (line.startsWith(";"))
- continue;
-
- int index = line.indexOf("(");
- if (index == -1)
- continue;
-
- switch (state) {
- case OUTER:
- state = State.IN_CLASS;
- String[] classInfo = line.substring(index).split(" ");
- packageName = classInfo[0].substring(2, classInfo[0].length() - 1);
- className = classInfo[1].substring(1, classInfo[1].length() - 1);
- groupName = classInfo[2];
- break;
- case IN_CLASS:
- state = State.IN_EXCEPTION_LIST;
- break;
- case IN_EXCEPTION_LIST:
- boolean inQuote = false;
- boolean inCode = false;
- boolean end = false;
- int start = index + 1;
- Queue<String> lines = new LinkedList<String>();
- for (int a = start; a < line.length(); ++a) {
- if (line.charAt(a) == '(' && !inCode && !inQuote) {
- if (current == null)
- current =
- new InputException(line.substring(start, a).trim());
- start = a + 1;
- inCode = true;
- }
- if (line.charAt(a) == '"')
- inQuote = !inQuote;
- if (line.charAt(a) == ')' && !inQuote) {
- if (inCode) {
- lines.offer(line.substring(start, a));
- inCode = false;
- } else
- end = true;
- }
- if (!end && a == line.length() - 1)
- line += r.readLine();
- }
- for (String l : lines) {
- int stringStart = l.indexOf("\"") + 1;
- int stringEnd = l.indexOf("\"", stringStart);
- Matcher matcher = EXCEPTION_INFO_REGEX.matcher(l.substring(0, stringStart));
- if (matcher.find())
- current.add(new InputCode(matcher.group(1),
- Integer.parseInt(matcher.group(2)),
- matcher.group(3),
- l.substring(stringStart, stringEnd)));
- }
- exceptions.offer(current);
- current = null;
- break;
- }
- }
- }
-
- /**
- * Returns the name of this group of exceptions.
- *
- * @return the name of this group of exceptions.
- */
- public String getGroupName()
- {
- return groupName;
- }
-
- /**
- * Returns the name of the package this class will go in.
- *
- * @return the name of the package.
- */
- public String getPackageName()
- {
- return packageName;
- }
-
- /**
- * Returns the name of the generated class.
- *
- * @return the name of the class.
- */
- public String getClassName()
- {
- return className;
- }
-
- /**
- * Returns the exceptions contained in this class.
- *
- * @return the exceptions.
- */
- public Queue<InputException> getExceptions() {
- return exceptions;
- }
-
- /**
- * Returns a textual representation of this input.
- *
- * @return a textual representation.
- */
- public String toString() {
- return getClass().getName() +
- "[packageName=" + packageName +
- ",className=" + className +
- ",groupName=" + groupName +
- ",exceptions=" + exceptions +
- "]";
- }
-
-}
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/InputCode.java Wed Feb 05 11:04:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.tools.corba.se.logutil;
-
-public class InputCode {
-
- /**
- * The name of this code.
- */
- private final String name;
-
- /**
- * The code.
- */
- private final int code;
-
- /**
- * The log level for this code.
- */
- private final String logLevel;
-
- /**
- * The error message for this code.
- */
- private final String message;
-
- /**
- * Creates a new error code with the specified name, code,
- * log level and error message.
- *
- * @param name the name of the new code.
- * @param code the code itself.
- * @param logLevel the level of severity of this error.
- * @param message the error message for this code.
- */
- public InputCode(final String name, final int code,
- final String logLevel, final String message) {
- this.name = name;
- this.code = code;
- this.logLevel = logLevel;
- this.message = message;
- }
-
- /**
- * Returns the name of this code.
- *
- * @return the name of the code.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns the code.
- *
- * @return the code.
- */
- public int getCode() {
- return code;
- }
-
- /**
- * Returns the severity of this code.
- *
- * @return the log level severity of the code.
- */
- public String getLogLevel() {
- return logLevel;
- }
-
- /**
- * Returns the error message for this code.
- *
- * @return the error message for this code.
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Returns a textual representation of this code.
- *
- * @return a textual representation.
- */
- public String toString() {
- return getClass().getName() +
- "[name=" + name +
- ",code=" + code +
- ",logLevel=" + logLevel +
- ",message=" + message +
- "]";
- }
-
-}
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/InputException.java Wed Feb 05 11:04:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.tools.corba.se.logutil;
-
-import java.util.LinkedList;
-import java.util.Queue;
-
-public class InputException {
-
- /**
- * The name of this exception.
- */
- private final String name;
-
- /**
- * The codes associated with this exception.
- */
- private final Queue<InputCode> codes;
-
- /**
- * Constructs a new {@link InputException} with the
- * specified name.
- *
- * @param name the name of the new exception;
- */
- public InputException(final String name) {
- this.name = name;
- codes = new LinkedList<InputCode>();
- }
-
- /**
- * Adds a new code to this exception.
- *
- * @param c the code to add.
- */
- public void add(InputCode c)
- {
- codes.offer(c);
- }
-
- /**
- * Returns the name of this exception.
- *
- * @return the exception's name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns the codes associated with this exception.
- *
- * @return the exception's codes.
- */
- public Queue<InputCode> getCodes() {
- return codes;
- }
-
- /**
- * Returns a textual representation of this exception.
- *
- * @return a textual representation.
- */
- public String toString() {
- return getClass().getName()
- + "[name=" + name
- + ",codes=" + codes
- + "]";
- }
-
-}
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/MC.java Wed Feb 05 11:04:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,559 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.tools.corba.se.logutil;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Formatter;
-import java.util.List;
-import java.util.Queue;
-
-public class MC {
-
- private static final String VERSION = "1.0";
-
- private static final List<String> SUN_EXCEPTION_GROUPS = Arrays.asList(new String[]
- { "SUNBASE", "ORBUTIL", "ACTIVATION", "NAMING", "INTERCEPTORS", "POA", "IOR", "UTIL" });
-
- private static final List<String> EXCEPTIONS = Arrays.asList(new String[]
- { "UNKNOWN", "BAD_PARAM", "NO_MEMORY", "IMP_LIMIT", "COMM_FAILURE", "INV_OBJREF", "NO_PERMISSION",
- "INTERNAL", "MARSHAL", "INITIALIZE", "NO_IMPLEMENT", "BAD_TYPECODE", "BAD_OPERATION", "NO_RESOURCES",
- "NO_RESPONSE", "PERSIST_STORE", "BAD_INV_ORDER", "TRANSIENT", "FREE_MEM", "INV_IDENT", "INV_FLAG",
- "INTF_REPOS", "BAD_CONTEXT", "OBJ_ADAPTER", "DATA_CONVERSION", "OBJECT_NOT_EXIST", "TRANSACTION_REQUIRED",
- "TRANSACTION_ROLLEDBACK", "INVALID_TRANSACTION", "INV_POLICY", "CODESET_INCOMPATIBLE", "REBIND",
- "TIMEOUT", "TRANSACTION_UNAVAILABLE", "BAD_QOS", "INVALID_ACTIVITY", "ACTIVITY_COMPLETED",
- "ACTIVITY_REQUIRED" });
-
- /**
- * Read the minor codes from the input file and
- * write out a resource file.
- *
- * @param inFile the file to read the codes from.
- * @param outDir the directory to write the resource file to.
- * @throws FileNotFoundException if the input file can not be found.
- * @throws IOException if an I/O error occurs.
- */
- private void makeResource(String inFile, String outDir)
- throws FileNotFoundException, IOException {
- writeResource(outDir, new Input(inFile));
- }
-
- /**
- * Create a new Java source file using the specified Scheme input file,
- * and writing the result to the given output directory.
- *
- * @param inFile the file to read the data from.
- * @param outDir the directory to write the Java class to.
- * @throws FileNotFoundException if the input file can not be found.
- * @throws IOException if an I/O error occurs.
- */
- private void makeClass(String inFile, String outDir)
- throws FileNotFoundException, IOException {
- writeClass(inFile, outDir, new Input(inFile));
- }
-
- /**
- * Writes out a Java source file using the data from the given
- * {@link Input} object. The result is written to {@code outDir}.
- * The name of the input file is just used in the header of the
- * resulting source file.
- *
- * @param inFile the name of the file the data was read from.
- * @param outDir the directory to write the Java class to.
- * @param input the parsed input data.
- * @throws FileNotFoundException if the output file can't be written.
- */
- private void writeClass(String inFile, String outDir, Input input)
- throws FileNotFoundException {
- String packageName = input.getPackageName();
- String className = input.getClassName();
- String groupName = input.getGroupName();
- Queue<InputException> exceptions = input.getExceptions();
- FileOutputStream file = new FileOutputStream(outDir + File.separator + className + ".java");
- IndentingPrintWriter pw = new IndentingPrintWriter(file);
-
- writeClassHeader(inFile, groupName, pw);
- pw.printMsg("package @ ;", packageName);
- pw.println();
- pw.println("import java.util.logging.Logger ;");
- pw.println("import java.util.logging.Level ;");
- pw.println();
- pw.println("import org.omg.CORBA.OMGVMCID ;");
- pw.println( "import com.sun.corba.se.impl.util.SUNVMCID ;");
- pw.println( "import org.omg.CORBA.CompletionStatus ;");
- pw.println( "import org.omg.CORBA.SystemException ;");
- pw.println();
- pw.println( "import com.sun.corba.se.spi.orb.ORB ;");
- pw.println();
- pw.println( "import com.sun.corba.se.spi.logging.LogWrapperFactory;");
- pw.println();
- pw.println( "import com.sun.corba.se.spi.logging.LogWrapperBase;");
- pw.println();
- writeImports(exceptions, pw);
- pw.println();
- pw.indent();
- pw.printMsg("public class @ extends LogWrapperBase {", className);
- pw.println();
- pw.printMsg("public @( Logger logger )", className);
- pw.indent();
- pw.println( "{");
- pw.undent();
- pw.println( "super( logger ) ;");
- pw.println( "}");
- pw.println();
- pw.flush();
- writeFactoryMethod(className, groupName, pw);
- writeExceptions(groupName, exceptions, className, pw);
- pw.undent();
- pw.println( );
- pw.println( "}");
- pw.flush();
- pw.close();
- }
-
- /**
- * Writes out the header of a Java source file.
- *
- * @param inFile the input file the file was generated from.
- * @param groupName the group of exceptions the Java source file is for.
- * @param pw the print writer used to write the output.
- */
- private void writeClassHeader(String inFile, String groupName,
- IndentingPrintWriter pw) {
- if (groupName.equals("OMG"))
- pw.println("// Log wrapper class for standard exceptions");
- else
- pw.printMsg("// Log wrapper class for Sun private system exceptions in group @",
- groupName);
- pw.println("//");
- pw.printMsg("// Generated by MC.java version @, DO NOT EDIT BY HAND!", VERSION);
- pw.printMsg("// Generated from input file @ on @", inFile, new Date());
- pw.println();
- }
-
- /**
- * Write out the import list for the exceptions.
- *
- * @param groups the exceptions that were parsed.
- * @param pw the {@link IndentingPrintWriter} for writing to the file.
- */
- private void writeImports(Queue<InputException> exceptions,
- IndentingPrintWriter pw) {
- if (exceptions == null)
- return;
- for (InputException e : exceptions)
- pw.println("import org.omg.CORBA." + e.getName() + " ;");
- }
-
- /**
- * Write out the factory method for this group of exceptions.
- *
- * @param className the name of the generated class.
- * @param groupName the name of this group of exceptions.
- * @param pw the {@link IndentingPrintWriter} for writing to the file.
- */
- private void writeFactoryMethod(String className, String groupName,
- IndentingPrintWriter pw) {
- pw.indent();
- pw.println( "private static LogWrapperFactory factory = new LogWrapperFactory() {");
- pw.println( "public LogWrapperBase create( Logger logger )" );
- pw.indent();
- pw.println( "{");
- pw.undent();
- pw.printMsg("return new @( logger ) ;", className);
- pw.undent();
- pw.println( "}" );
- pw.println( "} ;" );
- pw.println();
- pw.printMsg("public static @ get( ORB orb, String logDomain )", className);
- pw.indent();
- pw.println( "{");
- pw.indent();
- pw.printMsg( "@ wrapper = ", className);
- pw.indent();
- pw.printMsg( "(@) orb.getLogWrapper( logDomain, ", className);
- pw.undent();
- pw.undent();
- pw.printMsg( "\"@\", factory ) ;", groupName);
- pw.undent();
- pw.println( "return wrapper ;" );
- pw.println( "} " );
- pw.println();
- pw.printMsg( "public static @ get( String logDomain )", className);
- pw.indent();
- pw.println( "{");
- pw.indent();
- pw.printMsg( "@ wrapper = ", className);
- pw.indent();
- pw.printMsg( "(@) ORB.staticGetLogWrapper( logDomain, ", className);
- pw.undent();
- pw.undent();
- pw.printMsg( "\"@\", factory ) ;", groupName);
- pw.undent();
- pw.println( "return wrapper ;" );
- pw.println( "} " );
- pw.println();
- }
-
- /**
- * Writes out the exceptions themselves.
- *
- * @param groupName the name of this group of exceptions.
- * @param exceptions the exceptions to write out.
- * @param className the name of the generated class.
- * @param pw the {@link IndentingPrintWriter} for writing to the file.
- */
- private void writeExceptions(String groupName, Queue<InputException> exceptions,
- String className, IndentingPrintWriter pw) {
- for (InputException e : exceptions) {
- pw.println("///////////////////////////////////////////////////////////");
- pw.printMsg("// @", e.getName());
- pw.println("///////////////////////////////////////////////////////////");
- pw.println();
- for (InputCode c : e.getCodes())
- writeMethods(groupName, e.getName(), c.getName(), c.getCode(),
- c.getLogLevel(), className, StringUtil.countArgs(c.getMessage()), pw);
- pw.flush();
- }
- }
-
- /**
- * Writes out the methods for a particular error.
- *
- * @param groupName the name of this group of exceptions.
- * @param exceptionName the name of this particular exception.
- * @param errorName the name of this particular error.
- * @param code the minor code for this particular error.
- * @param ident the name of the error in mixed-case identifier form.
- * @param level the level at which to place log messages.
- * @param className the name of the class for this group of exceptions.
- * @param numParams the number of parameters the detail message takes.
- * @param pw the print writer for writing to the file.
- */
- private void writeMethods(String groupName, String exceptionName, String errorName,
- int code, String level, String className, int numParams,
- IndentingPrintWriter pw) {
- String ident = StringUtil.toMixedCase(errorName);
- pw.printMsg("public static final int @ = @ ;", errorName, getBase(groupName, code));
- pw.println();
- pw.flush();
- writeMethodStatusCause(groupName, exceptionName, errorName, ident, level,
- numParams, className, pw);
- pw.println();
- pw.flush();
- writeMethodStatus(exceptionName, ident, numParams, pw);
- pw.println();
- pw.flush();
- writeMethodCause(exceptionName, ident, numParams, pw);
- pw.println();
- pw.flush();
- writeMethodNoArgs(exceptionName, ident, numParams, pw);
- pw.println();
- pw.flush();
- }
-
- /**
- * Writes out a method for an error that takes a
- * {@link org.omg.CORBA.CompletionStatus} and a cause.
- *
- * @param groupName the name of this group of exceptions.
- * @param exceptionName the name of this particular exception.
- * @param errorName the name of this particular error.
- * @param ident the name of the error in mixed-case identifier form.
- * @param logLevel the level at which to place log messages.
- * @param numParams the number of parameters the detail message takes.
- * @param className the name of the class for this group of exceptions.
- * @param pw the print writer for writing to the file.
- */
- private void writeMethodStatusCause(String groupName, String exceptionName,
- String errorName, String ident,
- String logLevel, int numParams,
- String className, IndentingPrintWriter pw) {
- pw.indent();
- pw.printMsg( "public @ @( CompletionStatus cs, Throwable t@) {", exceptionName,
- ident, makeDeclArgs(true, numParams));
- pw.printMsg( "@ exc = new @( @, cs ) ;", exceptionName, exceptionName, errorName);
- pw.indent();
- pw.println( "if (t != null)" );
- pw.undent();
- pw.println( "exc.initCause( t ) ;" );
- pw.println();
- pw.indent();
- pw.printMsg( "if (logger.isLoggable( Level.@ )) {", logLevel);
- if (numParams > 0) {
- pw.printMsg( "Object[] parameters = new Object[@] ;", numParams);
- for (int a = 0; a < numParams; ++a)
- pw.printMsg("parameters[@] = arg@ ;", a, a);
- } else
- pw.println( "Object[] parameters = null ;");
- pw.indent();
- pw.printMsg( "doLog( Level.@, \"@.@\",", logLevel, groupName, ident);
- pw.undent();
- pw.undent();
- pw.printMsg( "parameters, @.class, exc ) ;", className);
- pw.println( "}");
- pw.println();
-
- pw.undent();
- pw.println( "return exc ;");
- pw.println( "}");
- }
-
- /**
- * Writes out a method for an error that takes a
- * {@link org.omg.CORBA.CompletionStatus}.
- *
- * @param exceptionName the name of this particular exception.
- * @param ident the name of the error in mixed-case identifier form.
- * @param numParams the number of parameters the detail message takes.
- * @param pw the print writer for writing to the file.
- */
- private void writeMethodStatus(String exceptionName, String ident,
- int numParams, IndentingPrintWriter pw) {
- pw.indent();
- pw.printMsg("public @ @( CompletionStatus cs@) {", exceptionName,
- ident, makeDeclArgs(true, numParams));
- pw.undent();
- pw.printMsg("return @( cs, null@ ) ;", ident, makeCallArgs(true, numParams));
- pw.println("}");
- }
-
- /**
- * Writes out a method for an error that takes a cause.
- *
- * @param exceptionName the name of this particular exception.
- * @param ident the name of the error in mixed-case identifier form.
- * @param numParams the number of parameters the detail message takes.
- * @param pw the print writer for writing to the file.
- */
- private void writeMethodCause(String exceptionName, String ident,
- int numParams, IndentingPrintWriter pw) {
- pw.indent();
- pw.printMsg("public @ @( Throwable t@) {", exceptionName, ident,
- makeDeclArgs(true, numParams));
- pw.undent();
- pw.printMsg("return @( CompletionStatus.COMPLETED_NO, t@ ) ;", ident,
- makeCallArgs(true, numParams));
- pw.println("}");
- }
-
- /**
- * Writes out a method for an error that takes no arguments.
- *
- * @param exceptionName the name of this particular exception.
- * @param ident the name of the error in mixed-case identifier form.
- * @param numParams the number of parameters the detail message takes.
- * @param pw the print writer for writing to the file.
- */
- private void writeMethodNoArgs(String exceptionName, String ident,
- int numParams, IndentingPrintWriter pw) {
-
- pw.indent();
- pw.printMsg("public @ @( @) {", exceptionName, ident,
- makeDeclArgs(false, numParams));
- pw.undent();
- pw.printMsg("return @( CompletionStatus.COMPLETED_NO, null@ ) ;",
- ident, makeCallArgs(true, numParams));
- pw.println("}");
- }
-
- /**
- * Returns a list of comma-separated arguments with type declarations.
- *
- * @param leadingComma true if the list should start with a comma.
- * @param numArgs the number of arguments to generate.
- * @return the generated string.
- */
- private String makeDeclArgs(boolean leadingComma, int numArgs) {
- return makeArgString("Object arg", leadingComma, numArgs);
- }
-
- /**
- * Returns a list of comma-separated arguments without type declarations.
- *
- * @param leadingComma true if the list should start with a comma.
- * @param numArgs the number of arguments to generate.
- * @return the generated string.
- */
- private String makeCallArgs(boolean leadingComma, int numArgs) {
- return makeArgString("arg", leadingComma, numArgs);
- }
-
- /**
- * Returns a list of comma-separated arguments.
- *
- * @param prefixString the string with which to prefix each argument.
- * @param leadingComma true if the list should start with a comma.
- * @param numArgs the number of arguments to generate.
- * @return the generated string.
- */
- private String makeArgString(String prefixString, boolean leadingComma,
- int numArgs) {
- if (numArgs == 0)
- return " ";
- if (numArgs == 1) {
- if (leadingComma)
- return ", " + prefixString + (numArgs - 1);
- else
- return " " + prefixString + (numArgs - 1);
- }
- return makeArgString(prefixString, leadingComma, numArgs - 1) +
- ", " + prefixString + (numArgs - 1);
- }
-
- /**
- * Returns the {@link String} containing the calculation of the
- * error code.
- *
- * @param groupName the group of exception to which the code belongs.
- * @param code the minor code number representing the exception within the group.
- * @return the unique error code.
- */
- private String getBase(String groupName, int code) {
- if (groupName.equals("OMG"))
- return "OMGVMCID.value + " + code;
- else
- return "SUNVMCID.value + " + (code + getSunBaseNumber(groupName));
- }
-
- /**
- * Returns the base number for Sun-specific exceptions.
- *
- * @return the base number.
- */
- private int getSunBaseNumber(String groupName) {
- return 200 * SUN_EXCEPTION_GROUPS.indexOf(groupName);
- }
-
- /**
- * Writes out a resource file using the data from the given
- * {@link Input} object. The result is written to {@code outDir}.
- *
- * @param outDir the directory to write the Java class to.
- * @param input the parsed input data.
- * @throws FileNotFoundException if the output file can't be written.
- */
- private void writeResource(String outDir, Input input)
- throws FileNotFoundException {
- FileOutputStream file = new FileOutputStream(outDir + File.separator +
- input.getClassName() + ".resource");
- IndentingPrintWriter pw = new IndentingPrintWriter(file);
- String groupName = input.getGroupName();
- for (InputException e : input.getExceptions()) {
- String exName = e.getName();
- for (InputCode c : e.getCodes()) {
- String ident = StringUtil.toMixedCase(c.getName());
- pw.printMsg("@.@=\"@: (@) @\"", groupName, ident,
- getMessageID(groupName, exName, c.getCode()), exName, c.getMessage());
- }
- pw.flush();
- }
- pw.close();
- }
-
- /**
- * Returns the message ID corresponding to the given group name,
- * exception name and error code.
- *
- * @param groupName the name of the group of exceptions.
- * @param exception the name of the particular exception.
- * @param code an error code from the given exception.
- * @return the message ID.
- */
- private String getMessageID(String groupName, String exceptionName, int code) {
- if (groupName.equals("OMG"))
- return getStandardMessageID(exceptionName, code);
- else
- return getSunMessageID(groupName, exceptionName, code);
- }
-
- /**
- * Returns the standard (OMG) message ID corresponding to the given
- * exception name and error code.
- *
- * @param exceptionName the name of the particular exception.
- * @param code an error code from the given exception.
- * @return the message ID.
- */
- private String getStandardMessageID(String exceptionName, int code) {
- return new Formatter().format("IOP%s0%04d", getExceptionID(exceptionName),
- code).toString();
- }
-
- /**
- * Returns the Sun message ID corresponding to the given group name,
- * exception name and error code.
- *
- * @param groupName the name of the group of exceptions.
- * @param exceptionName the name of the particular exception.
- * @param code an error code from the given exception.
- * @return the message ID.
- */
- private String getSunMessageID(String groupName, String exceptionName, int code) {
- return new Formatter().format("IOP%s1%04d", getExceptionID(exceptionName),
- getSunBaseNumber(groupName) + code).toString();
- }
-
- /**
- * Returns the exception ID corresponding to the given exception name.
- *
- * @param exceptionName the name of the particular exception.
- * @return the message ID.
- */
- private String getExceptionID(String exceptionName) {
- return new Formatter().format("%03d", EXCEPTIONS.indexOf(exceptionName)).toString();
- }
-
- /**
- * Entry point for running the generator from the command
- * line. Users can specify either "make-class" or "make-resource"
- * as the first argument to generate the specified type of file.
- *
- * @param args the command-line arguments.
- * @throws FileNotFoundException if the input file can not be found.
- * @throws IOException if an I/O error occurs.
- */
- public static void main(String[] args)
- throws FileNotFoundException, IOException
- {
- if (args.length < 3)
- {
- System.err.println("(make-class|make-resource) <input file> <output dir>");
- System.exit(-1);
- }
- if (args[0].equals("make-class"))
- new MC().makeClass(args[1], args[2]);
- else if (args[0].equals("make-resource"))
- new MC().makeResource(args[1], args[2]);
- else
- System.err.println("Invalid command: " + args[0]);
- }
-
-}
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/Makefile Wed Feb 05 11:04:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-#
-# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-PACKAGE=com/sun/kenc/util
-
-CLASSES=LogWrapperBase IndentingPrintWriter StringUtil
-SOURCE=$(CLASSES:%=$(PACKAGE)/%.java)
-OBJECT=$(CLASSES:%=$(PACKAGE)/%.class)
-
-MCROOTS= Activation Interceptors IOR Naming ORBUtil POA Util OMG
-MCFILES=$(MCROOTS:%=data/%.mc)
-MCSOURCE=$(MCROOTS:%=$(PACKAGE)/%SystemException.java)
-MCCLASS=$(MCROOTS:%=$(PACKAGE)/%SystemException.class)
-MCRESOURCE=$(MCROOTS:%=resources/%SystemException.resource)
-
-JARDIR=lib
-UTILJAR=$(JARDIR)/util.jar
-JSCHEMEJAR=$(JARDIR)/jscheme.jar
-JARS=$(UTILJAR):$(JSCHEMEJAR)
-
-all: mkdir jar resources classes
-
-mkdir :
- @-mkdir resources
-
-clean:
- @-rm $(OBJECT) $(MCSOURCE) $(MCOBJECT) $(MCCLASS) $(MCRESOURCE) $(UTILJAR)
-
-test:
- @echo "PACKAGE :" $(PACKAGE)
- @echo "CLASSES :" $(CLASSES)
- @echo "SOURCE :" $(SOURCE)
- @echo "OBJECT :" $(OBJECT)
- @echo "MCROOTS :" $(MCROOTS)
- @echo "MCFILES :" $(MCFILES)
- @echo "MCCLASS :" $(MCCLASS)
- @echo "MCRESOURCE :" $(MCRESOURCE)
-
-jar: $(UTILJAR)
-
-$(UTILJAR) : $(OBJECT)
- jar cvf $(JARDIR)/util.jar $(OBJECT)
-
-$(OBJECT) : $(SOURCE)
-
-classes: $(MCCLASS)
-
-$(MCCLASS) : $(MCSOURCE)
-
-$(MCSOURCE) : $(MCFILES)
-
-resources: $(MCRESOURCE)
-
-$(MCRESOURCE) : $(MCFILES)
-
-# This target does not compile, because the generated source code requires
-# com.sun.corba.se.impl.util.SUNVMCID, which would normally be built in the
-# ee package. This should not be a problem once everything is merged into the
-# workspace.
-genclasses: $(MCCLASS)
-
-$(PACKAGE)/%SystemException.java : data/%.mc
- ./mc make-class $<
- mv *SystemException.java $(PACKAGE)
-
-resources/%SystemException.resource : data/%.mc
- ./mc make-resource $<
- mv *.resource resources
-
-$(PACKAGE)/%.class : $(PACKAGE)/%.java
- javac -classpath $(JARS) $<
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/StringUtil.java Wed Feb 05 11:04:21 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.corba.se.logutil;
-
-public abstract class StringUtil {
- /** Take a string containing underscores, and return a string
- * with the underscore removed, and all characters exception in lower
- * case except the characters after the underscores.
- */
- public static String toMixedCase( String str )
- {
- StringBuffer sbuf = new StringBuffer( str.length() ) ;
- boolean uppercaseNext = false ;
- for (int ctr=0; ctr<str.length(); ctr++) {
- char ch = str.charAt( ctr ) ;
-
- if (ch == '_') {
- uppercaseNext = true ;
- } else if (uppercaseNext) {
- sbuf.append( Character.toUpperCase( ch ) ) ;
- uppercaseNext = false ;
- } else {
- sbuf.append( Character.toLowerCase( ch ) ) ;
- }
- }
-
- return sbuf.toString() ;
- }
-
- public static int countArgs( String str )
- {
- int result = 0 ;
- for( int ctr = 0; ctr<str.length(); ctr++ )
- if (str.charAt(ctr) == '{')
- result++ ;
-
- return result ;
- }
-}