This commit is contained in:
Xiaobin Lu 2009-04-09 13:59:45 -07:00
commit 87b1e69996
215 changed files with 9781 additions and 5308 deletions

View File

@ -26,3 +26,5 @@ caf58ffa084568990cbb3441f9ae188e36b31770 jdk7-b42
6b84b04a80afe23262377c60913eebfc898f14c4 jdk7-b49
5da0e6b9f4f18ef483c977337214b12ee0e1fc8f jdk7-b50
a25c5ec5e40e07733d1ff9898a0abe36159288ff jdk7-b51
7a90e89e36d103038f8667f6a7daae34ecfa1ad8 jdk7-b52
d52186ee770dac57950536cd00ccbfdef360b04c jdk7-b53

View File

@ -26,3 +26,5 @@ d7744e86dedc21a8ecf6bdb73eb191b8eaf5b0da jdk7-b47
aee93a8992d2389121eb610c00a86196f3e2b9b0 jdk7-b49
5111e13e44e542fe945b47ab154546daec36737d jdk7-b50
0f0189d55ce4a1f7840da7582ac7d970b3b7ab15 jdk7-b51
4264c2fe66493e57c411045a1b61377796641e45 jdk7-b52
c235f4a8559d196879c56af80159f67ee5d0e720 jdk7-b53

View File

@ -26,3 +26,5 @@ ccd6a16502e0650d91d85c4b86be05cbcd461a87 jdk7-b42
d70978bc64bc7a04be7797ab0dcd9b7b1b3a6bff jdk7-b49
0edbd0074b02b42b2b83cc47cb391d4869b7a8ec jdk7-b50
3eb8f1047a7402a9a79937d1c39560e931e91da2 jdk7-b51
bec82237d694f9802b820fa11bbb4f7fa9bf8e77 jdk7-b52
3c4d73194f6f89f040ae3b2d257335dfa8a1b2b5 jdk7-b53

View File

@ -46,8 +46,6 @@ CORBA_JMK_DIRECTORY=$(TOPDIR)/make/com/sun/corba/minclude/
include $(CORBA_JMK_DIRECTORY)com_sun_corba_se_PortableActivationIDL.jmk
include $(CORBA_JMK_DIRECTORY)com_sun_corba_se_impl_logging.jmk
FILES_java += com/sun/corba/se/org/omg/CORBA/ORB.java
#
# Dirs
#
@ -80,11 +78,11 @@ ORBUTIL.MC = $(SRC_DIR)/com/sun/corba/se/spi/logging/data/ORBUtil.mc
POA.MC = $(SRC_DIR)/com/sun/corba/se/spi/logging/data/POA.mc
UTIL.MC = $(SRC_DIR)/com/sun/corba/se/spi/logging/data/Util.mc
MC_GENERATE_CLASS = $(SRC_DIR)/com/sun/tools/corba/se/logutil/scripts/mc.scm -main main make-class
MC_GENERATE_LOG_RB = $(SRC_DIR)/com/sun/tools/corba/se/logutil/scripts/mc.scm -main main make-resource
MC_GENERATE_CLASS = make-class
MC_GENERATE_LOG_RB = make-resource
JSCHEME_GENERATE_CLASS = $(BOOT_JAVA_CMD) jscheme.REPL $(MC_GENERATE_CLASS)
JSCHEME_GENERATE_LOG_RB = $(BOOT_JAVA_CMD) jscheme.REPL $(MC_GENERATE_LOG_RB)
JSCHEME_GENERATE_CLASS = $(BOOT_JAVA_CMD) com.sun.tools.corba.se.logutil.MC $(MC_GENERATE_CLASS)
JSCHEME_GENERATE_LOG_RB = $(BOOT_JAVA_CMD) com.sun.tools.corba.se.logutil.MC $(MC_GENERATE_LOG_RB)
#

View File

@ -1,5 +1,5 @@
#
# Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
# Copyright 2003-2009 Sun Microsystems, Inc. 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
@ -75,15 +75,14 @@ ORBUTIL.MC = $(SRC_DIR)/com/sun/corba/se/spi/logging/data/ORBUtil.mc
POA.MC = $(SRC_DIR)/com/sun/corba/se/spi/logging/data/POA.mc
UTIL.MC = $(SRC_DIR)/com/sun/corba/se/spi/logging/data/Util.mc
MC_GENERATE_CLASS = $(SRC_DIR)/com/sun/tools/corba/se/logutil/scripts/mc.scm -main main make-class
MC_GENERATE_LOG_RB = $(SRC_DIR)/com/sun/tools/corba/se/logutil/scripts/mc.scm -main main make-resource
MC_GENERATE_CLASS = make-class
MC_GENERATE_LOG_RB = make-resource
JSCHEME_LIB_DIRECTORY=$(SRC_DIR)/com/sun/tools/corba/se/logutil/lib
JSCHEME_CLASSPATH=$(JSCHEME_LIB_DIRECTORY)/jscheme.jar$(CLASSPATH_SEPARATOR)$(JSCHEME_LIB_DIRECTORY)/jschemelogutil.jar
JSCHEME_GENERATE_CLASS = $(BOOT_JAVA_CMD) \
-cp "$(JSCHEME_CLASSPATH)" jscheme.REPL $(MC_GENERATE_CLASS)
JSCHEME_GENERATE_LOG_RB = $(BOOT_JAVA_CMD) \
-cp "$(JSCHEME_CLASSPATH)" jscheme.REPL $(MC_GENERATE_LOG_RB)
MC_CLASSPATH=$(BUILDTOOLJARDIR)/MC.jar
MCJ_GENERATE_CLASS = $(BOOT_JAVA_CMD) \
-cp "$(MC_CLASSPATH)" com.sun.tools.corba.se.logutil.MC $(MC_GENERATE_CLASS)
MCJ_GENERATE_LOG_RB = $(BOOT_JAVA_CMD) \
-cp "$(MC_CLASSPATH)" com.sun.tools.corba.se.logutil.MC $(MC_GENERATE_LOG_RB)
#
@ -104,28 +103,28 @@ $(LOG_GENDIRECTORY):
$(MKDIR) -p $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/ActivationSystemException.java : $(ACTIVATION.MC)
$(JSCHEME_GENERATE_CLASS) $(ACTIVATION.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_CLASS) $(ACTIVATION.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/IORSystemException.java : $(IOR.MC)
$(JSCHEME_GENERATE_CLASS) $(IOR.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_CLASS) $(IOR.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/InterceptorsSystemException.java : $(INTERCEPTORS.MC)
$(JSCHEME_GENERATE_CLASS) $(INTERCEPTORS.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_CLASS) $(INTERCEPTORS.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/NamingSystemException.java : $(NAMING.MC)
$(JSCHEME_GENERATE_CLASS) $(NAMING.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_CLASS) $(NAMING.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/OMGSystemException.java : $(OMG.MC)
$(JSCHEME_GENERATE_CLASS) $(OMG.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_CLASS) $(OMG.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/ORBUtilSystemException.java : $(ORBUTIL.MC)
$(JSCHEME_GENERATE_CLASS) $(ORBUTIL.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_CLASS) $(ORBUTIL.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/POASystemException.java : $(POA.MC)
$(JSCHEME_GENERATE_CLASS) $(POA.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_CLASS) $(POA.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/UtilSystemException.java : $(UTIL.MC)
$(JSCHEME_GENERATE_CLASS) $(UTIL.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_CLASS) $(UTIL.MC) $(LOG_GENDIRECTORY)
logresource.generate: $(LOG_GENDIRECTORY)/LogStrings.properties
@ -142,28 +141,28 @@ $(LOG_GENDIRECTORY)/LogStrings.properties: \
$(CAT) $(LOG_GENDIRECTORY)/*.resource > $(LOG_GENDIRECTORY)/LogStrings.properties
$(LOG_GENDIRECTORY)/ActivationSystemException.resource : $(ACTIVATION.MC)
$(JSCHEME_GENERATE_LOG_RB) $(ACTIVATION.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_LOG_RB) $(ACTIVATION.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/IORSystemException.resource : $(IOR.MC)
$(JSCHEME_GENERATE_LOG_RB) $(IOR.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_LOG_RB) $(IOR.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/InterceptorsSystemException.resource : $(INTERCEPTORS.MC)
$(JSCHEME_GENERATE_LOG_RB) $(INTERCEPTORS.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_LOG_RB) $(INTERCEPTORS.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/NamingSystemException.resource : $(NAMING.MC)
$(JSCHEME_GENERATE_LOG_RB) $(NAMING.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_LOG_RB) $(NAMING.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/OMGSystemException.resource : $(OMG.MC)
$(JSCHEME_GENERATE_LOG_RB) $(OMG.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_LOG_RB) $(OMG.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/ORBUtilSystemException.resource : $(ORBUTIL.MC)
$(JSCHEME_GENERATE_LOG_RB) $(ORBUTIL.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_LOG_RB) $(ORBUTIL.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/POASystemException.resource : $(POA.MC)
$(JSCHEME_GENERATE_LOG_RB) $(POA.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_LOG_RB) $(POA.MC) $(LOG_GENDIRECTORY)
$(LOG_GENDIRECTORY)/UtilSystemException.resource : $(UTIL.MC)
$(JSCHEME_GENERATE_LOG_RB) $(UTIL.MC) $(LOG_GENDIRECTORY)
$(MCJ_GENERATE_LOG_RB) $(UTIL.MC) $(LOG_GENDIRECTORY)
#

View File

@ -1,5 +1,5 @@
#
# Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
# Copyright 1998-2009 Sun Microsystems, Inc. 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
@ -33,6 +33,7 @@ include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = \
strip_properties \
idlj \
logutil \
all build clean clobber::
$(SUBDIRS-loop)

View File

@ -0,0 +1,43 @@
#
# Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#
# Makefile for building the idlj tool
#
BUILDDIR = ../..
PACKAGE = com.sun.tools.corba.se.logutil
PRODUCT = tools
PROGRAM = MC
include $(BUILDDIR)/common/Defs.gmk
BUILDTOOL_SOURCE_ROOT = $(SHARE_SRC)/classes
BUILDTOOL_MAIN = $(PKGDIR)/MC.java
#
# Build tool jar rules.
#
include $(BUILDDIR)/common/BuildToolJar.gmk

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2009 Sun Microsystems, Inc. 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
@ -30,7 +30,6 @@ import java.io.Writer ;
import java.io.OutputStream ;
import java.io.BufferedWriter ;
import java.io.OutputStreamWriter ;
import jsint.Pair ;
import java.util.StringTokenizer ;
public class IndentingPrintWriter extends PrintWriter {
@ -38,22 +37,20 @@ public class IndentingPrintWriter extends PrintWriter {
private int indentWidth = 4 ;
private String indentString = "" ;
public void printMsg( String msg, Pair data )
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() ;
Object head = data.first ;
Pair tail = (Pair)data.rest ;
String token = null ;
int pos = 0;
while (st.hasMoreTokens()) {
token = st.nextToken() ;
if (token.equals("@")) {
if (head != null) {
result.append( head ) ;
head = tail.first ;
tail = (Pair)tail.rest ;
if (pos < data.length) {
result.append( data[pos] );
++pos;
} else {
throw new Error( "List too short for message" ) ;
}

View File

@ -0,0 +1,211 @@
/*
* Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.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 +
"]";
}
}

View File

@ -0,0 +1,116 @@
/*
* Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.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 +
"]";
}
}

View File

@ -0,0 +1,94 @@
/*
* Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.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
+ "]";
}
}

View File

@ -0,0 +1,559 @@
/*
* Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.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]);
}
}

View File

@ -1,2 +0,0 @@
#! /bin/sh
java -cp lib/jscheme.jar:lib/util.jar jscheme.REPL mc.scm -main main $@

View File

@ -1,662 +0,0 @@
; Scheme program to produce CORBA standard exceptions class
; requires Jscheme Java extensions
; Makes use of some custom Java classes also
(import "com.sun.tools.corba.se.logutil.IndentingPrintWriter" )
(import "com.sun.tools.corba.se.logutil.StringUtil" )
(import "java.io.FileOutputStream")
(define version-string "1.3")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Utility functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; reload this file (convenience definition)
(define (reload) (load "mc.scm"))
; Simple little function to report an error
(define (error msg)
(throw (Error. msg)))
; some debug support
(define debug #f)
(define (dprint msg)
(if debug
(.println System.out$ msg)))
; Replace dprint with noprint to avoid seeing messages when debug is #t
(define (noprint msg) ())
; Helper function present so that a scheme method taking strings as args
; can be easily run from a command line.
; arg: vector containing argument strings. Element 0 is the function name
; to execute
(define (main arg)
(let*
(
(arg-list (vector->list arg))
(function-symbol (string->symbol (car arg-list)))
(args (cdr arg-list)))
(apply (eval function-symbol) args)))
; Returns the position of key in lst, numbering from 0. key is matched using eqv?
(define (get-list-position key lst)
(letrec
(
(helper (lambda (k l accum)
(cond
((null? l) (error (string-append "Could not find " k)))
((eqv? k (car l)) accum)
(else (helper k (cdr l) (+ accum 1))) ))))
(begin
(noprint (string-append "get-list-position called with key " key " lst " lst ))
(helper key lst 0))))
; Return a string representing number in decimal padded to length with leading 0s.
(define (pad-number-string number length)
(let*
(
(number-string (number->string number))
(pad-length (- length (string-length number-string)))
)
(string-append (make-string pad-length #\0) number-string)))
; Read an S-expression from a file that contains all of the data.
;
; The S-expression used for minor codes must have the structure
; (package-name class-name exception-group-name
; (exception
; (name value level explanation)
; ...
; )
; ...
; )
(define (read-file fname)
(read (open-input-file fname)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Functions for handling major system exceptions and exception groups
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Function to find the base ID given an exception group name. Result is a function that
; maps the minor code into the Java expression for that minor code's actual value.
(define (get-base group-name)
(if (eqv? group-name 'OMG)
(lambda (minor-code)
(string-append "OMGVMCID.value + " (number->string minor-code)))
(let ; bind base-number outside the lambda so it is only evaluated once
(
(base-number (get-sun-base-number group-name)))
(lambda (minor-code)
(string-append "SUNVMCID.value + " (number->string (+ base-number minor-code)))))))
; Function to get a base value for the group-name
(define (get-sun-base-number group-name)
(let*
(
(lst (list 'SUNBASE 'ORBUTIL 'ACTIVATION 'NAMING 'INTERCEPTORS 'POA 'IOR 'UTIL))
(subsystem-size 200))
(* subsystem-size (get-list-position group-name lst))))
; Function to get a 3 digit number for a system exception
(define (get-exception-id exception-name)
(let
(
(lst (list '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 )))
(pad-number-string (get-list-position exception-name lst) 3)))
; Return the message id string for any system exception
;
(define (get-message-id exception-type group-name minor)
(if (eqv? group-name 'OMG)
(get-standard-message-id exception-type minor)
(get-sun-message-id exception-type group-name minor)))
; Return the message id string for a particular standard exception
;
(define (get-standard-message-id exception-type minor)
(string-append
"IOP"
(get-exception-id exception-type)
"0"
(pad-number-string (number->string minor) 4)))
; Return the sun message id for this exception-type, group-name, and minor code.
(define (get-sun-message-id exception-type group-name minor)
(string-append
"IOP"
(get-exception-id exception-type)
"1"
(pad-number-string (+ (get-sun-base-number group-name) minor) 4)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; visitor framework for the input file format
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (visit-top obj func1)
(let*
(
(package (car obj))
(class (cadr obj))
(group (caddr obj))
(func2 (func1 package class group))
(exceptions (cadddr obj)))
(visit-exceptions exceptions func2)))
; visit the elements of an arbitrary list
; lst: the list to visit
; func: the function to apply to each element of lst
; next-level the function on lst element and func that visits the next level
(define (visit-list lst func next-level)
(if (null? (cdr lst))
(next-level #t (car lst) func)
(begin
(next-level #f (car lst) func)
(visit-list (cdr lst) func next-level))))
(define (visit-exceptions exceptions func2)
(visit-list exceptions func2 (lambda (last-flag element func) (visit-exception last-flag element func))))
(define (visit-exception last-flag exception func2)
(let*
(
(major (car exception))
(minor-codes (cdr exception))
(func3 (func2 last-flag major)))
(visit-minor-codes minor-codes func3)))
(define (visit-minor-codes minor-codes func3)
(visit-list minor-codes func3 (lambda (last-flag element func) (visit-minor-code last-flag element func))))
(define (visit-minor-code last-flag minor-code func3)
(let*
(
(name (car minor-code))
(minor (cadr minor-code))
(level (caddr minor-code))
(msg (cadddr minor-code)))
(func3 last-flag name minor level msg)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The visitors
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; A simple visitor that just echoes the input for test purposes
(define (simple-visitor package class group)
(let*
(
(pw (IndentingPrintWriter. System.out$)))
(begin
(.indent pw)
(.printMsg pw "package=@ class=@ group=@" (list package class group))
(.flush pw)
(lambda (last-flag major)
(begin
(.indent pw)
(.printMsg pw "major=@" (list major))
(.flush pw)
(lambda (last-flag name minor level message)
(begin
(if last-flag (.undent pw))
(.printMsg pw "name=@ minor=@ level=@ message=@" (list name minor level message))
(.flush pw))))))))
; Function that returns a visitor that writes out the resource file in the form:
; id="MSGID: explanation"
; outdir: Output directory
(define (resource-visitor outdir)
(lambda (package class group)
(let*
(
(file-name (string-append outdir java.io.File.separator$ class ".resource"))
(pw (IndentingPrintWriter. (FileOutputStream. file-name))))
(begin
(dprint (string-append "package= " package " class=" class " group=" group " file-name=" file-name))
(lambda (last-flag1 major)
(begin
; (dprint (string-append "last-flag1=" last-flag1 " major=" major))
(lambda (last-flag2 name minor level message)
(begin
; (dprint (string-append "last-flag2=" last-flag2 " name=" name
; " minor=" minor " level=" level " message=" message))
(let*
(
(msgid (get-message-id major group minor))
(ident (StringUtil.toMixedCase (symbol->string name))))
(begin
; (dprint (string-append "msgid=" msgid " ident=" ident))
(.printMsg pw "@.@=\"@: (@) @\"" (list group ident msgid major message))
(.flush pw)
(if (and last-flag1 last-flag2)
(begin
; (dprint "closing file")
(.close pw)))))))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Top-level functions for creating the products. All have names of the form make-xxx
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Read the minor codes from the infile and write out a resource file.
(define (make-resource infile outdir)
(tryCatch
(visit-top (read-file infile) (resource-visitor outdir))
(lambda (exc)
(begin
(.println System.out$ (string-append "make-resource failed with exception " (.toString exc)))
(System.exit 1)))))
; Read the minor codes from the infile and write a Java implementation to
; handle them to outfile under outdir
(define (make-class infile outdir)
(tryCatch
(write-class infile outdir (read-file infile))
(lambda (exc)
(begin
(.println System.out$ (string-append "make-class failed with exception " (.toString exc)))
(System.exit 1)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The original make-class implementation (this should be replaced by two visitors)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Write out the Java source code for the StandardExceptions class
; outdir: Output directory to write the generated files
; obj: the data from the input file
(define (write-class infile outdir obj)
(let*
(
(package-name (car obj))
(class-name (cadr obj))
(exception-group-name (caddr obj))
(exceptions (cadddr obj))
(file (FileOutputStream. (string-append outdir java.io.File.separator$ class-name ".java")))
(pw (IndentingPrintWriter. file))
)
(begin
(write-class-header infile package-name class-name exception-group-name pw)
(.printMsg pw "package @ ;"
(list package-name))
(.println pw)
(.println pw "import java.util.logging.Logger ;")
(.println pw "import java.util.logging.Level ;")
(.println pw)
(.println pw "import org.omg.CORBA.OMGVMCID ;")
(.println pw "import com.sun.corba.se.impl.util.SUNVMCID ;")
(.println pw "import org.omg.CORBA.CompletionStatus ;")
(.println pw "import org.omg.CORBA.SystemException ;")
(.println pw)
(.println pw "import com.sun.corba.se.spi.orb.ORB ;")
(.println pw)
(.println pw "import com.sun.corba.se.spi.logging.LogWrapperFactory;")
(.println pw)
(.println pw "import com.sun.corba.se.spi.logging.LogWrapperBase;")
(.println pw)
(write-imports exceptions pw)
(.println pw)
(.indent pw)
(.printMsg pw "public class @ extends LogWrapperBase {"
(list class-name))
(.println pw)
(.printMsg pw "public @( Logger logger )"
(list class-name))
(.indent pw)
(.println pw "{")
(.undent pw)
(.println pw "super( logger ) ;")
(.println pw "}")
(.println pw)
(.flush pw)
(write-factory-method class-name exception-group-name pw)
(write-exceptions exception-group-name exceptions (get-base exception-group-name) class-name pw)
(.undent pw)
(.println pw )
(.println pw "}")
(.flush pw)
(.close pw)
)))
; Write out the header for the resource file
(define (write-class-header infile package class group pw)
(begin
(if (eqv? group 'OMG)
(.println pw "// Log wrapper class for standard exceptions")
(.printMsg pw "// Log wrapper class for Sun private system exceptions in group @" (list group)))
(.println pw "//")
(.printMsg pw "// Generated by mc.scm version @, DO NOT EDIT BY HAND!" (list version-string))
(.printMsg pw "// Generated from input file @ on @" (list infile (java.util.Date.)))
(.println pw)))
(define (write-factory-method class-name exception-group-name pw)
(begin
(.indent pw)
(.println pw "private static LogWrapperFactory factory = new LogWrapperFactory() {")
(.println pw "public LogWrapperBase create( Logger logger )" )
(.indent pw)
(.println pw "{")
(.undent pw)
(.printMsg pw "return new @( logger ) ;" (list class-name))
(.undent pw)
(.println pw "}" )
(.println pw "} ;" )
(.println pw)
(.printMsg pw "public static @ get( ORB orb, String logDomain )" (list class-name))
(.indent pw)
(.println pw "{")
(.indent pw)
(.printMsg pw "@ wrapper = "
(list class-name))
(.indent pw)
(.printMsg pw "(@) orb.getLogWrapper( logDomain, "
(list class-name))
(.undent pw)
(.undent pw)
(.printMsg pw "\"@\", factory ) ;"
(list exception-group-name))
(.undent pw)
(.println pw "return wrapper ;" )
(.println pw "} " )
(.println pw)
(.printMsg pw "public static @ get( String logDomain )" (list class-name))
(.indent pw)
(.println pw "{")
(.indent pw)
(.printMsg pw "@ wrapper = "
(list class-name))
(.indent pw)
(.printMsg pw "(@) ORB.staticGetLogWrapper( logDomain, "
(list class-name))
(.undent pw)
(.undent pw)
(.printMsg pw "\"@\", factory ) ;"
(list exception-group-name))
(.undent pw)
(.println pw "return wrapper ;" )
(.println pw "} " )
(.println pw)))
; Write out the import list for the exceptions listed in obj
; obj: the data from the input file
; pw: an IndentingPrintWriter for the output file
(define (write-imports obj pw)
(if (null? obj)
()
(let
(
(exception (caar obj))
)
(begin
(.print pw "import org.omg.CORBA.")
(.print pw exception)
(.println pw " ;")
(write-imports (cdr obj) pw)
))))
; Write out the list of exceptions starting with the first one
; obj: the data from the input file
; base: the lambda that returns the string defining the minor code value
; pw: an IndentingPrintWriter for the output file
(define (write-exceptions group-name obj base class-name pw)
(if (null? obj)
()
(let*
(
(record (car obj))
(exception (car record))
(minor-codes (cdr record))
)
(begin
(write-exception group-name exception minor-codes base class-name pw)
(write-exceptions group-name (cdr obj) base class-name pw)
))))
; Write out a single exception
; exception: the CORBA SystemException type
; base: the base for the minor code value
; minor-codes: a list of minor code data for each minor exception type
; pw: an IndentingPrintWriter for the output file
(define (write-exception group-name exception minor-codes base class-name pw)
(begin
(.println pw "///////////////////////////////////////////////////////////")
(.printMsg pw "// @" (list exception))
(.println pw "///////////////////////////////////////////////////////////")
(.println pw)
(write-methods group-name exception minor-codes base class-name pw)
(.flush pw)))
; Write all of the methods for a single exception
; exception: the CORBA SystemException type
; base: the base for the minor code value
; minor-codes: a list of minor code data for each minor exception type
; pw: an IndentingPrintWriter for the output file
(define (write-methods group-name exception minor-codes base class-name pw)
(if (null? minor-codes)
()
(begin
(write-method group-name exception (car minor-codes) base class-name pw)
(write-methods group-name exception (cdr minor-codes) base class-name pw)
)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Code that writes out the Java methods for exception handling
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Write the methods for a single minor code within an exception
; exception: the CORBA SystemException type
; minor-code: minor code data for one minor exception type
; (name value level explanation)
; base: the base for the minor code value
; pw: an IndentingPrintWriter for the output file
(define (write-method group-name exception minor-code base class-name pw)
(let*
(
(x (symbol->string (car minor-code)))
(ident (cons x (StringUtil.toMixedCase x)))
(value (cadr minor-code))
(level (symbol->string (caddr minor-code)))
(explanation (cadddr minor-code))
(num-params (StringUtil.countArgs explanation)))
(begin
(.printMsg pw "public static final int @ = @ ;"
(list x (base value)))
(.println pw )
(.flush pw )
(write-method-status-cause group-name exception ident level num-params class-name pw)
(.println pw)
(.flush pw)
(write-method-status exception ident level num-params pw)
(.println pw)
(.flush pw)
(write-method-cause exception ident level num-params pw)
(.println pw)
(.flush pw)
(write-method-no-args exception ident level num-params pw)
(.println pw)
(.flush pw))))
; Construct a string of the form arg1, ..., argn where n is num-params
(define (make-arg-string fixed leading-comma-flag num-args)
(let
(
(helper (lambda (lcf n)
(let*
(
(numstr (number->string (- n 1))))
(if (or lcf (> n 1))
(string-append ", " fixed numstr)
(string-append " " fixed numstr))))))
(cond
((eqv? num-args 0) " ")
((eqv? num-args 1) (helper leading-comma-flag 1))
(else (string-append
(make-arg-string fixed leading-comma-flag (- num-args 1))
(helper leading-comma-flag num-args ))))))
(define (make-decl-args leading-comma-flag num-args)
(make-arg-string "Object arg" leading-comma-flag num-args))
(define (make-call-args leading-comma-flag num-args)
(make-arg-string "arg" leading-comma-flag num-args))
; make-xxx-args patterns:
; leading-comma-flag #t
;
; 0 " "
; 1 ", arg0"
; 2 ", arg0, arg1"
; 3 ", arg0, arg1, arg2"
;
; 0 " "
; 1 ", Object arg0"
; 2 ", Object arg0, Object arg1"
; 3 ", Object arg0, Object arg1, Object arg2"
;
; leading-comma-flag #f
;
; 0 " "
; 1 " arg0"
; 2 " arg0, arg1"
; 3 " arg0, arg1, arg2"
;
; 0 " "
; 1 " Object arg0"
; 2 " Object arg0, Object arg1"
; 3 " Object arg0, Object arg1, Object arg2"
(define (emit-assignments num pw)
(let
(
(helper
(lambda (n)
(.printMsg pw "parameters[@] = arg@ ;" (list n n)))))
(if (= num 1)
(helper (- num 1))
(begin
(emit-assignments (- num 1) pw)
(helper (- num 1))))))
; Write a method for an exception that takes a CompletionStatus and a cause
; exception: the CORBA system exception type
; id: the identifier for this exception in the form ( ident . mixed-case-ident )
; level: the logging level
; num-params: number of parameters in the explanation string, which determines
; how many argn parameters we need
; pw: the indenting print writer we are using
(define (write-method-status-cause group-name exception id level num-params class-name pw)
(let*
(
(ident (car id))
(ident-mc (cdr id)))
(begin
(.indent pw)
(.printMsg pw "public @ @( CompletionStatus cs, Throwable t@) {"
(list exception ident-mc (make-decl-args #t num-params)))
(.printMsg pw "@ exc = new @( @, cs ) ;"
(list exception exception ident ))
(.indent pw)
(.println pw "if (t != null)" )
(.undent pw)
(.println pw "exc.initCause( t ) ;" )
(.println pw)
(.indent pw)
(.printMsg pw "if (logger.isLoggable( Level.@ )) {"
(list level))
(if (> num-params 0)
(begin
(.printMsg pw "Object[] parameters = new Object[@] ;"
(list (number->string num-params)))
(emit-assignments num-params pw)
)
(begin
(.println pw "Object[] parameters = null ;"
)))
(.indent pw)
(.printMsg pw "doLog( Level.@, \"@.@\"," (list level group-name ident-mc))
(.undent pw)
(.undent pw)
(.printMsg pw "parameters, @.class, exc ) ;" (list class-name))
(.println pw "}")
(.println pw)
(.undent pw)
(.println pw "return exc ;")
(.println pw "}"))))
; Write a method for an exception that takes a CompletionStatus. The cause is null.
;
; exception: the CORBA system exception type
; id: the identifier for this exception in the form ( ident . mixed-case-ident )
; level: the logging level
; num-params: number of parameters in the explanation string, which determines
; how many argn parameters we need
; pw: the indenting print writer we are using
(define (write-method-status exception id level num-params pw)
(let*
(
(ident-mc (cdr id)))
(begin
(.indent pw)
(.printMsg pw "public @ @( CompletionStatus cs@) {"
(list exception ident-mc (make-decl-args #t num-params)))
(.undent pw)
(.printMsg pw "return @( cs, null@ ) ;"
(list ident-mc (make-call-args #t num-params)))
(.println pw "}"))))
; Write a method for an exception that takes a cause. The status is COMPLETED_NO.
;
; exception: the CORBA system exception type
; id: the identifier for this exception in the form ( ident . mixed-case-ident )
; level: the logging level
; num-params: number of parameters in the explanation string, which determines
; how many argn parameters we need
; pw: the indenting print writer we are using
(define (write-method-cause exception id level num-params pw)
(let*
(
(ident-mc (cdr id)))
(begin
(.indent pw)
(.printMsg pw "public @ @( Throwable t@) {"
(list exception ident-mc (make-decl-args #t num-params)))
(.undent pw)
(.printMsg pw "return @( CompletionStatus.COMPLETED_NO, t@ ) ;"
(list ident-mc (make-call-args #t num-params)))
(.println pw "}"))))
; Write a method for an exception that takes no arguments. This is COMPLETED_NO and
; a null cause.
;
; exception: the CORBA system exception type
; id: the identifier for this exception in the form ( ident . mixed-case-ident )
; level: the logging level
; num-params: number of parameters in the explanation string, which determines
; how many argn parameters we need
; pw: the indenting print writer we are using
(define (write-method-no-args exception id level num-params pw)
(let*
(
(ident-mc (cdr id)))
(begin
(.indent pw)
(.printMsg pw "public @ @( @) {"
(list exception ident-mc (make-decl-args #f num-params)))
(.undent pw)
(.printMsg pw "return @( CompletionStatus.COMPLETED_NO, null@ ) ;"
(list ident-mc (make-call-args #t num-params)))
(.println pw "}"))))
;;; end of file

View File

@ -1,2 +0,0 @@
#! /bin/sh
java -cp ${CLASSPATH}:lib/jscheme.jar:lib/util.jar jscheme.REPL mc.scm

View File

@ -26,3 +26,5 @@ bcb33806d186561c781992e5f4d8a90bb033f9f0 jdk7-b48
8b22ccb5aba2c6c11bddf6488a7bb7ef5b4bf2be jdk7-b49
dae503d9f04c1a11e182dbf7f770509c28dc0609 jdk7-b50
2581d90c6c9b2012da930eb4742add94a03069a0 jdk7-b51
1b1e8f1a4fe8cebc01c022484f78148e17b62a0d jdk7-b52
032c6af894dae8d939b3dd31d82042549e7793e0 jdk7-b53

View File

@ -31,11 +31,11 @@
#
# Don't put quotes (fail windows build).
HOTSPOT_VM_COPYRIGHT=Copyright 2008
HOTSPOT_VM_COPYRIGHT=Copyright 2009
HS_MAJOR_VER=15
HS_MAJOR_VER=16
HS_MINOR_VER=0
HS_BUILD_NUMBER=04
HS_BUILD_NUMBER=01
JDK_MAJOR_VER=1
JDK_MINOR_VER=7

View File

@ -26,3 +26,5 @@ d711ad1954b294957737ea386cfd4d3c05028a36 jdk7-b47
5c1f24531903573c1830775432276da567243f9c jdk7-b49
e8514e2be76d90889ebdb90d627aca2db5c150c6 jdk7-b50
ae890d80d5dffcd4dc77a1f17d768e192d1852c7 jdk7-b51
69ad87dc25cbcaaaded4727199395ad0c78bc427 jdk7-b52
e8837366d3fd72f7c7a47ebfdbd5106c16156f12 jdk7-b53

View File

@ -1,241 +0,0 @@
#!echo "This is not a shell script"
#############################################################################
#
# Copyright 2006 Sun Microsystems, Inc. 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. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#############################################################################
#
# JPRT shell configuration for building.
#
# Input environment variables:
# ALT_BOOTDIR
# ALT_SLASH_JAVA
# ALT_JDK_IMPORT_PATH
# Windows Only:
# PATH
# PROCESSOR_IDENTIFIER
# ROOTDIR
#
# Output variable settings:
# make Full path to GNU make
#
# Output environment variables:
# PATH
# Windows Only:
# ALT_DEVTOOLS_PATH (To avoid the C:/UTILS default)
#
# After JDK6, most settings will be found via ALT_SLASH_JAVA or
# by way of other system environment variables. If this was JDK5
# or an older JDK, you might need to export more ALT_* variables.
#
#############################################################################
#############################################################################
# Error
error() # message
{
echo "ERROR: $1"
exit 6
}
# Directory must exist
dirMustExist() # dir name
{
if [ ! -d "$1" ] ; then
error "Directory for $2 does not exist: $1"
fi
}
# File must exist
fileMustExist() # dir name
{
if [ ! -f "$1" ] ; then
error "File for $2 does not exist: $1"
fi
}
#############################################################################
# Should be set by JPRT as the 3 basic inputs
bootdir="${ALT_BOOTDIR}"
slashjava="${ALT_SLASH_JAVA}"
jdk_import="${ALT_JDK_IMPORT_PATH}"
# Check input
dirMustExist "${bootdir}" ALT_BOOTDIR
dirMustExist "${slashjava}" ALT_SLASH_JAVA
dirMustExist "${jdk_import}" ALT_JDK_IMPORT_PATH
# Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
osname=`uname -s`
if [ "${osname}" = SunOS ] ; then
# SOLARIS: Sparc or X86
osarch=`uname -p`
if [ "${osarch}" = sparc ] ; then
solaris_arch=sparc
else
solaris_arch=i386
fi
# Add basic solaris system paths
path4sdk=/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin
# Get the previous JDK to be used to bootstrap the build
path4sdk=${bootdir}/bin:${path4sdk}
# Ant
ANT_HOME=${slashjava}/devtools/share/ant/1.7.0
export ANT_HOME
antbindir=${ANT_HOME}/bin
fileMustExist "${antbindir}/ant" ant
path4sdk=${antbindir}:${path4sdk}
# Find GNU make
make=/usr/sfw/bin/gmake
if [ ! -f ${make} ] ; then
make=/opt/sfw/bin/gmake
if [ ! -f ${make} ] ; then
make=${slashjava}/devtools/${solaris_arch}/bin/gnumake
fi
fi
fileMustExist "${make}" make
# File creation mask
umask 002
elif [ "${osname}" = Linux ] ; then
# LINUX: X86, AMD64
osarch=`uname -m`
if [ "${osarch}" = i686 ] ; then
linux_arch=i586
elif [ "${osarch}" = x86_64 ] ; then
linux_arch=amd64
fi
# Add basic paths
path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
# Get the previous JDK to be used to bootstrap the build
path4sdk=${bootdir}/bin:${path4sdk}
# Ant
ANT_HOME=${slashjava}/devtools/share/ant/1.7.0
export ANT_HOME
antbindir=${ANT_HOME}/bin
fileMustExist "${antbindir}/ant" ant
path4sdk=${antbindir}:${path4sdk}
# Find GNU make
make=/usr/bin/make
fileMustExist "${make}" make
umask 002
else
# Windows: Differs on CYGWIN vs. MKS.
# Also, blanks in pathnames gives GNU make headaches, so anything placed
# in any ALT_* variable should be the short windows dosname.
# WINDOWS: Install and use MKS or CYGWIN (should have already been done)
# Assumption here is that you are in a shell window via MKS or cygwin.
# MKS install should have defined the environment variable ROOTDIR.
# We also need to figure out which one we have: X86, AMD64
if [ "`echo ${PROCESSOR_IDENTIFIER} | fgrep AMD64`" != "" ] ; then
windows_arch=amd64
else
windows_arch=i586
fi
# We need to determine if we are running a CYGWIN shell or an MKS shell
# (if uname isn't available, then it will be unix_toolset=unknown)
unix_toolset=unknown
if [ "`uname -a | fgrep Cygwin`" = "" -a -d "${ROOTDIR}" ] ; then
# We kind of assume ROOTDIR is where MKS is and it's ok
unix_toolset=MKS
mkshome=`dosname -s "${ROOTDIR}"`
# Utility to convert to short pathnames without spaces
dosname="${mkshome}/mksnt/dosname -s"
# Most unix utilities are in the mksnt directory of ROOTDIR
unixcommand_path="${mkshome}/mksnt"
path4sdk="${unixcommand_path}"
dirMustExist "${unixcommand_path}" ALT_UNIXCOMMAND_PATH
devtools_path="${slashjava}/devtools/win32/bin"
path4sdk="${devtools_path};${path4sdk}"
# Normally this need not be set, but on Windows it's default is C:/UTILS
ALT_DEVTOOLS_PATH="${devtools_path}"
export ALT_DEVTOOLS_PATH
dirMustExist "${devtools_path}" ALT_DEVTOOLS_PATH
# Find GNU make
make="${devtools_path}/gnumake.exe"
fileMustExist "${make}" make
elif [ "`uname -a | fgrep Cygwin`" != "" -a -f /bin/cygpath ] ; then
# For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
unix_toolset=CYGWIN
# Utility to convert to short pathnames without spaces
dosname="/usr/bin/cygpath -a -m -s"
# Most unix utilities are in the /usr/bin
unixcommand_path="/usr/bin"
path4sdk="${unixcommand_path}"
dirMustExist "${unixcommand_path}" ALT_UNIXCOMMAND_PATH
# Find GNU make
make="${unixcommand_path}/make.exe"
fileMustExist "${make}" make
else
echo "WARNING: Cannot figure out if this is MKS or CYGWIN"
fi
# WINDOWS: Get the previous JDK to be used to bootstrap the build
path4sdk="${bootdir}/bin;${path4sdk}"
# Ant
ANT_HOME=${slashjava}/devtools/share/ant/1.7.0
export ANT_HOME
antbindir=${ANT_HOME}/bin
fileMustExist "${antbindir}/ant" ant
path4sdk="${antbindir};${path4sdk}"
# Turn all \\ into /, remove duplicates and trailing /
slash_path="`echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g'`"
# For windows, it's hard to know where the system is, so we just add this
# to PATH.
path4sdk="${slash_path};${PATH}"
# Convert path4sdk to cygwin style
if [ "${unix_toolset}" = CYGWIN ] ; then
path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
fi
fi
# Export PATH setting
PATH="${path4sdk}"
export PATH
# Things we need to unset
unset LD_LIBRARY_PATH
unset LD_LIBRARY_PATH_32
unset LD_LIBRARY_PATH_64
unset JAVA_HOME

View File

@ -26,3 +26,5 @@ af4a3eeb7812a5d09a241c50b51b3c648a9d45c1 jdk7-b46
18ca864890f3d4ed942ecbffb78c936a57759921 jdk7-b49
5be52db581f1ea91ab6e0eb34ba7f439125bfb16 jdk7-b50
41a66a42791ba90bff489af72cbfea71be9b40a5 jdk7-b51
e646890d18b770f625f14ed4ad5c50554d8d3d8b jdk7-b52
b250218eb2e534384667ec73e3713e684667fd4c jdk7-b53

View File

@ -1,241 +0,0 @@
#!echo "This is not a shell script"
#############################################################################
#
# Copyright 2006 Sun Microsystems, Inc. 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. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#############################################################################
#
# JPRT shell configuration for building.
#
# Input environment variables:
# ALT_BOOTDIR
# ALT_SLASH_JAVA
# ALT_JDK_IMPORT_PATH
# Windows Only:
# PATH
# PROCESSOR_IDENTIFIER
# ROOTDIR
#
# Output variable settings:
# make Full path to GNU make
#
# Output environment variables:
# PATH
# Windows Only:
# ALT_DEVTOOLS_PATH (To avoid the C:/UTILS default)
#
# After JDK6, most settings will be found via ALT_SLASH_JAVA or
# by way of other system environment variables. If this was JDK5
# or an older JDK, you might need to export more ALT_* variables.
#
#############################################################################
#############################################################################
# Error
error() # message
{
echo "ERROR: $1"
exit 6
}
# Directory must exist
dirMustExist() # dir name
{
if [ ! -d "$1" ] ; then
error "Directory for $2 does not exist: $1"
fi
}
# File must exist
fileMustExist() # dir name
{
if [ ! -f "$1" ] ; then
error "File for $2 does not exist: $1"
fi
}
#############################################################################
# Should be set by JPRT as the 3 basic inputs
bootdir="${ALT_BOOTDIR}"
slashjava="${ALT_SLASH_JAVA}"
jdk_import="${ALT_JDK_IMPORT_PATH}"
# Check input
dirMustExist "${bootdir}" ALT_BOOTDIR
dirMustExist "${slashjava}" ALT_SLASH_JAVA
dirMustExist "${jdk_import}" ALT_JDK_IMPORT_PATH
# Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
osname=`uname -s`
if [ "${osname}" = SunOS ] ; then
# SOLARIS: Sparc or X86
osarch=`uname -p`
if [ "${osarch}" = sparc ] ; then
solaris_arch=sparc
else
solaris_arch=i386
fi
# Add basic solaris system paths
path4sdk=/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin
# Get the previous JDK to be used to bootstrap the build
path4sdk=${bootdir}/bin:${path4sdk}
# Ant
ANT_HOME=${slashjava}/devtools/share/ant/1.7.0
export ANT_HOME
antbindir=${ANT_HOME}/bin
fileMustExist "${antbindir}/ant" ant
path4sdk=${antbindir}:${path4sdk}
# Find GNU make
make=/usr/sfw/bin/gmake
if [ ! -f ${make} ] ; then
make=/opt/sfw/bin/gmake
if [ ! -f ${make} ] ; then
make=${slashjava}/devtools/${solaris_arch}/bin/gnumake
fi
fi
fileMustExist "${make}" make
# File creation mask
umask 002
elif [ "${osname}" = Linux ] ; then
# LINUX: X86, AMD64
osarch=`uname -m`
if [ "${osarch}" = i686 ] ; then
linux_arch=i586
elif [ "${osarch}" = x86_64 ] ; then
linux_arch=amd64
fi
# Add basic paths
path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
# Get the previous JDK to be used to bootstrap the build
path4sdk=${bootdir}/bin:${path4sdk}
# Ant
ANT_HOME=${slashjava}/devtools/share/ant/1.7.0
export ANT_HOME
antbindir=${ANT_HOME}/bin
fileMustExist "${antbindir}/ant" ant
path4sdk=${antbindir}:${path4sdk}
# Find GNU make
make=/usr/bin/make
fileMustExist "${make}" make
umask 002
else
# Windows: Differs on CYGWIN vs. MKS.
# Also, blanks in pathnames gives GNU make headaches, so anything placed
# in any ALT_* variable should be the short windows dosname.
# WINDOWS: Install and use MKS or CYGWIN (should have already been done)
# Assumption here is that you are in a shell window via MKS or cygwin.
# MKS install should have defined the environment variable ROOTDIR.
# We also need to figure out which one we have: X86, AMD64
if [ "`echo ${PROCESSOR_IDENTIFIER} | fgrep AMD64`" != "" ] ; then
windows_arch=amd64
else
windows_arch=i586
fi
# We need to determine if we are running a CYGWIN shell or an MKS shell
# (if uname isn't available, then it will be unix_toolset=unknown)
unix_toolset=unknown
if [ "`uname -a | fgrep Cygwin`" = "" -a -d "${ROOTDIR}" ] ; then
# We kind of assume ROOTDIR is where MKS is and it's ok
unix_toolset=MKS
mkshome=`dosname -s "${ROOTDIR}"`
# Utility to convert to short pathnames without spaces
dosname="${mkshome}/mksnt/dosname -s"
# Most unix utilities are in the mksnt directory of ROOTDIR
unixcommand_path="${mkshome}/mksnt"
path4sdk="${unixcommand_path}"
dirMustExist "${unixcommand_path}" ALT_UNIXCOMMAND_PATH
devtools_path="${slashjava}/devtools/win32/bin"
path4sdk="${devtools_path};${path4sdk}"
# Normally this need not be set, but on Windows it's default is C:/UTILS
ALT_DEVTOOLS_PATH="${devtools_path}"
export ALT_DEVTOOLS_PATH
dirMustExist "${devtools_path}" ALT_DEVTOOLS_PATH
# Find GNU make
make="${devtools_path}/gnumake.exe"
fileMustExist "${make}" make
elif [ "`uname -a | fgrep Cygwin`" != "" -a -f /bin/cygpath ] ; then
# For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
unix_toolset=CYGWIN
# Utility to convert to short pathnames without spaces
dosname="/usr/bin/cygpath -a -m -s"
# Most unix utilities are in the /usr/bin
unixcommand_path="/usr/bin"
path4sdk="${unixcommand_path}"
dirMustExist "${unixcommand_path}" ALT_UNIXCOMMAND_PATH
# Find GNU make
make="${unixcommand_path}/make.exe"
fileMustExist "${make}" make
else
echo "WARNING: Cannot figure out if this is MKS or CYGWIN"
fi
# WINDOWS: Get the previous JDK to be used to bootstrap the build
path4sdk="${bootdir}/bin;${path4sdk}"
# Ant
ANT_HOME=${slashjava}/devtools/share/ant/1.7.0
export ANT_HOME
antbindir=${ANT_HOME}/bin
fileMustExist "${antbindir}/ant" ant
path4sdk="${antbindir};${path4sdk}"
# Turn all \\ into /, remove duplicates and trailing /
slash_path="`echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g'`"
# For windows, it's hard to know where the system is, so we just add this
# to PATH.
path4sdk="${slash_path};${PATH}"
# Convert path4sdk to cygwin style
if [ "${unix_toolset}" = CYGWIN ] ; then
path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
fi
fi
# Export PATH setting
PATH="${path4sdk}"
export PATH
# Things we need to unset
unset LD_LIBRARY_PATH
unset LD_LIBRARY_PATH_32
unset LD_LIBRARY_PATH_64
unset JAVA_HOME

View File

@ -26,3 +26,5 @@ b4ac413b1f129eeef0acab3f31081c1b7dfe3b27 jdk7-b47
8311105ea7a3db7bcbcb2b696459127c7f2297a4 jdk7-b49
58ba2cd5a25053684ec53205d95edeeaa0006f13 jdk7-b50
fea0898259ae41c73620b1815aa48f036216155c jdk7-b51
bcbeadb4a5d759b29e876ee2c83401e91ff22f60 jdk7-b52
a2033addca678f9e4c0d92ffa1e389171cc9321d jdk7-b53

View File

@ -61,6 +61,28 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
%% This notice is provided with respect to littlecms, which may be included with this software:
Little cms
Copyright (C) 1998-2004 Marti Maria
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
%% This notice is provided with respect to zlib 1.1.3, which may be included with this software:
Acknowledgments:
@ -115,16 +137,6 @@ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQ
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
____________________________________
This formulation of W3C's notice and license became active on August 14 1998 so as to improve compatibility with GPL. This version ensures that W3C software licensing terms are no more restrictive than GPL and consequently W3C software may be distributed in GPL packages. See the older formulation for the policy prior to this date. Please see our Copyright FAQ for common questions about using materials from our site, including specific terms and conditions for packages like libwww, Amaya, and Jigsaw. Other questions about this notice can be directed to site-policy@w3.org.
 
%% This notice is provided with respect to jscheme.jar, which may be included with this software:
Software License Agreement
Copyright © 1998-2002 by Peter Norvig.
Permission is granted to anyone to use this software, in source or object code form, on any computer system, and to modify, compile, decompile, run, and redistribute it to anyone else, subject to the following restrictions:
1.The author makes no warranty of any kind, either expressed or implied, about the suitability of this software for any purpose.
2.The author accepts no liability of any kind for damages or other consequences of the use of this software, even if they arise from defects in the software.
3.The origin of this software must not be misrepresented, either by explicit claim or by omission.
4.Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. Altered versions may be distributed in packages under other licenses (such as the GNU license).
If you find this software useful, it would be nice if you let me (peter@norvig.com) know about it, and nicer still if you send me modifications that you are willing to share. However, you are not required to do so.
%% This notice is provided with respect to PC/SC Lite for Suse Linux v. 1.1.1, which may be included with this software:

View File

@ -41,7 +41,15 @@ include $(BUILDDIR)/common/Defs.gmk
# Note : some targets are double colon rules and some single colon rules
# within common included gmk files : that is why the following for loop
# has been duplicated.
SUBDIRS = snmp
# When building the openjdk, build snmp only if importing binary plugs,
ifdef OPENJDK
ifeq ($(IMPORT_BINARY_PLUGS),true)
SUBDIRS = snmp
endif
else
SUBDIRS = snmp
endif
all build:
$(SUBDIRS-loop)

View File

@ -94,6 +94,9 @@ ifndef OPTIMIZATION_LEVEL
OPTIMIZATION_LEVEL = LOWER
endif
endif
ifndef FASTDEBUG_OPTIMIZATION_LEVEL
FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
endif
CC_OPT/NONE =
CC_OPT/LOWER = -O2
@ -173,8 +176,8 @@ CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
# FASTDEBUG: Optimize the code in the -g versions, gives us a faster debug java
ifeq ($(FASTDEBUG), true)
CFLAGS_DBG += $(CC_OPT/LOWER)
CXXFLAGS_DBG += $(CC_OPT/LOWER)
CFLAGS_DBG += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
CXXFLAGS_DBG += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
endif
CPPFLAGS_COMMON = -D$(ARCH) -DARCH='"$(ARCH)"' -DLINUX $(VERSION_DEFINES) \

View File

@ -93,6 +93,9 @@ ifndef OPTIMIZATION_LEVEL
OPTIMIZATION_LEVEL = LOWER
endif
endif
ifndef FASTDEBUG_OPTIMIZATION_LEVEL
FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
endif
#
# If -Xa is in CFLAGS_COMMON it will end up ahead of $(CC_OPT) for the
@ -143,8 +146,8 @@ endif
# Performance/size of files should be about the same, maybe smaller.
#
ifeq ($(FASTDEBUG), true)
CFLAGS_DEBUG_OPTION = -g $(CC_OPT/LOWER)
CXXFLAGS_DEBUG_OPTION = -g0 $(CXX_OPT/LOWER)
CFLAGS_DEBUG_OPTION = -g $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
CXXFLAGS_DEBUG_OPTION = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
endif
CFLAGS_COMMON = -L$(OBJDIR)

View File

@ -111,6 +111,9 @@ ifndef OPTIMIZATION_LEVEL
OPTIMIZATION_LEVEL = LOWER
endif
endif
ifndef FASTDEBUG_OPTIMIZATION_LEVEL
FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
endif
ifeq ($(CC_VERSION),msvc)
# Visual Studio .NET 2003 or VS2003 compiler option definitions:

View File

@ -145,6 +145,11 @@ endif
# 2. ALT_BINARY_PLUGS_PATH overrides all locations of classes and libraries
# 3. ALT_BUILD_BINARY_PLUGS_PATH is used to find a ALT_BINARY_PLUGS_PATH
# 4. ALT_CLOSED_JDK_IMPORT_PATH is used to locate classes and libraries
# Note: If any of the ALT_ variables are modified here, it is assumed
# that the build should be done with IMPORT_BINARY_PLUGS=true as
# well. Otherwise the default will be IMPORT_BINARY_PLUGS=false.
# Lastly, setting IMPORT_BINARY_PLUGS=false on the command line
# will override this logic, and plugs will not be imported.
#
# Always needed, defines the name of the imported/exported jarfile
@ -155,9 +160,11 @@ ifdef OPENJDK
CLOSED_JDK_IMPORT_PATH = $(ALT_CLOSED_JDK_IMPORT_PATH)
BINARY_PLUGS_PATH = $(CLOSED_JDK_IMPORT_PATH)
BINARY_PLUGS_JARFILE = $(CLOSED_JDK_IMPORT_PATH)/jre/lib/rt.jar
IMPORT_BINARY_PLUGS=true
endif
ifdef ALT_BUILD_BINARY_PLUGS_PATH
BUILD_BINARY_PLUGS_PATH = $(ALT_BUILD_BINARY_PLUGS_PATH)
IMPORT_BINARY_PLUGS=true
else
BUILD_BINARY_PLUGS_PATH = $(SLASH_JAVA)/re/jdk/$(JDK_VERSION)/promoted/latest/openjdk/binaryplugs
endif
@ -166,9 +173,11 @@ ifdef OPENJDK
ifdef ALT_BINARY_PLUGS_PATH
BINARY_PLUGS_PATH = $(ALT_BINARY_PLUGS_PATH)
BINARY_PLUGS_JARFILE = $(BINARY_PLUGS_PATH)/jre/lib/$(BINARY_PLUGS_JARNAME)
IMPORT_BINARY_PLUGS=true
endif
ifdef ALT_BINARY_PLUGS_JARFILE
BINARY_PLUGS_JARFILE = $(ALT_BINARY_PLUGS_JARFILE)
IMPORT_BINARY_PLUGS=true
endif
endif # OPENJDK

View File

@ -59,7 +59,15 @@ else
ADD_CLIENT_VM_OPTION = true
endif
endif
JAVA_JVM_FLAGS =
# Options for hotspot to turn off printing of options with fastdebug version
# and creating the hotspot.log file.
JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS = \
-XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput
# JVM options
JAVA_JVM_FLAGS = $(JAVA_HOTSPOT_DISABLE_PRINT_VMOPTIONS)
ifeq ($(ADD_CLIENT_VM_OPTION), true)
JAVA_JVM_FLAGS += -client
endif

View File

@ -229,11 +229,19 @@ ifeq ($(PLATFORM), windows)
TEMP_DISK=C:/temp
# GNU Make or MKS overrides $(PROCESSOR_ARCHITECTURE) to always
# return "x86". Use the first word of $(PROCESSOR_IDENTIFIER) instead.
PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
PROC_ARCH:=$(subst x86,X86,$(PROC_ARCH))
PROC_ARCH:=$(subst Intel64,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst em64t,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst EM64T,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst amd64,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst AMD64,X64,$(PROC_ARCH))
PROC_ARCH:=$(subst ia64,IA64,$(PROC_ARCH))
ifndef ARCH_DATA_MODEL
ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
ifeq ($(PROC_ARCH),IA64)
ARCH_DATA_MODEL=64
else
ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64)
ifeq ($(PROC_ARCH),X64)
ARCH_DATA_MODEL=64
else
ARCH_DATA_MODEL=32
@ -245,10 +253,12 @@ ifeq ($(PLATFORM), windows)
# If the user wants to perform a cross compile build then they must
# - set ARCH_DATA_MODEL=64 and either
# + set ARCH to ia64 or amd64, or
ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)), AMD64)
ifeq ($(PROC_ARCH),X64)
ARCH=amd64
else
ARCH=ia64
ifeq ($(PROC_ARCH),IA64)
ARCH=ia64
endif
endif
LIBARCH=$(ARCH)
# Value of Java os.arch property

View File

@ -245,6 +245,7 @@ ifdef OPENJDK
ALL_SETTINGS+=$(call addAltSetting,FREETYPE_HEADERS_PATH)
ALL_SETTINGS+=$(call addAltSetting,FREETYPE_LIB_PATH)
ALL_SETTINGS+=$(call addHeading,OPENJDK Import Binary Plug Settings)
ALL_SETTINGS+=$(call addOptionalSetting,IMPORT_BINARY_PLUGS)
ALL_SETTINGS+=$(call addAltSetting,BINARY_PLUGS_JARFILE)
ALL_SETTINGS+=$(call addAltSetting,BINARY_PLUGS_PATH)
ALL_SETTINGS+=$(call addAltSetting,BUILD_BINARY_PLUGS_PATH)

View File

@ -502,13 +502,15 @@ endif
######################################################
ifdef OPENJDK
sane-binary-plugs:
ifeq ($(IMPORT_BINARY_PLUGS),true)
@if [ ! -d "$(BINARY_PLUGS_PATH)" ]; then \
$(ECHO) "ERROR: Can't locate pre-built libraries. \n" \
$(ECHO) "WARNING: Can't locate pre-built libraries. \n" \
" Please check your access to \n" \
" $(BINARY_PLUGS_PATH) \n" \
" and/or check your value of ALT_BINARY_PLUGS_PATH. \n" \
"" >> $(ERROR_FILE); \
"" >> $(WARNING_FILE); \
fi
endif
endif
######################################################

View File

@ -1,5 +1,5 @@
#
# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
# Copyright 1997-2009 Sun Microsystems, Inc. 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
@ -204,6 +204,9 @@ JDI_DOCTITLE = "Java$(TRADEMARK) Debug Interface"
JDI_HEADER = "Java Debug Interface"
# JDI_PKGS is located in NON_CORE_PKGS.gmk
# Variables used by security components
SECURITYAPI_JAVADOCBOTTOM = '<font size="-1"><a href="http://bugs.sun.com/services/bugreport/index.jsp">Report a bug or request a feature.</a><br>Copyright $(THIS_YEAR) Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.</font>'
#
# Variables used by JAAS target
#
@ -221,6 +224,7 @@ JAAS_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \
-windowtitle $(JAAS_WINDOWTITLE) \
-doctitle $(JAAS_DOCTITLE) \
-header $(JAAS_JAVADOCHEADER) \
-bottom $(SECURITYAPI_JAVADOCBOTTOM) \
-linkoffline ../../../../../api $(DOCSDIR)/api/ \
-overview $(TOPDIR)/src/share/classes/com/sun/security/auth/jaas-overview.html
JAAS_WINDOWTITLE = "Java Authentication and Authorization Service "
@ -243,6 +247,7 @@ JGSS_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \
-windowtitle $(JGSS_WINDOWTITLE) \
-doctitle $(JGSS_DOCTITLE) \
-header $(JGSS_JAVADOCHEADER) \
-bottom $(SECURITYAPI_JAVADOCBOTTOM) \
-linkoffline ../../../../../api $(DOCSDIR)/api/ \
-overview $(JGSS_SOURCEPATH)/com/sun/security/jgss/jgss-overview.html
@ -266,6 +271,7 @@ SMARTCARDIO_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \
-windowtitle $(SMARTCARDIO_WINDOWTITLE) \
-doctitle $(SMARTCARDIO_DOCTITLE) \
-header $(SMARTCARDIO_JAVADOCHEADER) \
-bottom $(SECURITYAPI_JAVADOCBOTTOM) \
-linkoffline ../../../../../api $(DOCSDIR)/api/
SMARTCARDIO_WINDOWTITLE = "Java Smart Card I/O"

View File

@ -45,6 +45,7 @@ FDLIBM_SRC = $(SHARE_SRC)/native/java/lang/fdlibm
ifeq ($(PLATFORM),windows)
# Turn all optimizations off
OPTIMIZATION_LEVEL = NONE
FASTDEBUG_OPTIMIZATION_LEVEL = NONE
OTHER_CFLAGS =
CPPFLAGS_DBG += -DLOGGING
endif
@ -56,6 +57,7 @@ endif
ifeq ($(PLATFORM),linux)
# Turn all optimizations off
OPTIMIZATION_LEVEL = NONE
FASTDEBUG_OPTIMIZATION_LEVEL = NONE
endif
#

View File

@ -449,7 +449,6 @@ JAVA_JAVA_java = \
sun/misc/Service.java \
sun/misc/JavaLangAccess.java \
sun/misc/JavaIOAccess.java \
sun/misc/JavaIODeleteOnExitAccess.java \
sun/misc/JavaIOFileDescriptorAccess.java \
sun/misc/JavaNioAccess.java

View File

@ -46,6 +46,8 @@ include $(BUILDDIR)/common/Mapfile-vers.gmk
#
include FILES_c.gmk
# We don't need snmp here.
AUTO_JAVA_PRUNE = snmp
AUTO_FILES_JAVA_DIRS = java/lang/management com/sun/management sun/management
include Exportedfiles.gmk

View File

@ -220,6 +220,8 @@ FILES_src = \
sun/nio/ch/Util.java \
\
sun/nio/cs/AbstractCharsetProvider.java \
sun/nio/cs/ArrayDecoder.java \
sun/nio/cs/ArrayEncoder.java \
sun/nio/cs/FastCharsetProvider.java \
sun/nio/cs/HistoricallyNamedCharset.java \
sun/nio/cs/ISO_8859_1.java \

View File

@ -251,9 +251,11 @@ endif # INCLUDE_SA
#
ifdef OPENJDK
include $(BUILDDIR)/common/internal/BinaryPlugs.gmk
ifeq ($(IMPORT_BINARY_PLUGS),true)
include $(BUILDDIR)/common/internal/BinaryPlugs.gmk
build: import-binary-plugs
build: import-binary-plugs
endif
else # !OPENJDK

View File

@ -35,6 +35,7 @@ include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_JAVA_PRUNE = snmp
AUTO_FILES_JAVA_DIRS = javax/management com/sun/jmx com/sun/management/jmx
#

View File

@ -174,7 +174,8 @@ else
# Check CYGWIN (should have already been done)
# Assumption here is that you are in a shell window via cygwin.
if [ "$(echo ${PROCESSOR_IDENTIFIER} | fgrep AMD64)" != "" ] ; then
proc_arch=`echo "$(PROCESSOR_IDENTIFIER)" | expand | cut -d' ' -f1 | sed -e 's@x86@X86@g' -e 's@Intel64@X64@g' -e 's@em64t@X64@g' -e 's@EM64T@X64@g' -e 's@amd64@X64@g' -e 's@AMD64@X64@g' -e 's@ia64@IA64@g'`
if [ "${proc_arch}" = "X64" ] ; then
windows_arch=amd64
else
windows_arch=i586

View File

@ -1,363 +0,0 @@
#!echo "This is not a shell script"
#############################################################################
#
# Copyright 2006-2008 Sun Microsystems, Inc. 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. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#############################################################################
#
# JPRT shell configuration for building.
#
# Input environment variables:
# ALT_BOOTDIR
# ALT_SLASH_JAVA
# ALT_JDK_IMPORT_PATH
# OPENJDK
# Windows Only:
# PATH
# VS71COMNTOOLS
# PROCESSOR_IDENTIFIER
# ROOTDIR
#
# Output variable settings:
# make Full path to GNU make
# compiler_path Path to compiler bin directory
# compiler_name Unique name of this compiler
#
# Output environment variables:
# PATH
# ALT_COMPILER_PATH
# OPENJDK only:
# ALT_CLOSED_JDK_IMPORT_PATH
# ALT_JDK_DEVTOOLS_DIR
# Windows Only:
# ALT_MSDEVTOOLS_PATH
# ALT_DEVTOOLS_PATH (To avoid the C:/UTILS default)
# LIB
# INCLUDE
#
# After JDK6, most settings will be found via ALT_SLASH_JAVA or
# by way of other system environment variables. If this was JDK5
# or an older JDK, you might need to export more ALT_* variables.
#
# On Windows AMD64, if MSSDK is not set, assumes Platform SDK is installed at:
# C:/Program Files/Microsoft Platform SDK
#
#############################################################################
#############################################################################
# Error
error() # message
{
echo "ERROR: $1"
exit 6
}
# Directory must exist
dirMustExist() # dir name
{
if [ ! -d "$1" ] ; then
error "Directory for $2 does not exist: $1"
fi
}
# File must exist
fileMustExist() # dir name
{
if [ ! -f "$1" ] ; then
error "File for $2 does not exist: $1"
fi
}
#############################################################################
# Should be set by JPRT as the 3 basic inputs
bootdir="${ALT_BOOTDIR}"
slashjava="${ALT_SLASH_JAVA}"
jdk_import="${ALT_JDK_IMPORT_PATH}"
# The /java/devtools items
jdk_devtools="${slashjava}/devtools"
share="${jdk_devtools}/share"
# Needed for langtools, maybe other parts of the build
ANT_HOME="${share}/ant/latest"
export ANT_HOME
# The 3 bin directories in common to all platforms
sharebin="${share}/bin"
antbin="${ANT_HOME}/bin"
# Check input
dirMustExist "${bootdir}" ALT_BOOTDIR
dirMustExist "${slashjava}" ALT_SLASH_JAVA
dirMustExist "${jdk_import}" ALT_JDK_IMPORT_PATH
dirMustExist "${ANT_HOME}" ANT_HOME
# Use the JDK import for now (FIXME: use the binary plugs?)
if [ "${OPENJDK}" = true ] ; then
ALT_CLOSED_JDK_IMPORT_PATH="${jdk_import}"
export ALT_CLOSED_JDK_IMPORT_PATH
fi
# Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
osname=`uname -s`
if [ "${osname}" = SunOS ] ; then
# SOLARIS: Sparc or X86
osarch=`uname -p`
if [ "${osarch}" = sparc ] ; then
solaris_arch=sparc
else
solaris_arch=i386
fi
# Get the compilers into path (make sure it matches ALT setting)
if [ "${JPRT_SOLARIS_COMPILER_NAME}" != "" ] ; then
compiler_name=${JPRT_SOLARIS_COMPILER_NAME}
else
compiler_name=SS12
fi
compiler_path=${jdk_devtools}/${solaris_arch}/SUNWspro/${compiler_name}/bin
ALT_COMPILER_PATH="${compiler_path}"
export ALT_COMPILER_PATH
dirMustExist "${compiler_path}" ALT_COMPILER_PATH
path4sdk=${compiler_path}:${sharebin}:${antbin}
# Add basic solaris system paths
path4sdk=${path4sdk}:/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin
# Get the previous JDK to be used to bootstrap the build
path4sdk=${bootdir}/bin:${path4sdk}
# Find GNU make
make=/usr/sfw/bin/gmake
if [ ! -f ${make} ] ; then
make=/opt/sfw/bin/gmake
if [ ! -f ${make} ] ; then
make=${jdk_devtools}/${solaris_arch}/bin/gnumake
fi
fi
fileMustExist "${make}" make
# File creation mask
umask 002
elif [ "${osname}" = Linux ] ; then
# LINUX: X86, AMD64
osarch=`uname -m`
if [ "${osarch}" = i686 ] ; then
linux_arch=i586
elif [ "${osarch}" = x86_64 ] ; then
linux_arch=amd64
fi
# Get the compilers into path (make sure it matches ALT setting)
compiler_path=/usr/bin
compiler_name=usr_bin
ALT_COMPILER_PATH="${compiler_path}"
export ALT_COMPILER_PATH
dirMustExist "${compiler_path}" ALT_COMPILER_PATH
path4sdk=${compiler_path}:${sharebin}:${antbin}
# Add basic paths
path4sdk=${path4sdk}:/usr/bin:/bin:/usr/sbin:/sbin
# Get the previous JDK to be used to bootstrap the build
path4sdk=${bootdir}/bin:${path4sdk}
# Find GNU make
make=/usr/bin/make
fileMustExist "${make}" make
umask 002
# Linux platform may be old, use motif files from the devtools area
if [ "${OPENJDK}" = true ] ; then
ALT_JDK_DEVTOOLS_DIR="${jdk_devtools}"
export ALT_JDK_DEVTOOLS_DIR
fi
else
# Windows: Differs on CYGWIN vs. MKS, and the compiler available.
# Also, blanks in pathnames gives GNU make headaches, so anything placed
# in any ALT_* variable should be the short windows dosname.
# WINDOWS: Install and use MKS or CYGWIN (should have already been done)
# Assumption here is that you are in a shell window via MKS or cygwin.
# MKS install should have defined the environment variable ROOTDIR.
# We also need to figure out which one we have: X86, AMD64
if [ "`echo ${PROCESSOR_IDENTIFIER} | fgrep AMD64`" != "" ] ; then
windows_arch=amd64
else
windows_arch=i586
fi
# We need to determine if we are running a CYGWIN shell or an MKS shell
# (if uname isn't available, then it will be unix_toolset=unknown)
unix_toolset=unknown
if [ "`uname -a | fgrep Cygwin`" = "" -a -d "${ROOTDIR}" ] ; then
# We kind of assume ROOTDIR is where MKS is and it's ok
unix_toolset=MKS
mkshome=`dosname -s "${ROOTDIR}"`
# Utility to convert to short pathnames without spaces
dosname="${mkshome}/mksnt/dosname -s"
# Most unix utilities are in the mksnt directory of ROOTDIR
unixcommand_path="${mkshome}/mksnt"
path4sdk="${sharebin};${antbin};${unixcommand_path}"
dirMustExist "${unixcommand_path}" ALT_UNIXCOMMAND_PATH
devtools_path="${jdk_devtools}/win32/bin"
path4sdk="${devtools_path};${path4sdk}"
# Normally this need not be set, but on Windows it's default is C:/UTILS
ALT_DEVTOOLS_PATH="${devtools_path}"
export ALT_DEVTOOLS_PATH
dirMustExist "${devtools_path}" ALT_DEVTOOLS_PATH
# Find GNU make
make="${devtools_path}/gnumake.exe"
fileMustExist "${make}" make
elif [ "`uname -a | fgrep Cygwin`" != "" -a -f /bin/cygpath ] ; then
# For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
unix_toolset=CYGWIN
# Utility to convert to short pathnames without spaces
dosname="/usr/bin/cygpath -a -m -s"
# Most unix utilities are in the /usr/bin
unixcommand_path="/usr/bin"
path4sdk="${sharebin};${antbin};${unixcommand_path}"
dirMustExist "${unixcommand_path}" ALT_UNIXCOMMAND_PATH
# Find GNU make
make="${unixcommand_path}/make.exe"
fileMustExist "${make}" make
else
echo "WARNING: Cannot figure out if this is MKS or CYGWIN"
fi
# WINDOWS: Compiler setup (nasty part)
# NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE.
# NOTE: CYGWIN has a link.exe too, make sure the compilers are first
if [ "${windows_arch}" = i586 ] ; then
# 32bit Windows compiler settings
# VisualStudio .NET 2003 VC++ 7.1 (VS71COMNTOOLS should be defined)
vs_root=`${dosname} "${VS71COMNTOOLS}/../.."`
# Fill in PATH, LIB, and INCLUDE (unset all others to make sure)
msdev_root="${vs_root}/Common7/Tools"
msdevtools_path="${msdev_root}/bin"
vc7_root="${vs_root}/Vc7"
compiler_path="${vc7_root}/bin"
compiler_name=VS2003
platform_sdk="${vc7_root}/PlatformSDK"
# LIB and INCLUDE must use ; as a separator
include4sdk="${vc7_root}/atlmfc/include"
include4sdk="${include4sdk};${vc7_root}/include"
include4sdk="${include4sdk};${platform_sdk}/include/prerelease"
include4sdk="${include4sdk};${platform_sdk}/include"
include4sdk="${include4sdk};${vs_root}/SDK/v1.1/include"
lib4sdk="${vc7_root}/atlmfc/lib"
lib4sdk="${lib4sdk};${vc7_root}/lib"
lib4sdk="${lib4sdk};${platform_sdk}/lib/prerelease"
lib4sdk="${lib4sdk};${platform_sdk}/lib"
lib4sdk="${lib4sdk};${vs_root}/SDK/v1.1/lib"
# Search path and DLL locating path
# WARNING: CYGWIN has a link.exe too, make sure compilers are first
path4sdk="${vs_root}/Common7/Tools/bin;${path4sdk}"
path4sdk="${vs_root}/SDK/v1.1/bin;${path4sdk}"
path4sdk="${vs_root}/Common7/Tools;${path4sdk}"
path4sdk="${vs_root}/Common7/Tools/bin/prerelease;${path4sdk}"
path4sdk="${vs_root}/Common7/IDE;${path4sdk}"
path4sdk="${compiler_path};${path4sdk}"
elif [ "${windows_arch}" = amd64 ] ; then
# AMD64 64bit Windows compiler settings
if [ "${MSSDK}" != "" ] ; then
platform_sdk="${MSSDK}"
else
platform_sdk=`${dosname} "C:/Program Files/Microsoft Platform SDK/"`
fi
compiler_path="${platform_sdk}/Bin/win64/x86/AMD64"
compiler_name=VS2005_PSDK
msdevtools_path="${platform_sdk}/Bin"
# LIB and INCLUDE must use ; as a separator
include4sdk="${platform_sdk}/Include"
include4sdk="${include4sdk};${platform_sdk}/Include/crt/sys"
include4sdk="${include4sdk};${platform_sdk}/Include/mfc"
include4sdk="${include4sdk};${platform_sdk}/Include/atl"
include4sdk="${include4sdk};${platform_sdk}/Include/crt"
lib4sdk="${platform_sdk}/Lib/AMD64"
lib4sdk="${lib4sdk};${platform_sdk}/Lib/AMD64/atlmfc"
# Search path and DLL locating path
# WARNING: CYGWIN has a link.exe too, make sure compilers are first
path4sdk="${platform_sdk}/bin;${path4sdk}"
path4sdk="${compiler_path};${path4sdk}"
fi
# Export LIB and INCLUDE
unset lib
unset Lib
LIB="${lib4sdk}"
export LIB
unset include
unset Include
INCLUDE="${include4sdk}"
export INCLUDE
# Set the ALT variable
ALT_COMPILER_PATH=`${dosname} "${compiler_path}"`
export ALT_COMPILER_PATH
dirMustExist "${compiler_path}" ALT_COMPILER_PATH
ALT_MSDEVTOOLS_PATH=`${dosname} "${msdevtools_path}"`
export ALT_MSDEVTOOLS_PATH
dirMustExist "${msdevtools_path}" ALT_MSDEVTOOLS_PATH
# WINDOWS: Get the previous JDK to be used to bootstrap the build
path4sdk="${bootdir}/bin;${path4sdk}"
# Turn all \\ into /, remove duplicates and trailing /
slash_path="`echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g'`"
# For windows, it's hard to know where the system is, so we just add this
# to PATH.
path4sdk="${slash_path};${PATH}"
# Convert path4sdk to cygwin style
if [ "${unix_toolset}" = CYGWIN ] ; then
path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
fi
# Set special windows ALT variables
ALT_ISHIELDDIR="C:/ishield802"
export ALT_ISHIELDDIR
# Sponsors binaries
ALT_SPONSOR1DIR=C:/sponsor_binaries
export ALT_SPONSOR1DIR
ALT_SPONSOR2DIR=C:/sponsor_binaries
export ALT_SPONSOR2DIR
fi
# Export PATH setting
PATH="${path4sdk}"
export PATH
# Things we need to unset
unset LD_LIBRARY_PATH
unset LD_LIBRARY_PATH_32
unset LD_LIBRARY_PATH_64
unset JAVA_HOME

View File

@ -53,6 +53,19 @@ jprt.solaris_x64.build.platform.match32=solaris_i586_5.10
# Standard list of jprt test targets for this workspace
jprt.test.targets=*-*-*-jvm98
jprt.regression.test.targets= \
*-*-*-java/lang, \
*-*-*-java/security, \
*-*-*-java/text, \
*-*-*-java/util
#jprt.regression.test.targets= \
# *-*-*-java/awt, \
# *-*-*-java/beans, \
# *-*-*-java/io, \
# *-*-*-java/net, \
# *-*-*-java/nio, \
# *-*-*-java/rmi, \
# Directories needed to build
jprt.bundle.exclude.src.dirs=build

View File

@ -339,8 +339,7 @@ ifeq ($(PLATFORM), windows)
FONTCONFIGS_SRC = $(PLATFORM_SRC)/classes/sun/awt/windows
_FONTCONFIGS = \
fontconfig.properties \
fontconfig.98.properties
fontconfig.properties
FONTCONFIGS_SRC_PREFIX =

View File

@ -35,7 +35,16 @@ MGMT_LIB_SRC = $(SHARE_SRC)/lib/management
all build:: properties aclfile jmxremotefiles
SUBDIRS = snmp jmxremote
# When building the openjdk, build snmp only if importing binary plugs,
ifdef OPENJDK
ifeq ($(IMPORT_BINARY_PLUGS),true)
SUBDIRS = snmp
endif
else
SUBDIRS = snmp
endif
SUBDIRS += jmxremote
all build clean clobber::
$(SUBDIRS-loop)

View File

@ -304,12 +304,14 @@ SUNWprivate_1.1 {
Java_java_awt_FileDialog_initIDs;
Java_sun_awt_X11_XWindow_initIDs;
Java_sun_java2d_opengl_OGLContext_getOGLIdString;
Java_sun_java2d_opengl_OGLMaskFill_maskFill;
Java_sun_java2d_opengl_OGLRenderer_drawPoly;
Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer;
Java_sun_java2d_opengl_OGLSurfaceData_initTexture;
Java_sun_java2d_opengl_OGLSurfaceData_initFBObject;
Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer;
Java_sun_java2d_opengl_OGLSurfaceData_getTextureID;
Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget;
Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList;
Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo;

View File

@ -153,7 +153,7 @@ public class GIFImageMetadata extends GIFMetadata {
node.setAttribute("imageWidth", Integer.toString(imageWidth));
node.setAttribute("imageHeight", Integer.toString(imageHeight));
node.setAttribute("interlaceFlag",
interlaceFlag ? "true" : "false");
interlaceFlag ? "TRUE" : "FALSE");
root.appendChild(node);
// Local color table
@ -185,9 +185,9 @@ public class GIFImageMetadata extends GIFMetadata {
node.setAttribute("disposalMethod",
disposalMethodNames[disposalMethod]);
node.setAttribute("userInputFlag",
userInputFlag ? "true" : "false");
userInputFlag ? "TRUE" : "FALSE");
node.setAttribute("transparentColorFlag",
transparentColorFlag ? "true" : "false");
transparentColorFlag ? "TRUE" : "FALSE");
node.setAttribute("delayTime",
Integer.toString(delayTime));
node.setAttribute("transparentColorIndex",

View File

@ -55,6 +55,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sun.imageio.plugins.common.LZWCompressor;
import com.sun.imageio.plugins.common.PaletteBuilder;
import sun.awt.image.ByteComponentRaster;
public class GIFImageWriter extends ImageWriter {
private static final boolean DEBUG = false; // XXX false for release!
@ -905,10 +906,18 @@ public class GIFImageWriter extends ImageWriter {
LZWCompressor compressor =
new LZWCompressor(stream, initCodeSize, false);
/* At this moment we know that input image is indexed image.
* We can directly copy data iff:
* - no subsampling required (periodX = 1, periodY = 0)
* - we can access data directly (image is non-tiled,
* i.e. image data are in single block)
* - we can calculate offset in data buffer (next 3 lines)
*/
boolean isOptimizedCase =
periodX == 1 && periodY == 1 &&
sampleModel instanceof ComponentSampleModel &&
image.getNumXTiles() == 1 && image.getNumYTiles() == 1 &&
sampleModel instanceof ComponentSampleModel &&
image.getTile(0, 0) instanceof ByteComponentRaster &&
image.getTile(0, 0).getDataBuffer() instanceof DataBufferByte;
int numRowsWritten = 0;
@ -921,11 +930,14 @@ public class GIFImageWriter extends ImageWriter {
if (DEBUG) System.out.println("Writing interlaced");
if (isOptimizedCase) {
Raster tile = image.getTile(0, 0);
ByteComponentRaster tile =
(ByteComponentRaster)image.getTile(0, 0);
byte[] data = ((DataBufferByte)tile.getDataBuffer()).getData();
ComponentSampleModel csm =
(ComponentSampleModel)tile.getSampleModel();
int offset = csm.getOffset(sourceXOffset, sourceYOffset, 0);
// take into account the raster data offset
offset += tile.getDataOffset(0);
int lineStride = csm.getScanlineStride();
writeRowsOpt(data, offset, lineStride, compressor,

View File

@ -158,13 +158,10 @@ abstract class GIFMetadata extends IIOMetadata {
}
}
String value = attr.getNodeValue();
// XXX Should be able to use equals() here instead of
// equalsIgnoreCase() but some boolean attributes are incorrectly
// set to "true" or "false" by the J2SE core metadata classes
// getAsTree() method (which are duplicated above). See bug 5082756.
if (value.equalsIgnoreCase("TRUE")) {
// Allow lower case booleans for backward compatibility, #5082756
if (value.equals("TRUE") || value.equals("true")) {
return true;
} else if (value.equalsIgnoreCase("FALSE")) {
} else if (value.equals("FALSE") || value.equals("false")) {
return false;
} else {
fatal(node, "Attribute " + name + " must be 'TRUE' or 'FALSE'!");

View File

@ -202,7 +202,7 @@ public class GIFStreamMetadata extends GIFMetadata {
compression_node.appendChild(node);
node = new IIOMetadataNode("Lossless");
node.setAttribute("value", "true");
node.setAttribute("value", "TRUE");
compression_node.appendChild(node);
// NumProgressiveScans not in stream

View File

@ -1003,7 +1003,7 @@ class JFIFMarkerSegment extends MarkerSegment {
3,
new int [] {0, 1, 2},
null);
ColorModel cm = new ComponentColorModel(JPEG.sRGB,
ColorModel cm = new ComponentColorModel(JPEG.JCS.sRGB,
false,
false,
ColorModel.OPAQUE,

View File

@ -208,15 +208,24 @@ public class JPEG {
public static final int [] bOffsRGB = { 2, 1, 0 };
protected static final ColorSpace sRGB =
ColorSpace.getInstance(ColorSpace.CS_sRGB);
protected static ColorSpace YCC = null; // Can't be final
/* These are kept in the inner class to avoid static initialization
* of the CMM class until someone actually needs it.
* (e.g. do not init CMM on the request for jpeg mime types)
*/
public static class JCS {
public static final ColorSpace sRGB =
ColorSpace.getInstance(ColorSpace.CS_sRGB);
public static final ColorSpace YCC;
static {
try {
YCC = ColorSpace.getInstance(ColorSpace.CS_PYCC);
} catch (IllegalArgumentException e) {
// PYCC.pf may not always be installed
static {
ColorSpace cs = null;
try {
cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
} catch (IllegalArgumentException e) {
// PYCC.pf may not always be installed
} finally {
YCC = cs;
}
}
}

View File

@ -228,31 +228,31 @@ public class JPEGImageReader extends ImageReader {
(BufferedImage.TYPE_BYTE_GRAY);
defaultTypes[JPEG.JCS_RGB] =
ImageTypeSpecifier.createInterleaved
(JPEG.sRGB,
(JPEG.JCS.sRGB,
JPEG.bOffsRGB,
DataBuffer.TYPE_BYTE,
false,
false);
defaultTypes[JPEG.JCS_RGBA] =
ImageTypeSpecifier.createPacked
(JPEG.sRGB,
(JPEG.JCS.sRGB,
0xff000000,
0x00ff0000,
0x0000ff00,
0x000000ff,
DataBuffer.TYPE_INT,
false);
if (JPEG.YCC != null) {
if (JPEG.JCS.YCC != null) {
defaultTypes[JPEG.JCS_YCC] =
ImageTypeSpecifier.createInterleaved
(JPEG.YCC,
(JPEG.JCS.YCC,
JPEG.bandOffsets[2],
DataBuffer.TYPE_BYTE,
false,
false);
defaultTypes[JPEG.JCS_YCCA] =
ImageTypeSpecifier.createInterleaved
(JPEG.YCC,
(JPEG.JCS.YCC,
JPEG.bandOffsets[3],
DataBuffer.TYPE_BYTE,
true,
@ -774,7 +774,7 @@ public class JPEGImageReader extends ImageReader {
case JPEG.JCS_RGB:
list.add(raw);
list.add(getImageType(JPEG.JCS_GRAYSCALE));
if (JPEG.YCC != null) {
if (JPEG.JCS.YCC != null) {
list.add(getImageType(JPEG.JCS_YCC));
}
break;
@ -811,7 +811,7 @@ public class JPEGImageReader extends ImageReader {
}
list.add(getImageType(JPEG.JCS_GRAYSCALE));
if (JPEG.YCC != null) { // Might be null if PYCC.pf not installed
if (JPEG.JCS.YCC != null) { // Might be null if PYCC.pf not installed
list.add(getImageType(JPEG.JCS_YCC));
}
break;
@ -893,7 +893,7 @@ public class JPEGImageReader extends ImageReader {
(!cs.isCS_sRGB()) &&
(cm.getNumComponents() == numComponents)) {
// Target isn't sRGB, so convert from sRGB to the target
convert = new ColorConvertOp(JPEG.sRGB, cs, null);
convert = new ColorConvertOp(JPEG.JCS.sRGB, cs, null);
} else if (csType != ColorSpace.TYPE_RGB) {
throw new IIOException("Incompatible color conversion");
}
@ -906,18 +906,18 @@ public class JPEGImageReader extends ImageReader {
}
break;
case JPEG.JCS_YCC:
if (JPEG.YCC == null) { // We can't do YCC at all
if (JPEG.JCS.YCC == null) { // We can't do YCC at all
throw new IIOException("Incompatible color conversion");
}
if ((cs != JPEG.YCC) &&
if ((cs != JPEG.JCS.YCC) &&
(cm.getNumComponents() == numComponents)) {
convert = new ColorConvertOp(JPEG.YCC, cs, null);
convert = new ColorConvertOp(JPEG.JCS.YCC, cs, null);
}
break;
case JPEG.JCS_YCCA:
// No conversions available; image must be YCCA
if ((JPEG.YCC == null) || // We can't do YCC at all
(cs != JPEG.YCC) ||
if ((JPEG.JCS.YCC == null) || // We can't do YCC at all
(cs != JPEG.JCS.YCC) ||
(cm.getNumComponents() != numComponents)) {
throw new IIOException("Incompatible color conversion");
}

View File

@ -39,8 +39,6 @@ public class JPEGImageReaderSpi extends ImageReaderSpi {
private static String [] writerSpiNames =
{"com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi"};
private boolean registered = false;
public JPEGImageReaderSpi() {
super(JPEG.vendor,
JPEG.version,
@ -61,26 +59,6 @@ public class JPEGImageReaderSpi extends ImageReaderSpi {
);
}
public void onRegistration(ServiceRegistry registry,
Class<?> category) {
if (registered) {
return;
}
try {
java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("jpeg"));
// Stuff it all into one lib for first pass
//java.security.AccessController.doPrivileged(
//new sun.security.action.LoadLibraryAction("imageioIJG"));
} catch (Throwable e) { // Fail on any Throwable
// if it can't be loaded, deregister and return
registry.deregisterServiceProvider(this);
return;
}
registered = true;
}
public String getDescription(Locale locale) {
return "Standard JPEG Image Reader";
}

View File

@ -812,13 +812,13 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.YCC) {
if (cs == JPEG.JCS.YCC) {
if (!alpha) {
if (jfif != null) {
convertTosRGB = true;
convertOp =
new ColorConvertOp(cs,
JPEG.sRGB,
JPEG.JCS.sRGB,
null);
outCsType = JPEG.JCS_YCbCr;
} else if (adobe != null) {
@ -1494,7 +1494,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.YCC) {
if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
@ -1533,7 +1533,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.YCC) {
if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
@ -1579,7 +1579,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.YCC) {
if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {

View File

@ -42,8 +42,6 @@ public class JPEGImageWriterSpi extends ImageWriterSpi {
private static String [] readerSpiNames =
{"com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi"};
private boolean registered = false;
public JPEGImageWriterSpi() {
super(JPEG.vendor,
JPEG.version,
@ -68,23 +66,6 @@ public class JPEGImageWriterSpi extends ImageWriterSpi {
return "Standard JPEG Image Writer";
}
public void onRegistration(ServiceRegistry registry,
Class<?> category) {
if (registered) {
return;
}
try {
java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("jpeg"));
} catch (Throwable e) { // Fail on any Throwable
// if it can't be loaded, deregister and return
registry.deregisterServiceProvider(this);
return;
}
registered = true;
}
public boolean isFormatLossless() {
return false;
}

View File

@ -490,7 +490,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.YCC) {
if (cs == JPEG.JCS.YCC) {
wantJFIF = false;
componentIDs[0] = (byte) 'Y';
componentIDs[1] = (byte) 'C';
@ -955,7 +955,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
// Lossless - false
IIOMetadataNode lossless = new IIOMetadataNode("Lossless");
lossless.setAttribute("value", "false");
lossless.setAttribute("value", "FALSE");
compression.appendChild(lossless);
// NumProgressiveScans - count sos segments

View File

@ -37,6 +37,7 @@ import java.awt.image.WritableRaster;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException;
import java.io.SequenceInputStream;
@ -59,7 +60,7 @@ import com.sun.imageio.plugins.common.SubImageInputStream;
import java.io.ByteArrayOutputStream;
import sun.awt.image.ByteInterleavedRaster;
class PNGImageDataEnumeration implements Enumeration {
class PNGImageDataEnumeration implements Enumeration<InputStream> {
boolean firstTime = true;
ImageInputStream stream;
@ -72,7 +73,7 @@ class PNGImageDataEnumeration implements Enumeration {
int type = stream.readInt(); // skip chunk type
}
public Object nextElement() {
public InputStream nextElement() {
try {
firstTime = false;
ImageInputStream iis = new SubImageInputStream(stream, length);
@ -207,25 +208,17 @@ public class PNGImageReader extends ImageReader {
resetStreamSettings();
}
private String readNullTerminatedString(String charset) throws IOException {
private String readNullTerminatedString(String charset, int maxLen) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b;
while ((b = stream.read()) != 0) {
int count = 0;
while ((maxLen > count++) && ((b = stream.read()) != 0)) {
if (b == -1) throw new EOFException();
baos.write(b);
}
return new String(baos.toByteArray(), charset);
}
private String readNullTerminatedString() throws IOException {
StringBuilder b = new StringBuilder();
int c;
while ((c = stream.read()) != 0) {
b.append((char)c);
}
return b.toString();
}
private void readHeader() throws IIOException {
if (gotHeader) {
return;
@ -434,7 +427,7 @@ public class PNGImageReader extends ImageReader {
}
private void parse_iCCP_chunk(int chunkLength) throws IOException {
String keyword = readNullTerminatedString();
String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.iCCP_profileName = keyword;
metadata.iCCP_compressionMethod = stream.readUnsignedByte();
@ -450,7 +443,7 @@ public class PNGImageReader extends ImageReader {
private void parse_iTXt_chunk(int chunkLength) throws IOException {
long chunkStart = stream.getStreamPosition();
String keyword = readNullTerminatedString();
String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.iTXt_keyword.add(keyword);
int compressionFlag = stream.readUnsignedByte();
@ -459,15 +452,17 @@ public class PNGImageReader extends ImageReader {
int compressionMethod = stream.readUnsignedByte();
metadata.iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
String languageTag = readNullTerminatedString("UTF8");
String languageTag = readNullTerminatedString("UTF8", 80);
metadata.iTXt_languageTag.add(languageTag);
long pos = stream.getStreamPosition();
int maxLen = (int)(chunkStart + chunkLength - pos);
String translatedKeyword =
readNullTerminatedString("UTF8");
readNullTerminatedString("UTF8", maxLen);
metadata.iTXt_translatedKeyword.add(translatedKeyword);
String text;
long pos = stream.getStreamPosition();
pos = stream.getStreamPosition();
byte[] b = new byte[(int)(chunkStart + chunkLength - pos)];
stream.readFully(b);
@ -511,7 +506,7 @@ public class PNGImageReader extends ImageReader {
private void parse_sPLT_chunk(int chunkLength)
throws IOException, IIOException {
metadata.sPLT_paletteName = readNullTerminatedString();
metadata.sPLT_paletteName = readNullTerminatedString("ISO-8859-1", 80);
chunkLength -= metadata.sPLT_paletteName.length() + 1;
int sampleDepth = stream.readUnsignedByte();
@ -554,12 +549,12 @@ public class PNGImageReader extends ImageReader {
}
private void parse_tEXt_chunk(int chunkLength) throws IOException {
String keyword = readNullTerminatedString();
String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.tEXt_keyword.add(keyword);
byte[] b = new byte[chunkLength - keyword.length() - 1];
stream.readFully(b);
metadata.tEXt_text.add(new String(b));
metadata.tEXt_text.add(new String(b, "ISO-8859-1"));
}
private void parse_tIME_chunk() throws IOException {
@ -640,7 +635,7 @@ public class PNGImageReader extends ImageReader {
}
private void parse_zTXt_chunk(int chunkLength) throws IOException {
String keyword = readNullTerminatedString();
String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.zTXt_keyword.add(keyword);
int method = stream.readUnsignedByte();
@ -648,7 +643,7 @@ public class PNGImageReader extends ImageReader {
byte[] b = new byte[chunkLength - keyword.length() - 2];
stream.readFully(b);
metadata.zTXt_text.add(new String(inflate(b)));
metadata.zTXt_text.add(new String(inflate(b), "ISO-8859-1"));
}
private void readMetadata() throws IIOException {
@ -1263,7 +1258,7 @@ public class PNGImageReader extends ImageReader {
try {
stream.seek(imageStartPosition);
Enumeration e = new PNGImageDataEnumeration(stream);
Enumeration<InputStream> e = new PNGImageDataEnumeration(stream);
InputStream is = new SequenceInputStream(e);
/* InflaterInputStream uses an Inflater instance which consumes

View File

@ -674,13 +674,8 @@ public class PNGImageWriter extends ImageWriter {
private byte[] deflate(byte[] b) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(baos);
int len = b.length;
for (int i = 0; i < len; i++) {
dos.write((int)(0xff & b[i]));
}
dos.write(b);
dos.close();
return baos.toByteArray();
}
@ -736,7 +731,7 @@ public class PNGImageWriter extends ImageWriter {
cs.writeByte(compressionMethod);
String text = (String)textIter.next();
cs.write(deflate(text.getBytes()));
cs.write(deflate(text.getBytes("ISO-8859-1")));
cs.finish();
}
}

View File

@ -211,8 +211,8 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
public int sRGB_renderingIntent;
// tEXt chunk
public ArrayList tEXt_keyword = new ArrayList(); // 1-79 char Strings
public ArrayList tEXt_text = new ArrayList(); // Strings
public ArrayList<String> tEXt_keyword = new ArrayList<String>(); // 1-79 characters
public ArrayList<String> tEXt_text = new ArrayList<String>();
// tIME chunk
public boolean tIME_present;
@ -235,13 +235,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
public int tRNS_blue;
// zTXt chunk
public ArrayList zTXt_keyword = new ArrayList(); // Strings
public ArrayList zTXt_compressionMethod = new ArrayList(); // Integers
public ArrayList zTXt_text = new ArrayList(); // Strings
public ArrayList<String> zTXt_keyword = new ArrayList<String>();
public ArrayList<Integer> zTXt_compressionMethod = new ArrayList<Integer>();
public ArrayList<String> zTXt_text = new ArrayList<String>();
// Unknown chunks
public ArrayList unknownChunkType = new ArrayList(); // Strings
public ArrayList unknownChunkData = new ArrayList(); // byte arrays
public ArrayList<String> unknownChunkType = new ArrayList<String>();
public ArrayList<byte[]> unknownChunkData = new ArrayList<byte[]>();
public PNGMetadata() {
super(true,
@ -426,21 +426,14 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
return false;
}
private ArrayList cloneBytesArrayList(ArrayList in) {
private ArrayList<byte[]> cloneBytesArrayList(ArrayList<byte[]> in) {
if (in == null) {
return null;
} else {
ArrayList list = new ArrayList(in.size());
Iterator iter = in.iterator();
while (iter.hasNext()) {
Object o = iter.next();
if (o == null) {
list.add(null);
} else {
list.add(((byte[])o).clone());
}
ArrayList<byte[]> list = new ArrayList<byte[]>(in.size());
for (byte[] b: in) {
list.add((b == null) ? null : (byte[])b.clone());
}
return list;
}
}
@ -600,7 +593,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
IIOMetadataNode iTXt_node = new IIOMetadataNode("iTXtEntry");
iTXt_node.setAttribute("keyword", iTXt_keyword.get(i));
iTXt_node.setAttribute("compressionFlag",
iTXt_compressionFlag.get(i) ? "1" : "0");
iTXt_compressionFlag.get(i) ? "TRUE" : "FALSE");
iTXt_node.setAttribute("compressionMethod",
iTXt_compressionMethod.get(i).toString());
iTXt_node.setAttribute("languageTag",
@ -832,7 +825,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
node = new IIOMetadataNode("BlackIsZero");
node.setAttribute("value", "true");
node.setAttribute("value", "TRUE");
chroma_node.appendChild(node);
if (PLTE_present) {
@ -894,7 +887,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
compression_node.appendChild(node);
node = new IIOMetadataNode("Lossless");
node.setAttribute("value", "true");
node.setAttribute("value", "TRUE");
compression_node.appendChild(node);
node = new IIOMetadataNode("NumProgressiveScans");
@ -1040,7 +1033,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
node.setAttribute("language",
iTXt_languageTag.get(i));
if (iTXt_compressionFlag.get(i)) {
node.setAttribute("compression", "deflate");
node.setAttribute("compression", "zip");
} else {
node.setAttribute("compression", "none");
}
@ -1052,7 +1045,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
node = new IIOMetadataNode("TextEntry");
node.setAttribute("keyword", (String)zTXt_keyword.get(i));
node.setAttribute("value", (String)zTXt_text.get(i));
node.setAttribute("compression", "deflate");
node.setAttribute("compression", "zip");
text_node.appendChild(node);
}
@ -1162,12 +1155,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
}
String value = attr.getNodeValue();
if (value.equals("true")) {
// Allow lower case booleans for backward compatibility, #5082756
if (value.equals("TRUE") || value.equals("true")) {
return true;
} else if (value.equals("false")) {
} else if (value.equals("FALSE") || value.equals("false")) {
return false;
} else {
fatal(node, "Attribute " + name + " must be 'true' or 'false'!");
fatal(node, "Attribute " + name + " must be 'TRUE' or 'FALSE'!");
return false;
}
}
@ -1421,26 +1415,30 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
String keyword = getAttribute(iTXt_node, "keyword");
iTXt_keyword.add(keyword);
if (isValidKeyword(keyword)) {
iTXt_keyword.add(keyword);
boolean compressionFlag =
getBooleanAttribute(iTXt_node, "compressionFlag");
iTXt_compressionFlag.add(Boolean.valueOf(compressionFlag));
boolean compressionFlag =
getBooleanAttribute(iTXt_node, "compressionFlag");
iTXt_compressionFlag.add(Boolean.valueOf(compressionFlag));
String compressionMethod =
getAttribute(iTXt_node, "compressionMethod");
iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
String compressionMethod =
getAttribute(iTXt_node, "compressionMethod");
iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
String languageTag =
getAttribute(iTXt_node, "languageTag");
iTXt_languageTag.add(languageTag);
String languageTag =
getAttribute(iTXt_node, "languageTag");
iTXt_languageTag.add(languageTag);
String translatedKeyword =
getAttribute(iTXt_node, "translatedKeyword");
iTXt_translatedKeyword.add(translatedKeyword);
String translatedKeyword =
getAttribute(iTXt_node, "translatedKeyword");
iTXt_translatedKeyword.add(translatedKeyword);
String text = getAttribute(iTXt_node, "text");
iTXt_text.add(text);
String text = getAttribute(iTXt_node, "text");
iTXt_text.add(text);
}
// silently skip invalid text entry
iTXt_node = iTXt_node.getNextSibling();
}
@ -1692,11 +1690,45 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
}
private boolean isISOLatin(String s) {
/*
* Accrding to PNG spec, keywords are restricted to 1 to 79 bytes
* in length. Keywords shall contain only printable Latin-1 characters
* and spaces; To reduce the chances for human misreading of a keyword,
* leading spaces, trailing spaces, and consecutive spaces are not
* permitted in keywords.
*
* See: http://www.w3.org/TR/PNG/#11keywords
*/
private boolean isValidKeyword(String s) {
int len = s.length();
if (len < 1 || len >= 80) {
return false;
}
if (s.startsWith(" ") || s.endsWith(" ") || s.contains(" ")) {
return false;
}
return isISOLatin(s, false);
}
/*
* According to PNG spec, keyword shall contain only printable
* Latin-1 [ISO-8859-1] characters and spaces; that is, only
* character codes 32-126 and 161-255 decimal are allowed.
* For Latin-1 value fields the 0x10 (linefeed) control
* character is aloowed too.
*
* See: http://www.w3.org/TR/PNG/#11keywords
*/
private boolean isISOLatin(String s, boolean isLineFeedAllowed) {
int len = s.length();
for (int i = 0; i < len; i++) {
if (s.charAt(i) > 255) {
return false;
char c = s.charAt(i);
if (c < 32 || c > 255 || (c > 126 && c < 161)) {
// not printable. Check whether this is an allowed
// control char
if (!isLineFeedAllowed || c != 0x10) {
return false;
}
}
}
return true;
@ -1929,19 +1961,22 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
while (child != null) {
String childName = child.getNodeName();
if (childName.equals("TextEntry")) {
String keyword = getAttribute(child, "keyword");
String keyword =
getAttribute(child, "keyword", "", false);
String value = getAttribute(child, "value");
String encoding = getAttribute(child, "encoding");
String language = getAttribute(child, "language");
String language =
getAttribute(child, "language", "", false);
String compression =
getAttribute(child, "compression");
getAttribute(child, "compression", "none", false);
if (isISOLatin(value)) {
if (!isValidKeyword(keyword)) {
// Just ignore this node, PNG requires keywords
} else if (isISOLatin(value, true)) {
if (compression.equals("zip")) {
// Use a zTXt node
zTXt_keyword.add(keyword);
zTXt_text.add(value);
zTXt_compressionMethod.add(new Integer(0));
zTXt_compressionMethod.add(Integer.valueOf(0));
} else {
// Use a tEXt node
tEXt_keyword.add(keyword);
@ -1998,14 +2033,14 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
sBIT_present = false;
sPLT_present = false;
sRGB_present = false;
tEXt_keyword = new ArrayList();
tEXt_text = new ArrayList();
tEXt_keyword = new ArrayList<String>();
tEXt_text = new ArrayList<String>();
tIME_present = false;
tRNS_present = false;
zTXt_keyword = new ArrayList();
zTXt_compressionMethod = new ArrayList();
zTXt_text = new ArrayList();
unknownChunkType = new ArrayList();
unknownChunkData = new ArrayList();
zTXt_keyword = new ArrayList<String>();
zTXt_compressionMethod = new ArrayList<Integer>();
zTXt_text = new ArrayList<String>();
unknownChunkType = new ArrayList<String>();
unknownChunkData = new ArrayList<byte[]>();
}
}

View File

@ -94,6 +94,10 @@ public class StreamCloser {
tgn != null;
tg = tgn, tgn = tg.getParent());
streamCloser = new Thread(tg, streamCloserRunnable);
/* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader.
*/
streamCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(streamCloser);
return null;
}

View File

@ -356,6 +356,9 @@ public abstract class GraphicsEnvironment {
* @since 1.5
*/
public void preferLocaleFonts() {
if (!(this instanceof SunGraphicsEnvironment)) {
return;
}
sun.font.FontManager.preferLocaleFonts();
}
@ -376,6 +379,9 @@ public abstract class GraphicsEnvironment {
* @since 1.5
*/
public void preferProportionalFonts() {
if (!(this instanceof SunGraphicsEnvironment)) {
return;
}
sun.font.FontManager.preferProportionalFonts();
}

View File

@ -737,7 +737,7 @@ public class ICC_Profile implements Serializable {
ICC_Profile(ProfileDeferralInfo pdi) {
this.deferralInfo = pdi;
this.profileActivator = new ProfileActivator() {
public void activate() {
public void activate() throws ProfileDataException {
activateDeferredProfile();
}
};
@ -830,20 +830,16 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_sRGB:
synchronized(ICC_Profile.class) {
if (sRGBprofile == null) {
try {
/*
* Deferral is only used for standard profiles.
* Enabling the appropriate access privileges is handled
* at a lower level.
*/
sRGBprofile = getDeferredInstance(
new ProfileDeferralInfo("sRGB.pf",
ColorSpace.TYPE_RGB,
3, CLASS_DISPLAY));
} catch (IOException e) {
throw new IllegalArgumentException(
"Can't load standard profile: sRGB.pf");
}
/*
* Deferral is only used for standard profiles.
* Enabling the appropriate access privileges is handled
* at a lower level.
*/
ProfileDeferralInfo pInfo =
new ProfileDeferralInfo("sRGB.pf",
ColorSpace.TYPE_RGB, 3,
CLASS_DISPLAY);
sRGBprofile = getDeferredInstance(pInfo);
}
thisProfile = sRGBprofile;
}
@ -853,7 +849,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_CIEXYZ:
synchronized(ICC_Profile.class) {
if (XYZprofile == null) {
XYZprofile = getStandardProfile("CIEXYZ.pf");
ProfileDeferralInfo pInfo =
new ProfileDeferralInfo("CIEXYZ.pf",
ColorSpace.TYPE_XYZ, 3,
CLASS_DISPLAY);
XYZprofile = getDeferredInstance(pInfo);
}
thisProfile = XYZprofile;
}
@ -863,7 +863,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_PYCC:
synchronized(ICC_Profile.class) {
if (PYCCprofile == null) {
PYCCprofile = getStandardProfile("PYCC.pf");
ProfileDeferralInfo pInfo =
new ProfileDeferralInfo("PYCC.pf",
ColorSpace.TYPE_3CLR, 3,
CLASS_DISPLAY);
PYCCprofile = getDeferredInstance(pInfo);
}
thisProfile = PYCCprofile;
}
@ -873,7 +877,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_GRAY:
synchronized(ICC_Profile.class) {
if (GRAYprofile == null) {
GRAYprofile = getStandardProfile("GRAY.pf");
ProfileDeferralInfo pInfo =
new ProfileDeferralInfo("GRAY.pf",
ColorSpace.TYPE_GRAY, 1,
CLASS_DISPLAY);
GRAYprofile = getDeferredInstance(pInfo);
}
thisProfile = GRAYprofile;
}
@ -883,7 +891,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_LINEAR_RGB:
synchronized(ICC_Profile.class) {
if (LINEAR_RGBprofile == null) {
LINEAR_RGBprofile = getStandardProfile("LINEAR_RGB.pf");
ProfileDeferralInfo pInfo =
new ProfileDeferralInfo("LINEAR_RGB.pf",
ColorSpace.TYPE_RGB, 3,
CLASS_DISPLAY);
LINEAR_RGBprofile = getDeferredInstance(pInfo);
}
thisProfile = LINEAR_RGBprofile;
}
@ -1047,9 +1059,7 @@ public class ICC_Profile implements Serializable {
* code will take care of access privileges.
* @see activateDeferredProfile()
*/
static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi)
throws IOException {
static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi) {
if (!ProfileDeferralMgr.deferring) {
return getStandardProfile(pdi.filename);
}
@ -1063,33 +1073,37 @@ public class ICC_Profile implements Serializable {
}
void activateDeferredProfile() {
byte profileData[];
FileInputStream fis;
String fileName = deferralInfo.filename;
void activateDeferredProfile() throws ProfileDataException {
byte profileData[];
FileInputStream fis;
String fileName = deferralInfo.filename;
profileActivator = null;
deferralInfo = null;
if ((fis = openProfile(fileName)) == null) {
throw new IllegalArgumentException("Cannot open file " + fileName);
throw new ProfileDataException("Cannot open file " + fileName);
}
try {
profileData = getProfileDataFromStream(fis);
fis.close(); /* close the file */
}
catch (IOException e) {
throw new IllegalArgumentException("Invalid ICC Profile Data" +
fileName);
ProfileDataException pde = new
ProfileDataException("Invalid ICC Profile Data" + fileName);
pde.initCause(e);
throw pde;
}
if (profileData == null) {
throw new IllegalArgumentException("Invalid ICC Profile Data" +
throw new ProfileDataException("Invalid ICC Profile Data" +
fileName);
}
try {
ID = CMSManager.getModule().loadProfile(profileData);
} catch (CMMException c) {
throw new IllegalArgumentException("Invalid ICC Profile Data" +
fileName);
ProfileDataException pde = new
ProfileDataException("Invalid ICC Profile Data" + fileName);
pde.initCause(c);
throw pde;
}
}

View File

@ -503,6 +503,21 @@ public final class Console implements Flushable
// Set up JavaIOAccess in SharedSecrets
static {
// Add a shutdown hook to restore console's echo state should
// it be necessary.
sun.misc.SharedSecrets.getJavaLangAccess()
.registerShutdownHook(0 /* shutdown hook invocation order */,
new Runnable() {
public void run() {
try {
if (echoOff) {
echo(true);
}
} catch (IOException x) { }
}
});
sun.misc.SharedSecrets.setJavaIOAccess(new sun.misc.JavaIOAccess() {
public Console console() {
if (istty()) {
@ -513,20 +528,6 @@ public final class Console implements Flushable
return null;
}
// Add a shutdown hook to restore console's echo state should
// it be necessary.
public Runnable consoleRestoreHook() {
return new Runnable() {
public void run() {
try {
if (echoOff) {
echo(true);
}
} catch (IOException x) {}
}
};
}
public Charset charset() {
// This method is called in sun.security.util.Password,
// cons already exists when this method is called

View File

@ -34,17 +34,18 @@ import java.io.File;
*/
class DeleteOnExitHook {
private static DeleteOnExitHook instance = null;
static {
sun.misc.SharedSecrets.getJavaLangAccess()
.registerShutdownHook(2 /* Shutdown hook invocation order */,
new Runnable() {
public void run() {
runHooks();
}
});
}
private static LinkedHashSet<String> files = new LinkedHashSet<String>();
static DeleteOnExitHook hook() {
if (instance == null)
instance = new DeleteOnExitHook();
return instance;
}
private DeleteOnExitHook() {}
static synchronized void add(String file) {
@ -54,7 +55,7 @@ class DeleteOnExitHook {
files.add(file);
}
void run() {
static void runHooks() {
LinkedHashSet<String> theFiles;
synchronized (DeleteOnExitHook.class) {

View File

@ -2147,18 +2147,6 @@ public class File
/** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = 301077366599181567L;
// Set up JavaIODeleteOnExitAccess in SharedSecrets
// Added here as DeleteOnExitHook is package-private and SharedSecrets cannot easily access it.
static {
sun.misc.SharedSecrets.setJavaIODeleteOnExitAccess(
new sun.misc.JavaIODeleteOnExitAccess() {
public void run() {
DeleteOnExitHook.hook().run();
}
}
);
}
// -- Integration with java.nio.file --
private volatile transient Path filePath;

View File

@ -34,19 +34,19 @@ import java.util.*;
* @see java.lang.Runtime#removeShutdownHook
*/
class ApplicationShutdownHooks implements Runnable {
private static ApplicationShutdownHooks instance = null;
class ApplicationShutdownHooks {
static {
Shutdown.add(1 /* shutdown hook invocation order */,
new Runnable() {
public void run() {
runHooks();
}
});
}
/* The set of registered hooks */
private static IdentityHashMap<Thread, Thread> hooks = new IdentityHashMap<Thread, Thread>();
static synchronized ApplicationShutdownHooks hook() {
if (instance == null)
instance = new ApplicationShutdownHooks();
return instance;
}
private ApplicationShutdownHooks() {}
/* Add a new shutdown hook. Checks the shutdown state and the hook itself,
@ -82,7 +82,7 @@ class ApplicationShutdownHooks implements Runnable {
* to run in. Hooks are run concurrently and this method waits for
* them to finish.
*/
public void run() {
static void runHooks() {
Collection<Thread> threads;
synchronized(ApplicationShutdownHooks.class) {
threads = hooks.keySet();

View File

@ -25,8 +25,6 @@
package java.lang;
import java.util.ArrayList;
/**
* Package-private utility class containing data structures and logic
@ -47,8 +45,13 @@ class Shutdown {
/* Should we run all finalizers upon exit? */
private static boolean runFinalizersOnExit = false;
/* The set of registered, wrapped hooks, or null if there aren't any */
private static ArrayList<Runnable> hooks = new ArrayList<Runnable>();
// The system shutdown hooks are registered with a predefined slot.
// The list of shutdown hooks is as follows:
// (0) Console restore hook
// (1) Application hooks
// (2) DeleteOnExit hook
private static final int MAX_SYSTEM_HOOKS = 10;
private static final Runnable[] hooks = new Runnable[MAX_SYSTEM_HOOKS];
/* The preceding static fields are protected by this lock */
private static class Lock { };
@ -68,33 +71,18 @@ class Shutdown {
/* Add a new shutdown hook. Checks the shutdown state and the hook itself,
* but does not do any security checks.
*/
static void add(Runnable hook) {
static void add(int slot, Runnable hook) {
synchronized (lock) {
if (state > RUNNING)
throw new IllegalStateException("Shutdown in progress");
hooks.add(hook);
if (hooks[slot] != null)
throw new InternalError("Shutdown hook at slot " + slot + " already registered");
hooks[slot] = hook;
}
}
/* Remove a previously-registered hook. Like the add method, this method
* does not do any security checks.
*/
static boolean remove(Runnable hook) {
synchronized (lock) {
if (state > RUNNING)
throw new IllegalStateException("Shutdown in progress");
if (hook == null) throw new NullPointerException();
if (hooks == null) {
return false;
} else {
return hooks.remove(hook);
}
}
}
/* Run all registered shutdown hooks
*/
private static void runHooks() {
@ -103,7 +91,7 @@ class Shutdown {
*/
for (Runnable hook : hooks) {
try {
hook.run();
if (hook != null) hook.run();
} catch(Throwable t) {
if (t instanceof ThreadDeath) {
ThreadDeath td = (ThreadDeath)t;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2009 Sun Microsystems, Inc. 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
@ -25,13 +25,10 @@
package java.lang;
import java.io.CharConversionException;
import java.io.UnsupportedEncodingException;
import java.lang.ref.SoftReference;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
@ -39,11 +36,12 @@ import java.nio.charset.CharacterCodingException;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.MalformedInputException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Arrays;
import sun.misc.MessageUtils;
import sun.nio.cs.HistoricallyNamedCharset;
import sun.nio.cs.ArrayDecoder;
import sun.nio.cs.ArrayEncoder;
/**
* Utility class for string encoding and decoding.
@ -74,10 +72,8 @@ class StringCoding {
// Trim the given byte array to the given length
//
private static byte[] safeTrim(byte[] ba, int len, Charset cs) {
if (len == ba.length
&& (System.getSecurityManager() == null
|| cs.getClass().getClassLoader0() == null))
private static byte[] safeTrim(byte[] ba, int len, Charset cs, boolean isTrusted) {
if (len == ba.length && (isTrusted || System.getSecurityManager() == null))
return ba;
else
return Arrays.copyOf(ba, len);
@ -85,10 +81,9 @@ class StringCoding {
// Trim the given char array to the given length
//
private static char[] safeTrim(char[] ca, int len, Charset cs) {
if (len == ca.length
&& (System.getSecurityManager() == null
|| cs.getClass().getClassLoader0() == null))
private static char[] safeTrim(char[] ca, int len,
Charset cs, boolean isTrusted) {
if (len == ca.length && (isTrusted || System.getSecurityManager() == null))
return ca;
else
return Arrays.copyOf(ca, len);
@ -128,6 +123,7 @@ class StringCoding {
private final String requestedCharsetName;
private final Charset cs;
private final CharsetDecoder cd;
private final boolean isTrusted;
private StringDecoder(Charset cs, String rcn) {
this.requestedCharsetName = rcn;
@ -135,6 +131,7 @@ class StringCoding {
this.cd = cs.newDecoder()
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
this.isTrusted = (cs.getClass().getClassLoader0() == null);
}
String charsetName() {
@ -152,24 +149,28 @@ class StringCoding {
char[] ca = new char[en];
if (len == 0)
return ca;
cd.reset();
ByteBuffer bb = ByteBuffer.wrap(ba, off, len);
CharBuffer cb = CharBuffer.wrap(ca);
try {
CoderResult cr = cd.decode(bb, cb, true);
if (!cr.isUnderflow())
cr.throwException();
cr = cd.flush(cb);
if (!cr.isUnderflow())
cr.throwException();
} catch (CharacterCodingException x) {
// Substitution is always enabled,
// so this shouldn't happen
throw new Error(x);
if (cd instanceof ArrayDecoder) {
int clen = ((ArrayDecoder)cd).decode(ba, off, len, ca);
return safeTrim(ca, clen, cs, isTrusted);
} else {
cd.reset();
ByteBuffer bb = ByteBuffer.wrap(ba, off, len);
CharBuffer cb = CharBuffer.wrap(ca);
try {
CoderResult cr = cd.decode(bb, cb, true);
if (!cr.isUnderflow())
cr.throwException();
cr = cd.flush(cb);
if (!cr.isUnderflow())
cr.throwException();
} catch (CharacterCodingException x) {
// Substitution is always enabled,
// so this shouldn't happen
throw new Error(x);
}
return safeTrim(ca, cb.position(), cs, isTrusted);
}
return safeTrim(ca, cb.position(), cs);
}
}
static char[] decode(String charsetName, byte[] ba, int off, int len)
@ -193,8 +194,57 @@ class StringCoding {
}
static char[] decode(Charset cs, byte[] ba, int off, int len) {
StringDecoder sd = new StringDecoder(cs, cs.name());
return sd.decode(Arrays.copyOfRange(ba, off, off + len), 0, len);
// (1)We never cache the "external" cs, the only benefit of creating
// an additional StringDe/Encoder object to wrap it is to share the
// de/encode() method. These SD/E objects are short-lifed, the young-gen
// gc should be able to take care of them well. But the best approash
// is still not to generate them if not really necessary.
// (2)The defensive copy of the input byte/char[] has a big performance
// impact, as well as the outgoing result byte/char[]. Need to do the
// optimization check of (sm==null && classLoader0==null) for both.
// (3)getClass().getClassLoader0() is expensive
// (4)There might be a timing gap in isTrusted setting. getClassLoader0()
// is only chcked (and then isTrusted gets set) when (SM==null). It is
// possible that the SM==null for now but then SM is NOT null later
// when safeTrim() is invoked...the "safe" way to do is to redundant
// check (... && (isTrusted || SM == null || getClassLoader0())) in trim
// but it then can be argued that the SM is null when the opertaion
// is started...
CharsetDecoder cd = cs.newDecoder();
int en = scale(len, cd.maxCharsPerByte());
char[] ca = new char[en];
if (len == 0)
return ca;
boolean isTrusted = false;
if (System.getSecurityManager() != null) {
if (!(isTrusted = (cs.getClass().getClassLoader0() == null))) {
ba = Arrays.copyOfRange(ba, off, off + len);
off = 0;
}
}
if (cd instanceof ArrayDecoder) {
int clen = ((ArrayDecoder)cd).decode(ba, off, len, ca);
return safeTrim(ca, clen, cs, isTrusted);
} else {
cd.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
.reset();
ByteBuffer bb = ByteBuffer.wrap(ba, off, len);
CharBuffer cb = CharBuffer.wrap(ca);
try {
CoderResult cr = cd.decode(bb, cb, true);
if (!cr.isUnderflow())
cr.throwException();
cr = cd.flush(cb);
if (!cr.isUnderflow())
cr.throwException();
} catch (CharacterCodingException x) {
// Substitution is always enabled,
// so this shouldn't happen
throw new Error(x);
}
return safeTrim(ca, cb.position(), cs, isTrusted);
}
}
static char[] decode(byte[] ba, int off, int len) {
@ -218,14 +268,12 @@ class StringCoding {
}
}
// -- Encoding --
private static class StringEncoder {
private Charset cs;
private CharsetEncoder ce;
private final String requestedCharsetName;
private final boolean isTrusted;
private StringEncoder(Charset cs, String rcn) {
this.requestedCharsetName = rcn;
@ -233,6 +281,7 @@ class StringCoding {
this.ce = cs.newEncoder()
.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
this.isTrusted = (cs.getClass().getClassLoader0() == null);
}
String charsetName() {
@ -250,23 +299,27 @@ class StringCoding {
byte[] ba = new byte[en];
if (len == 0)
return ba;
ce.reset();
ByteBuffer bb = ByteBuffer.wrap(ba);
CharBuffer cb = CharBuffer.wrap(ca, off, len);
try {
CoderResult cr = ce.encode(cb, bb, true);
if (!cr.isUnderflow())
cr.throwException();
cr = ce.flush(bb);
if (!cr.isUnderflow())
cr.throwException();
} catch (CharacterCodingException x) {
// Substitution is always enabled,
// so this shouldn't happen
throw new Error(x);
if (ce instanceof ArrayEncoder) {
int blen = ((ArrayEncoder)ce).encode(ca, off, len, ba);
return safeTrim(ba, blen, cs, isTrusted);
} else {
ce.reset();
ByteBuffer bb = ByteBuffer.wrap(ba);
CharBuffer cb = CharBuffer.wrap(ca, off, len);
try {
CoderResult cr = ce.encode(cb, bb, true);
if (!cr.isUnderflow())
cr.throwException();
cr = ce.flush(bb);
if (!cr.isUnderflow())
cr.throwException();
} catch (CharacterCodingException x) {
// Substitution is always enabled,
// so this shouldn't happen
throw new Error(x);
}
return safeTrim(ba, bb.position(), cs, isTrusted);
}
return safeTrim(ba, bb.position(), cs);
}
}
@ -291,8 +344,39 @@ class StringCoding {
}
static byte[] encode(Charset cs, char[] ca, int off, int len) {
StringEncoder se = new StringEncoder(cs, cs.name());
return se.encode(Arrays.copyOfRange(ca, off, off + len), 0, len);
CharsetEncoder ce = cs.newEncoder();
int en = scale(len, ce.maxBytesPerChar());
byte[] ba = new byte[en];
if (len == 0)
return ba;
boolean isTrusted = false;
if (System.getSecurityManager() != null) {
if (!(isTrusted = (cs.getClass().getClassLoader0() == null))) {
ca = Arrays.copyOfRange(ca, off, off + len);
off = 0;
}
}
if (ce instanceof ArrayEncoder) {
int blen = ((ArrayEncoder)ce).encode(ca, off, len, ba);
return safeTrim(ba, blen, cs, isTrusted);
} else {
ce.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE)
.reset();
ByteBuffer bb = ByteBuffer.wrap(ba);
CharBuffer cb = CharBuffer.wrap(ca, off, len);
try {
CoderResult cr = ce.encode(cb, bb, true);
if (!cr.isUnderflow())
cr.throwException();
cr = ce.flush(bb);
if (!cr.isUnderflow())
cr.throwException();
} catch (CharacterCodingException x) {
throw new Error(x);
}
return safeTrim(ba, bb.position(), cs, isTrusted);
}
}
static byte[] encode(char[] ca, int off, int len) {

View File

@ -34,7 +34,6 @@ import java.security.AllPermission;
import java.nio.channels.Channel;
import java.nio.channels.spi.SelectorProvider;
import sun.nio.ch.Interruptible;
import sun.net.InetAddressCachePolicy;
import sun.reflect.Reflection;
import sun.security.util.SecurityConstants;
import sun.reflect.annotation.AnnotationType;
@ -310,7 +309,6 @@ public final class System {
}
security = s;
InetAddressCachePolicy.setIfNotSet(InetAddressCachePolicy.FOREVER);
}
/**
@ -1121,14 +1119,6 @@ public final class System {
// Setup Java signal handlers for HUP, TERM, and INT (where available).
Terminator.setup();
// The order in with the hooks are added here is important as it
// determines the order in which they are run.
// (1)Console restore hook needs to be called first.
// (2)Application hooks must be run before calling deleteOnExitHook.
Shutdown.add(sun.misc.SharedSecrets.getJavaIOAccess().consoleRestoreHook());
Shutdown.add(ApplicationShutdownHooks.hook());
Shutdown.add(sun.misc.SharedSecrets.getJavaIODeleteOnExitAccess());
// Initialize any miscellenous operating system settings that need to be
// set for the class libraries. Currently this is no-op everywhere except
// for Windows where the process-wide error mode is set before the java.io
@ -1174,6 +1164,9 @@ public final class System {
public void blockedOn(Thread t, Interruptible b) {
t.blockedOn(b);
}
public void registerShutdownHook(int slot, Runnable r) {
Shutdown.add(slot, r);
}
});
}

View File

@ -5,7 +5,7 @@
* 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. Sun designates this
* particular file as subject to the "Classname" exception as provided
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT

View File

@ -215,6 +215,14 @@ public class LogManager {
// This private class is used as a shutdown hook.
// It does a "reset" to close all open handlers.
private class Cleaner extends Thread {
private Cleaner() {
/* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader.
*/
this.setContextClassLoader(null);
}
public void run() {
// This is to ensure the LogManager.<clinit> is completed
// before synchronized block. Otherwise deadlocks are possible.

View File

@ -2567,7 +2567,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
break;
case '<': // (?<xxx) look behind
ch = read();
if (Character.isLetter(ch)) { // named captured group
if (ASCII.isLower(ch) || ASCII.isUpper(ch) || ASCII.isDigit(ch)) {
// named captured group
String name = groupname(ch);
if (namedGroups().containsKey(name))
throw error("Named capturing group <" + name

View File

@ -67,126 +67,13 @@ public class ImageTypeSpecifier {
* <code>BufferedImage</code> types.
*/
private static ImageTypeSpecifier[] BISpecifier;
private static ColorSpace sRGB;
// Initialize the standard specifiers
static {
ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
BISpecifier =
new ImageTypeSpecifier[BufferedImage.TYPE_BYTE_INDEXED + 1];
BISpecifier[BufferedImage.TYPE_CUSTOM] = null;
BISpecifier[BufferedImage.TYPE_INT_RGB] =
createPacked(sRGB,
0x00ff0000,
0x0000ff00,
0x000000ff,
0x0,
DataBuffer.TYPE_INT,
false);
BISpecifier[BufferedImage.TYPE_INT_ARGB] =
createPacked(sRGB,
0x00ff0000,
0x0000ff00,
0x000000ff,
0xff000000,
DataBuffer.TYPE_INT,
false);
BISpecifier[BufferedImage.TYPE_INT_ARGB_PRE] =
createPacked(sRGB,
0x00ff0000,
0x0000ff00,
0x000000ff,
0xff000000,
DataBuffer.TYPE_INT,
true);
BISpecifier[BufferedImage.TYPE_INT_BGR] =
createPacked(sRGB,
0x000000ff,
0x0000ff00,
0x00ff0000,
0x0,
DataBuffer.TYPE_INT,
false);
int[] bOffsRGB = { 2, 1, 0 };
BISpecifier[BufferedImage.TYPE_3BYTE_BGR] =
createInterleaved(sRGB,
bOffsRGB,
DataBuffer.TYPE_BYTE,
false,
false);
int[] bOffsABGR = { 3, 2, 1, 0 };
BISpecifier[BufferedImage.TYPE_4BYTE_ABGR] =
createInterleaved(sRGB,
bOffsABGR,
DataBuffer.TYPE_BYTE,
true,
false);
BISpecifier[BufferedImage.TYPE_4BYTE_ABGR_PRE] =
createInterleaved(sRGB,
bOffsABGR,
DataBuffer.TYPE_BYTE,
true,
true);
BISpecifier[BufferedImage.TYPE_USHORT_565_RGB] =
createPacked(sRGB,
0xF800,
0x07E0,
0x001F,
0x0,
DataBuffer.TYPE_USHORT,
false);
BISpecifier[BufferedImage.TYPE_USHORT_555_RGB] =
createPacked(sRGB,
0x7C00,
0x03E0,
0x001F,
0x0,
DataBuffer.TYPE_USHORT,
false);
BISpecifier[BufferedImage.TYPE_BYTE_GRAY] =
createGrayscale(8,
DataBuffer.TYPE_BYTE,
false);
BISpecifier[BufferedImage.TYPE_USHORT_GRAY] =
createGrayscale(16,
DataBuffer.TYPE_USHORT,
false);
BISpecifier[BufferedImage.TYPE_BYTE_BINARY] =
createGrayscale(1,
DataBuffer.TYPE_BYTE,
false);
BufferedImage bi =
new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED);
IndexColorModel icm = (IndexColorModel)bi.getColorModel();
int mapSize = icm.getMapSize();
byte[] redLUT = new byte[mapSize];
byte[] greenLUT = new byte[mapSize];
byte[] blueLUT = new byte[mapSize];
byte[] alphaLUT = new byte[mapSize];
icm.getReds(redLUT);
icm.getGreens(greenLUT);
icm.getBlues(blueLUT);
icm.getAlphas(alphaLUT);
BISpecifier[BufferedImage.TYPE_BYTE_INDEXED] =
createIndexed(redLUT, greenLUT, blueLUT, alphaLUT,
8,
DataBuffer.TYPE_BYTE);
}
/**
@ -1011,7 +898,7 @@ public class ImageTypeSpecifier {
ImageTypeSpecifier createFromBufferedImageType(int bufferedImageType) {
if (bufferedImageType >= BufferedImage.TYPE_INT_RGB &&
bufferedImageType <= BufferedImage.TYPE_BYTE_INDEXED) {
return BISpecifier[bufferedImageType];
return getSpecifier(bufferedImageType);
} else if (bufferedImageType == BufferedImage.TYPE_CUSTOM) {
throw new IllegalArgumentException("Cannot create from TYPE_CUSTOM!");
} else {
@ -1041,7 +928,7 @@ public class ImageTypeSpecifier {
if (image instanceof BufferedImage) {
int bufferedImageType = ((BufferedImage)image).getType();
if (bufferedImageType != BufferedImage.TYPE_CUSTOM) {
return BISpecifier[bufferedImageType];
return getSpecifier(bufferedImageType);
}
}
@ -1225,4 +1112,130 @@ public class ImageTypeSpecifier {
public int hashCode() {
return (9 * colorModel.hashCode()) + (14 * sampleModel.hashCode());
}
private static ImageTypeSpecifier getSpecifier(int type) {
if (BISpecifier[type] == null) {
BISpecifier[type] = createSpecifier(type);
}
return BISpecifier[type];
}
private static ImageTypeSpecifier createSpecifier(int type) {
switch(type) {
case BufferedImage.TYPE_INT_RGB:
return createPacked(sRGB,
0x00ff0000,
0x0000ff00,
0x000000ff,
0x0,
DataBuffer.TYPE_INT,
false);
case BufferedImage.TYPE_INT_ARGB:
return createPacked(sRGB,
0x00ff0000,
0x0000ff00,
0x000000ff,
0xff000000,
DataBuffer.TYPE_INT,
false);
case BufferedImage.TYPE_INT_ARGB_PRE:
return createPacked(sRGB,
0x00ff0000,
0x0000ff00,
0x000000ff,
0xff000000,
DataBuffer.TYPE_INT,
true);
case BufferedImage.TYPE_INT_BGR:
return createPacked(sRGB,
0x000000ff,
0x0000ff00,
0x00ff0000,
0x0,
DataBuffer.TYPE_INT,
false);
case BufferedImage.TYPE_3BYTE_BGR:
return createInterleaved(sRGB,
new int[] { 2, 1, 0 },
DataBuffer.TYPE_BYTE,
false,
false);
case BufferedImage.TYPE_4BYTE_ABGR:
return createInterleaved(sRGB,
new int[] { 3, 2, 1, 0 },
DataBuffer.TYPE_BYTE,
true,
false);
case BufferedImage.TYPE_4BYTE_ABGR_PRE:
return createInterleaved(sRGB,
new int[] { 3, 2, 1, 0 },
DataBuffer.TYPE_BYTE,
true,
true);
case BufferedImage.TYPE_USHORT_565_RGB:
return createPacked(sRGB,
0xF800,
0x07E0,
0x001F,
0x0,
DataBuffer.TYPE_USHORT,
false);
case BufferedImage.TYPE_USHORT_555_RGB:
return createPacked(sRGB,
0x7C00,
0x03E0,
0x001F,
0x0,
DataBuffer.TYPE_USHORT,
false);
case BufferedImage.TYPE_BYTE_GRAY:
return createGrayscale(8,
DataBuffer.TYPE_BYTE,
false);
case BufferedImage.TYPE_USHORT_GRAY:
return createGrayscale(16,
DataBuffer.TYPE_USHORT,
false);
case BufferedImage.TYPE_BYTE_BINARY:
return createGrayscale(1,
DataBuffer.TYPE_BYTE,
false);
case BufferedImage.TYPE_BYTE_INDEXED:
{
BufferedImage bi =
new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED);
IndexColorModel icm = (IndexColorModel)bi.getColorModel();
int mapSize = icm.getMapSize();
byte[] redLUT = new byte[mapSize];
byte[] greenLUT = new byte[mapSize];
byte[] blueLUT = new byte[mapSize];
byte[] alphaLUT = new byte[mapSize];
icm.getReds(redLUT);
icm.getGreens(greenLUT);
icm.getBlues(blueLUT);
icm.getAlphas(alphaLUT);
return createIndexed(redLUT, greenLUT, blueLUT, alphaLUT,
8,
DataBuffer.TYPE_BYTE);
}
default:
throw new IllegalArgumentException("Invalid BufferedImage type!");
}
}
}

View File

@ -242,8 +242,12 @@ public interface IIOMetadataFormat {
/**
* A constant returned by <code>getAttributeDataType</code>
* indicating that the value of an attribute is one of 'true' or
* 'false'.
* indicating that the value of an attribute is one of the boolean
* values 'true' or 'false'.
* Attribute values of type DATATYPE_BOOLEAN should be marked as
* enumerations, and the permitted values should be the string
* literal values "TRUE" or "FALSE", although a plugin may also
* recognise lower or mixed case equivalents.
*/
int DATATYPE_BOOLEAN = 1;

View File

@ -98,7 +98,7 @@ public abstract class FontConfiguration {
if (!inited) {
this.preferLocaleFonts = false;
this.preferPropFonts = false;
fontConfig = this; /* static initialization */
setFontConfiguration();
readFontConfigFile(fontConfigFile);
initFontConfig();
inited = true;
@ -1244,6 +1244,10 @@ public abstract class FontConfiguration {
return fontConfig;
}
protected void setFontConfiguration() {
fontConfig = this; /* static initialization */
}
//////////////////////////////////////////////////////////////////////
// FontConfig data tables and the index constants in binary file //
//////////////////////////////////////////////////////////////////////

View File

@ -26,6 +26,7 @@
package sun.font;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
@ -842,8 +843,36 @@ public class FileFontStrike extends PhysicalStrike {
return fileFont.getGlyphOutlineBounds(pScalerContext, glyphCode);
}
private
WeakReference<ConcurrentHashMap<Integer,GeneralPath>> outlineMapRef;
GeneralPath getGlyphOutline(int glyphCode, float x, float y) {
return fileFont.getGlyphOutline(pScalerContext, glyphCode, x, y);
GeneralPath gp = null;
ConcurrentHashMap<Integer, GeneralPath> outlineMap = null;
if (outlineMapRef != null) {
outlineMap = outlineMapRef.get();
if (outlineMap != null) {
gp = (GeneralPath)outlineMap.get(glyphCode);
}
}
if (gp == null) {
gp = fileFont.getGlyphOutline(pScalerContext, glyphCode, 0, 0);
if (outlineMap == null) {
outlineMap = new ConcurrentHashMap<Integer, GeneralPath>();
outlineMapRef =
new WeakReference
<ConcurrentHashMap<Integer,GeneralPath>>(outlineMap);
}
outlineMap.put(glyphCode, gp);
}
gp = (GeneralPath)gp.clone(); // mutable!
if (x != 0f || y != 0f) {
gp.transform(AffineTransform.getTranslateInstance(x, y));
}
return gp;
}
GeneralPath getGlyphVectorOutline(int[] glyphs, float x, float y) {

View File

@ -1601,18 +1601,27 @@ public final class FontManager {
/* Path may be absolute or a base file name relative to one of
* the platform font directories
*/
private static String getPathName(String s) {
private static String getPathName(final String s) {
File f = new File(s);
if (f.isAbsolute()) {
return s;
} else if (pathDirs.length==1) {
return pathDirs[0] + File.separator + s;
} else {
for (int p=0; p<pathDirs.length; p++) {
f = new File(pathDirs[p] + File.separator + s);
if (f.exists()) {
return f.getAbsolutePath();
}
String path = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<String>() {
public String run() {
for (int p=0; p<pathDirs.length; p++) {
File f = new File(pathDirs[p] +File.separator+ s);
if (f.exists()) {
return f.getAbsolutePath();
}
}
return null;
}
});
if (path != null) {
return path;
}
}
return s; // shouldn't happen, but harmless

View File

@ -338,6 +338,8 @@ public final class GlyphLayout {
cache = new ConcurrentHashMap<SDKey, SDCache>(10);
cacheRef = new
SoftReference<ConcurrentHashMap<SDKey, SDCache>>(cache);
} else if (cache.size() >= 512) {
cache.clear();
}
cache.put(key, res);
}

View File

@ -232,6 +232,16 @@ public final class StrikeCache {
if (disposer.pScalerContext != 0L) {
freeLongMemory(new long[0], disposer.pScalerContext);
}
} else if (disposer.pScalerContext != 0L) {
/* Rarely a strike may have been created that never cached
* any glyphs. In this case we still want to free the scaler
* context.
*/
if (FontManager.longAddresses) {
freeLongMemory(new long[0], disposer.pScalerContext);
} else {
freeIntMemory(new int[0], disposer.pScalerContext);
}
}
}

View File

@ -25,6 +25,7 @@
package sun.java2d.cmm;
import java.awt.color.ProfileDataException;
/**
* An interface to allow the ProfileDeferralMgr to activate a
@ -35,6 +36,6 @@ public interface ProfileActivator {
/**
* Activate a previously deferred ICC_Profile object.
*/
public void activate();
public void activate() throws ProfileDataException;
}

View File

@ -25,6 +25,7 @@
package sun.java2d.cmm;
import java.awt.color.ProfileDataException;
import java.util.Vector;
@ -39,7 +40,7 @@ import java.util.Vector;
public class ProfileDeferralMgr {
public static boolean deferring = true;
private static Vector aVector;
private static Vector<ProfileActivator> aVector;
/**
* Records a ProfileActivator object whose activate method will
@ -51,7 +52,7 @@ public class ProfileDeferralMgr {
return;
}
if (aVector == null) {
aVector = new Vector(3, 3);
aVector = new Vector<ProfileActivator>(3, 3);
}
aVector.addElement(pa);
return;
@ -89,8 +90,26 @@ public class ProfileDeferralMgr {
return;
}
n = aVector.size();
for (i = 0; i < n; i++) {
((ProfileActivator) aVector.get(i)).activate();
for (ProfileActivator pa : aVector) {
try {
pa.activate();
} catch (ProfileDataException e) {
/*
* Ignore profile activation error for now:
* such exception is pssible due to absence
* or corruption of standard color profile.
* As for now we expect all profiles should
* be shiped with jre and presence of this
* exception is indication of some configuration
* problem in jre installation.
*
* NB: we still are greedy loading deferred profiles
* and load them all if any of them is needed.
* Therefore broken profile (if any) might be never used.
* If there will be attempt to use broken profile then
* it will result in CMMException.
*/
}
}
aVector.removeAllElements();
aVector = null;

View File

@ -120,7 +120,7 @@ public class Dasher extends LineSink {
// Normalize so 0 <= phase < dash[0]
int idx = 0;
dashOn = false;
dashOn = true;
int d;
while (phase >= (d = dash[idx])) {
phase -= d;

View File

@ -245,6 +245,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
FloatToS15_16(coords[1]));
break;
case PathIterator.SEG_CLOSE:
lsink.lineJoin();
lsink.close();
break;
default:

View File

@ -31,9 +31,9 @@ import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.Properties;
import java.util.Enumeration;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
import java.lang.management.ManagementFactory;
@ -41,7 +41,6 @@ import java.lang.reflect.Method;
import javax.management.remote.JMXConnectorServer;
import sun.management.snmp.AdaptorBootstrap;
import sun.management.jmxremote.ConnectorBootstrap;
import static sun.management.AgentConfigurationError.*;
import sun.misc.VMSupport;
@ -69,6 +68,9 @@ public class Agent {
private static final String LOCAL_CONNECTOR_ADDRESS_PROP =
"com.sun.management.jmxremote.localConnectorAddress";
private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME =
"sun.management.snmp.AdaptorBootstrap";
// invoked by -javaagent or -Dcom.sun.management.agent.class
public static void premain(String args) throws Exception {
agentmain(args);
@ -128,7 +130,7 @@ public class Agent {
try {
if (snmpPort != null) {
AdaptorBootstrap.initialize(snmpPort, props);
loadSnmpAgent(snmpPort, props);
}
/*
@ -204,6 +206,36 @@ public class Agent {
return mgmtProps;
}
private static void loadSnmpAgent(String snmpPort, Properties props) {
try {
// invoke the following through reflection:
// AdaptorBootstrap.initialize(snmpPort, props);
final Class<?> adaptorClass =
Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME,true,null);
final Method initializeMethod =
adaptorClass.getMethod("initialize",
String.class, Properties.class);
initializeMethod.invoke(null,snmpPort,props);
} catch (ClassNotFoundException x) {
// The SNMP packages are not present: throws an exception.
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
} catch (NoSuchMethodException x) {
// should not happen...
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
} catch (InvocationTargetException x) {
final Throwable cause = x.getCause();
if (cause instanceof RuntimeException)
throw (RuntimeException) cause;
else if (cause instanceof Error)
throw (Error) cause;
// should not happen...
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,cause);
} catch (IllegalAccessException x) {
// should not happen...
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
}
}
// read config file and initialize the properties
private static void readConfiguration(String fname, Properties p) {
if (fname == null) {

View File

@ -978,15 +978,6 @@ public class FormattedFloatingDecimal{
return new String(result);
}
// This method should only ever be called if this object is constructed
// without Form.DECIMAL_FLOAT because the perThreadBuffer is not large
// enough to handle floating-point numbers of large precision.
public String toJavaFormatString() {
char result[] = (char[])(perThreadBuffer.get());
int i = getChars(result);
return new String(result, 0, i);
}
// returns the exponent before rounding
public int getExponent() {
return decExponent - 1;
@ -1157,265 +1148,6 @@ public class FormattedFloatingDecimal{
}
};
// This method should only ever be called if this object is constructed
// without Form.DECIMAL_FLOAT because the perThreadBuffer is not large
// enough to handle floating-point numbers of large precision.
public void appendTo(Appendable buf) {
char result[] = (char[])(perThreadBuffer.get());
int i = getChars(result);
if (buf instanceof StringBuilder)
((StringBuilder) buf).append(result, 0, i);
else if (buf instanceof StringBuffer)
((StringBuffer) buf).append(result, 0, i);
else
assert false;
}
public static FormattedFloatingDecimal
readJavaFormatString( String in ) throws NumberFormatException {
boolean isNegative = false;
boolean signSeen = false;
int decExp;
char c;
parseNumber:
try{
in = in.trim(); // don't fool around with white space.
// throws NullPointerException if null
int l = in.length();
if ( l == 0 ) throw new NumberFormatException("empty String");
int i = 0;
switch ( c = in.charAt( i ) ){
case '-':
isNegative = true;
//FALLTHROUGH
case '+':
i++;
signSeen = true;
}
// Check for NaN and Infinity strings
c = in.charAt(i);
if(c == 'N' || c == 'I') { // possible NaN or infinity
boolean potentialNaN = false;
char targetChars[] = null; // char arrary of "NaN" or "Infinity"
if(c == 'N') {
targetChars = notANumber;
potentialNaN = true;
} else {
targetChars = infinity;
}
// compare Input string to "NaN" or "Infinity"
int j = 0;
while(i < l && j < targetChars.length) {
if(in.charAt(i) == targetChars[j]) {
i++; j++;
}
else // something is amiss, throw exception
break parseNumber;
}
// For the candidate string to be a NaN or infinity,
// all characters in input string and target char[]
// must be matched ==> j must equal targetChars.length
// and i must equal l
if( (j == targetChars.length) && (i == l) ) { // return NaN or infinity
return (potentialNaN ? new FormattedFloatingDecimal(Double.NaN) // NaN has no sign
: new FormattedFloatingDecimal(isNegative?
Double.NEGATIVE_INFINITY:
Double.POSITIVE_INFINITY)) ;
}
else { // something went wrong, throw exception
break parseNumber;
}
} else if (c == '0') { // check for hexadecimal floating-point number
if (l > i+1 ) {
char ch = in.charAt(i+1);
if (ch == 'x' || ch == 'X' ) // possible hex string
return parseHexString(in);
}
} // look for and process decimal floating-point string
char[] digits = new char[ l ];
int nDigits= 0;
boolean decSeen = false;
int decPt = 0;
int nLeadZero = 0;
int nTrailZero= 0;
digitLoop:
while ( i < l ){
switch ( c = in.charAt( i ) ){
case '0':
if ( nDigits > 0 ){
nTrailZero += 1;
} else {
nLeadZero += 1;
}
break; // out of switch.
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
while ( nTrailZero > 0 ){
digits[nDigits++] = '0';
nTrailZero -= 1;
}
digits[nDigits++] = c;
break; // out of switch.
case '.':
if ( decSeen ){
// already saw one ., this is the 2nd.
throw new NumberFormatException("multiple points");
}
decPt = i;
if ( signSeen ){
decPt -= 1;
}
decSeen = true;
break; // out of switch.
default:
break digitLoop;
}
i++;
}
/*
* At this point, we've scanned all the digits and decimal
* point we're going to see. Trim off leading and trailing
* zeros, which will just confuse us later, and adjust
* our initial decimal exponent accordingly.
* To review:
* we have seen i total characters.
* nLeadZero of them were zeros before any other digits.
* nTrailZero of them were zeros after any other digits.
* if ( decSeen ), then a . was seen after decPt characters
* ( including leading zeros which have been discarded )
* nDigits characters were neither lead nor trailing
* zeros, nor point
*/
/*
* special hack: if we saw no non-zero digits, then the
* answer is zero!
* Unfortunately, we feel honor-bound to keep parsing!
*/
if ( nDigits == 0 ){
digits = zero;
nDigits = 1;
if ( nLeadZero == 0 ){
// we saw NO DIGITS AT ALL,
// not even a crummy 0!
// this is not allowed.
break parseNumber; // go throw exception
}
}
/* Our initial exponent is decPt, adjusted by the number of
* discarded zeros. Or, if there was no decPt,
* then its just nDigits adjusted by discarded trailing zeros.
*/
if ( decSeen ){
decExp = decPt - nLeadZero;
} else {
decExp = nDigits+nTrailZero;
}
/*
* Look for 'e' or 'E' and an optionally signed integer.
*/
if ( (i < l) && (((c = in.charAt(i) )=='e') || (c == 'E') ) ){
int expSign = 1;
int expVal = 0;
int reallyBig = Integer.MAX_VALUE / 10;
boolean expOverflow = false;
switch( in.charAt(++i) ){
case '-':
expSign = -1;
//FALLTHROUGH
case '+':
i++;
}
int expAt = i;
expLoop:
while ( i < l ){
if ( expVal >= reallyBig ){
// the next character will cause integer
// overflow.
expOverflow = true;
}
switch ( c = in.charAt(i++) ){
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
expVal = expVal*10 + ( (int)c - (int)'0' );
continue;
default:
i--; // back up.
break expLoop; // stop parsing exponent.
}
}
int expLimit = bigDecimalExponent+nDigits+nTrailZero;
if ( expOverflow || ( expVal > expLimit ) ){
//
// The intent here is to end up with
// infinity or zero, as appropriate.
// The reason for yielding such a small decExponent,
// rather than something intuitive such as
// expSign*Integer.MAX_VALUE, is that this value
// is subject to further manipulation in
// doubleValue() and floatValue(), and I don't want
// it to be able to cause overflow there!
// (The only way we can get into trouble here is for
// really outrageous nDigits+nTrailZero, such as 2 billion. )
//
decExp = expSign*expLimit;
} else {
// this should not overflow, since we tested
// for expVal > (MAX+N), where N >= abs(decExp)
decExp = decExp + expSign*expVal;
}
// if we saw something not a digit ( or end of string )
// after the [Ee][+-], without seeing any digits at all
// this is certainly an error. If we saw some digits,
// but then some trailing garbage, that might be ok.
// so we just fall through in that case.
// HUMBUG
if ( i == expAt )
break parseNumber; // certainly bad
}
/*
* We parsed everything we could.
* If there are leftovers, then this is not good input!
*/
if ( i < l &&
((i != l - 1) ||
(in.charAt(i) != 'f' &&
in.charAt(i) != 'F' &&
in.charAt(i) != 'd' &&
in.charAt(i) != 'D'))) {
break parseNumber; // go throw exception
}
return new FormattedFloatingDecimal( isNegative, decExp, digits, nDigits, false, Integer.MAX_VALUE, Form.COMPATIBLE );
} catch ( StringIndexOutOfBoundsException e ){ }
throw new NumberFormatException("For input string: \"" + in + "\"");
}
/*
* Take a FormattedFloatingDecimal, which we presumably just scanned in,
* and find out what its value is, as a double.
@ -2035,548 +1767,4 @@ public class FormattedFloatingDecimal{
private static final char infinity[] = { 'I', 'n', 'f', 'i', 'n', 'i', 't', 'y' };
private static final char notANumber[] = { 'N', 'a', 'N' };
private static final char zero[] = { '0', '0', '0', '0', '0', '0', '0', '0' };
/*
* Grammar is compatible with hexadecimal floating-point constants
* described in section 6.4.4.2 of the C99 specification.
*/
private static Pattern hexFloatPattern = Pattern.compile(
//1 234 56 7 8 9
"([-+])?0[xX](((\\p{XDigit}+)\\.?)|((\\p{XDigit}*)\\.(\\p{XDigit}+)))[pP]([-+])?(\\p{Digit}+)[fFdD]?"
);
/*
* Convert string s to a suitable floating decimal; uses the
* double constructor and set the roundDir variable appropriately
* in case the value is later converted to a float.
*/
static FormattedFloatingDecimal parseHexString(String s) {
// Verify string is a member of the hexadecimal floating-point
// string language.
Matcher m = hexFloatPattern.matcher(s);
boolean validInput = m.matches();
if (!validInput) {
// Input does not match pattern
throw new NumberFormatException("For input string: \"" + s + "\"");
} else { // validInput
/*
* We must isolate the sign, significand, and exponent
* fields. The sign value is straightforward. Since
* floating-point numbers are stored with a normalized
* representation, the significand and exponent are
* interrelated.
*
* After extracting the sign, we normalized the
* significand as a hexadecimal value, calculating an
* exponent adjust for any shifts made during
* normalization. If the significand is zero, the
* exponent doesn't need to be examined since the output
* will be zero.
*
* Next the exponent in the input string is extracted.
* Afterwards, the significand is normalized as a *binary*
* value and the input value's normalized exponent can be
* computed. The significand bits are copied into a
* double significand; if the string has more logical bits
* than can fit in a double, the extra bits affect the
* round and sticky bits which are used to round the final
* value.
*/
// Extract significand sign
String group1 = m.group(1);
double sign = (( group1 == null ) || group1.equals("+"))? 1.0 : -1.0;
// Extract Significand magnitude
/*
* Based on the form of the significand, calculate how the
* binary exponent needs to be adjusted to create a
* normalized *hexadecimal* floating-point number; that
* is, a number where there is one nonzero hex digit to
* the left of the (hexa)decimal point. Since we are
* adjusting a binary, not hexadecimal exponent, the
* exponent is adjusted by a multiple of 4.
*
* There are a number of significand scenarios to consider;
* letters are used in indicate nonzero digits:
*
* 1. 000xxxx => x.xxx normalized
* increase exponent by (number of x's - 1)*4
*
* 2. 000xxx.yyyy => x.xxyyyy normalized
* increase exponent by (number of x's - 1)*4
*
* 3. .000yyy => y.yy normalized
* decrease exponent by (number of zeros + 1)*4
*
* 4. 000.00000yyy => y.yy normalized
* decrease exponent by (number of zeros to right of point + 1)*4
*
* If the significand is exactly zero, return a properly
* signed zero.
*/
String significandString =null;
int signifLength = 0;
int exponentAdjust = 0;
{
int leftDigits = 0; // number of meaningful digits to
// left of "decimal" point
// (leading zeros stripped)
int rightDigits = 0; // number of digits to right of
// "decimal" point; leading zeros
// must always be accounted for
/*
* The significand is made up of either
*
* 1. group 4 entirely (integer portion only)
*
* OR
*
* 2. the fractional portion from group 7 plus any
* (optional) integer portions from group 6.
*/
String group4;
if( (group4 = m.group(4)) != null) { // Integer-only significand
// Leading zeros never matter on the integer portion
significandString = stripLeadingZeros(group4);
leftDigits = significandString.length();
}
else {
// Group 6 is the optional integer; leading zeros
// never matter on the integer portion
String group6 = stripLeadingZeros(m.group(6));
leftDigits = group6.length();
// fraction
String group7 = m.group(7);
rightDigits = group7.length();
// Turn "integer.fraction" into "integer"+"fraction"
significandString =
((group6 == null)?"":group6) + // is the null
// check necessary?
group7;
}
significandString = stripLeadingZeros(significandString);
signifLength = significandString.length();
/*
* Adjust exponent as described above
*/
if (leftDigits >= 1) { // Cases 1 and 2
exponentAdjust = 4*(leftDigits - 1);
} else { // Cases 3 and 4
exponentAdjust = -4*( rightDigits - signifLength + 1);
}
// If the significand is zero, the exponent doesn't
// matter; return a properly signed zero.
if (signifLength == 0) { // Only zeros in input
return new FormattedFloatingDecimal(sign * 0.0);
}
}
// Extract Exponent
/*
* Use an int to read in the exponent value; this should
* provide more than sufficient range for non-contrived
* inputs. If reading the exponent in as an int does
* overflow, examine the sign of the exponent and
* significand to determine what to do.
*/
String group8 = m.group(8);
boolean positiveExponent = ( group8 == null ) || group8.equals("+");
long unsignedRawExponent;
try {
unsignedRawExponent = Integer.parseInt(m.group(9));
}
catch (NumberFormatException e) {
// At this point, we know the exponent is
// syntactically well-formed as a sequence of
// digits. Therefore, if an NumberFormatException
// is thrown, it must be due to overflowing int's
// range. Also, at this point, we have already
// checked for a zero significand. Thus the signs
// of the exponent and significand determine the
// final result:
//
// significand
// + -
// exponent + +infinity -infinity
// - +0.0 -0.0
return new FormattedFloatingDecimal(sign * (positiveExponent ?
Double.POSITIVE_INFINITY : 0.0));
}
long rawExponent =
(positiveExponent ? 1L : -1L) * // exponent sign
unsignedRawExponent; // exponent magnitude
// Calculate partially adjusted exponent
long exponent = rawExponent + exponentAdjust ;
// Starting copying non-zero bits into proper position in
// a long; copy explicit bit too; this will be masked
// later for normal values.
boolean round = false;
boolean sticky = false;
int bitsCopied=0;
int nextShift=0;
long significand=0L;
// First iteration is different, since we only copy
// from the leading significand bit; one more exponent
// adjust will be needed...
// IMPORTANT: make leadingDigit a long to avoid
// surprising shift semantics!
long leadingDigit = getHexDigit(significandString, 0);
/*
* Left shift the leading digit (53 - (bit position of
* leading 1 in digit)); this sets the top bit of the
* significand to 1. The nextShift value is adjusted
* to take into account the number of bit positions of
* the leadingDigit actually used. Finally, the
* exponent is adjusted to normalize the significand
* as a binary value, not just a hex value.
*/
if (leadingDigit == 1) {
significand |= leadingDigit << 52;
nextShift = 52 - 4;
/* exponent += 0 */ }
else if (leadingDigit <= 3) { // [2, 3]
significand |= leadingDigit << 51;
nextShift = 52 - 5;
exponent += 1;
}
else if (leadingDigit <= 7) { // [4, 7]
significand |= leadingDigit << 50;
nextShift = 52 - 6;
exponent += 2;
}
else if (leadingDigit <= 15) { // [8, f]
significand |= leadingDigit << 49;
nextShift = 52 - 7;
exponent += 3;
} else {
throw new AssertionError("Result from digit converstion too large!");
}
// The preceding if-else could be replaced by a single
// code block based on the high-order bit set in
// leadingDigit. Given leadingOnePosition,
// significand |= leadingDigit << (SIGNIFICAND_WIDTH - leadingOnePosition);
// nextShift = 52 - (3 + leadingOnePosition);
// exponent += (leadingOnePosition-1);
/*
* Now the exponent variable is equal to the normalized
* binary exponent. Code below will make representation
* adjustments if the exponent is incremented after
* rounding (includes overflows to infinity) or if the
* result is subnormal.
*/
// Copy digit into significand until the significand can't
// hold another full hex digit or there are no more input
// hex digits.
int i = 0;
for(i = 1;
i < signifLength && nextShift >= 0;
i++) {
long currentDigit = getHexDigit(significandString, i);
significand |= (currentDigit << nextShift);
nextShift-=4;
}
// After the above loop, the bulk of the string is copied.
// Now, we must copy any partial hex digits into the
// significand AND compute the round bit and start computing
// sticky bit.
if ( i < signifLength ) { // at least one hex input digit exists
long currentDigit = getHexDigit(significandString, i);
// from nextShift, figure out how many bits need
// to be copied, if any
switch(nextShift) { // must be negative
case -1:
// three bits need to be copied in; can
// set round bit
significand |= ((currentDigit & 0xEL) >> 1);
round = (currentDigit & 0x1L) != 0L;
break;
case -2:
// two bits need to be copied in; can
// set round and start sticky
significand |= ((currentDigit & 0xCL) >> 2);
round = (currentDigit &0x2L) != 0L;
sticky = (currentDigit & 0x1L) != 0;
break;
case -3:
// one bit needs to be copied in
significand |= ((currentDigit & 0x8L)>>3);
// Now set round and start sticky, if possible
round = (currentDigit &0x4L) != 0L;
sticky = (currentDigit & 0x3L) != 0;
break;
case -4:
// all bits copied into significand; set
// round and start sticky
round = ((currentDigit & 0x8L) != 0); // is top bit set?
// nonzeros in three low order bits?
sticky = (currentDigit & 0x7L) != 0;
break;
default:
throw new AssertionError("Unexpected shift distance remainder.");
// break;
}
// Round is set; sticky might be set.
// For the sticky bit, it suffices to check the
// current digit and test for any nonzero digits in
// the remaining unprocessed input.
i++;
while(i < signifLength && !sticky) {
currentDigit = getHexDigit(significandString,i);
sticky = sticky || (currentDigit != 0);
i++;
}
}
// else all of string was seen, round and sticky are
// correct as false.
// Check for overflow and update exponent accordingly.
if (exponent > DoubleConsts.MAX_EXPONENT) { // Infinite result
// overflow to properly signed infinity
return new FormattedFloatingDecimal(sign * Double.POSITIVE_INFINITY);
} else { // Finite return value
if (exponent <= DoubleConsts.MAX_EXPONENT && // (Usually) normal result
exponent >= DoubleConsts.MIN_EXPONENT) {
// The result returned in this block cannot be a
// zero or subnormal; however after the
// significand is adjusted from rounding, we could
// still overflow in infinity.
// AND exponent bits into significand; if the
// significand is incremented and overflows from
// rounding, this combination will update the
// exponent correctly, even in the case of
// Double.MAX_VALUE overflowing to infinity.
significand = (( ((long)exponent +
(long)DoubleConsts.EXP_BIAS) <<
(DoubleConsts.SIGNIFICAND_WIDTH-1))
& DoubleConsts.EXP_BIT_MASK) |
(DoubleConsts.SIGNIF_BIT_MASK & significand);
} else { // Subnormal or zero
// (exponent < DoubleConsts.MIN_EXPONENT)
if (exponent < (DoubleConsts.MIN_SUB_EXPONENT -1 )) {
// No way to round back to nonzero value
// regardless of significand if the exponent is
// less than -1075.
return new FormattedFloatingDecimal(sign * 0.0);
} else { // -1075 <= exponent <= MIN_EXPONENT -1 = -1023
/*
* Find bit position to round to; recompute
* round and sticky bits, and shift
* significand right appropriately.
*/
sticky = sticky || round;
round = false;
// Number of bits of significand to preserve is
// exponent - abs_min_exp +1
// check:
// -1075 +1074 + 1 = 0
// -1023 +1074 + 1 = 52
int bitsDiscarded = 53 -
((int)exponent - DoubleConsts.MIN_SUB_EXPONENT + 1);
assert bitsDiscarded >= 1 && bitsDiscarded <= 53;
// What to do here:
// First, isolate the new round bit
round = (significand & (1L << (bitsDiscarded -1))) != 0L;
if (bitsDiscarded > 1) {
// create mask to update sticky bits; low
// order bitsDiscarded bits should be 1
long mask = ~((~0L) << (bitsDiscarded -1));
sticky = sticky || ((significand & mask) != 0L ) ;
}
// Now, discard the bits
significand = significand >> bitsDiscarded;
significand = (( ((long)(DoubleConsts.MIN_EXPONENT -1) + // subnorm exp.
(long)DoubleConsts.EXP_BIAS) <<
(DoubleConsts.SIGNIFICAND_WIDTH-1))
& DoubleConsts.EXP_BIT_MASK) |
(DoubleConsts.SIGNIF_BIT_MASK & significand);
}
}
// The significand variable now contains the currently
// appropriate exponent bits too.
/*
* Determine if significand should be incremented;
* making this determination depends on the least
* significant bit and the round and sticky bits.
*
* Round to nearest even rounding table, adapted from
* table 4.7 in "Computer Arithmetic" by IsraelKoren.
* The digit to the left of the "decimal" point is the
* least significant bit, the digits to the right of
* the point are the round and sticky bits
*
* Number Round(x)
* x0.00 x0.
* x0.01 x0.
* x0.10 x0.
* x0.11 x1. = x0. +1
* x1.00 x1.
* x1.01 x1.
* x1.10 x1. + 1
* x1.11 x1. + 1
*/
boolean incremented = false;
boolean leastZero = ((significand & 1L) == 0L);
if( ( leastZero && round && sticky ) ||
((!leastZero) && round )) {
incremented = true;
significand++;
}
FormattedFloatingDecimal fd = new FormattedFloatingDecimal(FpUtils.rawCopySign(
Double.longBitsToDouble(significand),
sign));
/*
* Set roundingDir variable field of fd properly so
* that the input string can be properly rounded to a
* float value. There are two cases to consider:
*
* 1. rounding to double discards sticky bit
* information that would change the result of a float
* rounding (near halfway case between two floats)
*
* 2. rounding to double rounds up when rounding up
* would not occur when rounding to float.
*
* For former case only needs to be considered when
* the bits rounded away when casting to float are all
* zero; otherwise, float round bit is properly set
* and sticky will already be true.
*
* The lower exponent bound for the code below is the
* minimum (normalized) subnormal exponent - 1 since a
* value with that exponent can round up to the
* minimum subnormal value and the sticky bit
* information must be preserved (i.e. case 1).
*/
if ((exponent >= FloatConsts.MIN_SUB_EXPONENT-1) &&
(exponent <= FloatConsts.MAX_EXPONENT ) ){
// Outside above exponent range, the float value
// will be zero or infinity.
/*
* If the low-order 28 bits of a rounded double
* significand are 0, the double could be a
* half-way case for a rounding to float. If the
* double value is a half-way case, the double
* significand may have to be modified to round
* the the right float value (see the stickyRound
* method). If the rounding to double has lost
* what would be float sticky bit information, the
* double significand must be incremented. If the
* double value's significand was itself
* incremented, the float value may end up too
* large so the increment should be undone.
*/
if ((significand & 0xfffffffL) == 0x0L) {
// For negative values, the sign of the
// roundDir is the same as for positive values
// since adding 1 increasing the significand's
// magnitude and subtracting 1 decreases the
// significand's magnitude. If neither round
// nor sticky is true, the double value is
// exact and no adjustment is required for a
// proper float rounding.
if( round || sticky) {
if (leastZero) { // prerounding lsb is 0
// If round and sticky were both true,
// and the least significant
// significand bit were 0, the rounded
// significand would not have its
// low-order bits be zero. Therefore,
// we only need to adjust the
// significand if round XOR sticky is
// true.
if (round ^ sticky) {
fd.roundDir = 1;
}
}
else { // prerounding lsb is 1
// If the prerounding lsb is 1 and the
// resulting significand has its
// low-order bits zero, the significand
// was incremented. Here, we undo the
// increment, which will ensure the
// right guard and sticky bits for the
// float rounding.
if (round)
fd.roundDir = -1;
}
}
}
}
fd.fromHex = true;
return fd;
}
}
}
/**
* Return <code>s</code> with any leading zeros removed.
*/
static String stripLeadingZeros(String s) {
return s.replaceFirst("^0+", "");
}
/**
* Extract a hexadecimal digit from position <code>position</code>
* of string <code>s</code>.
*/
static int getHexDigit(String s, int position) {
int value = Character.digit(s.charAt(position), 16);
if (value <= -1 || value >= 16) {
throw new AssertionError("Unxpected failure of digit converstion of " +
s.charAt(position));
}
return value;
}
}

View File

@ -29,6 +29,5 @@ import java.nio.charset.Charset;
public interface JavaIOAccess {
public Console console();
public Runnable consoleRestoreHook();
public Charset charset();
}

View File

@ -54,4 +54,7 @@ public interface JavaLangAccess {
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
/** register shutdown hook */
void registerShutdownHook(int slot, Runnable r);
}

View File

@ -44,7 +44,6 @@ public class SharedSecrets {
private static JavaUtilJarAccess javaUtilJarAccess;
private static JavaLangAccess javaLangAccess;
private static JavaIOAccess javaIOAccess;
private static JavaIODeleteOnExitAccess javaIODeleteOnExitAccess;
private static JavaNetAccess javaNetAccess;
private static JavaNioAccess javaNioAccess;
private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
@ -103,17 +102,6 @@ public class SharedSecrets {
return javaIOAccess;
}
public static void setJavaIODeleteOnExitAccess(JavaIODeleteOnExitAccess jida) {
javaIODeleteOnExitAccess = jida;
}
public static JavaIODeleteOnExitAccess getJavaIODeleteOnExitAccess() {
if (javaIODeleteOnExitAccess == null) {
unsafe.ensureClassInitialized(File.class);
}
return javaIODeleteOnExitAccess;
}
public static void setJavaIOFileDescriptorAccess(JavaIOFileDescriptorAccess jiofda) {
javaIOFileDescriptorAccess = jiofda;
}

View File

@ -0,0 +1,35 @@
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.nio.cs;
/*
* FastPath byte[]->char[] decoder, REPLACE on malformed or
* unmappable input.
*/
public interface ArrayDecoder {
int decode(byte[] src, int off, int len, char[] dst);
}

View File

@ -0,0 +1,35 @@
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.nio.cs;
/*
* FastPath char[]->byte[] encoder, REPLACE on malformed input or
* unmappable input.
*/
public interface ArrayEncoder {
int encode(char[] src, int off, int len, byte[] dst);
}

View File

@ -23,9 +23,6 @@
* have any questions.
*/
/*
*/
package sun.nio.cs;
import java.nio.ByteBuffer;
@ -34,10 +31,7 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.MalformedInputException;
import java.nio.charset.UnmappableCharacterException;
import java.util.Arrays;
class ISO_8859_1
extends Charset
@ -65,8 +59,8 @@ class ISO_8859_1
return new Encoder(this);
}
private static class Decoder extends CharsetDecoder {
private static class Decoder extends CharsetDecoder
implements ArrayDecoder {
private Decoder(Charset cs) {
super(cs, 1.0f, 1.0f);
}
@ -127,10 +121,18 @@ class ISO_8859_1
return decodeBufferLoop(src, dst);
}
public int decode(byte[] src, int sp, int len, char[] dst) {
if (len > dst.length)
len = dst.length;
int dp = 0;
while (dp < len)
dst[dp++] = (char)(src[sp++] & 0xff);
return dp;
}
}
private static class Encoder extends CharsetEncoder {
private static class Encoder extends CharsetEncoder
implements ArrayEncoder {
private Encoder(Charset cs) {
super(cs, 1.0f, 1.0f);
}
@ -139,6 +141,10 @@ class ISO_8859_1
return c <= '\u00FF';
}
public boolean isLegalReplacement(byte[] repl) {
return (repl.length == 1); // we accept any byte value
}
private final Surrogate.Parser sgp = new Surrogate.Parser();
private CoderResult encodeArrayLoop(CharBuffer src,
@ -208,5 +214,31 @@ class ISO_8859_1
return encodeBufferLoop(src, dst);
}
private byte repl = (byte)'?';
protected void implReplaceWith(byte[] newReplacement) {
repl = newReplacement[0];
}
public int encode(char[] src, int sp, int len, byte[] dst) {
int dp = 0;
int sl = sp + Math.min(len, dst.length);
while (sp < sl) {
char c = src[sp++];
if (c <= '\u00FF') {
dst[dp++] = (byte)c;
continue;
}
if (Surrogate.isHigh(c) && sp < sl &&
Surrogate.isLow(src[sp])) {
if (len > dst.length) {
sl++;
len--;
}
sp++;
}
dst[dp++] = repl;
}
return dp;
}
}
}

View File

@ -32,6 +32,7 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.util.Arrays;
import static sun.nio.cs.CharsetMapping.*;
public class SingleByte
@ -45,7 +46,8 @@ public class SingleByte
return cr;
}
public static class Decoder extends CharsetDecoder {
final public static class Decoder extends CharsetDecoder
implements ArrayDecoder {
private final char[] b2c;
public Decoder(Charset cs, char[] b2c) {
@ -108,9 +110,29 @@ public class SingleByte
private final char decode(int b) {
return b2c[b + 128];
}
private char repl = '\uFFFD';
protected void implReplaceWith(String newReplacement) {
repl = newReplacement.charAt(0);
}
public int decode(byte[] src, int sp, int len, char[] dst) {
if (len > dst.length)
len = dst.length;
int dp = 0;
while (dp < len) {
dst[dp] = decode(src[sp++]);
if (dst[dp] == UNMAPPABLE_DECODING) {
dst[dp] = repl;
}
dp++;
}
return dp;
}
}
public static class Encoder extends CharsetEncoder {
final public static class Encoder extends CharsetEncoder
implements ArrayEncoder {
private Surrogate.Parser sgp;
private final char[] c2b;
private final char[] c2bIndex;
@ -125,6 +147,11 @@ public class SingleByte
return encode(c) != UNMAPPABLE_ENCODING;
}
public boolean isLegalReplacement(byte[] repl) {
return ((repl.length == 1 && repl[0] == (byte)'?') ||
super.isLegalReplacement(repl));
}
private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
char[] sa = src.array();
int sp = src.arrayOffset() + src.position();
@ -200,6 +227,34 @@ public class SingleByte
return UNMAPPABLE_ENCODING;
return c2b[index + (ch & 0xff)];
}
private byte repl = (byte)'?';
protected void implReplaceWith(byte[] newReplacement) {
repl = newReplacement[0];
}
public int encode(char[] src, int sp, int len, byte[] dst) {
int dp = 0;
int sl = sp + Math.min(len, dst.length);
while (sp < sl) {
char c = src[sp++];
int b = encode(c);
if (b != UNMAPPABLE_ENCODING) {
dst[dp++] = (byte)b;
continue;
}
if (Surrogate.isHigh(c) && sp < sl &&
Surrogate.isLow(src[sp])) {
if (len > dst.length) {
sl++;
len--;
}
sp++;
}
dst[dp++] = repl;
}
return dp;
}
}
// init the c2b and c2bIndex tables from b2c.

View File

@ -31,10 +31,7 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.MalformedInputException;
import java.nio.charset.UnmappableCharacterException;
import java.util.Arrays;
public class US_ASCII
extends Charset
@ -61,7 +58,8 @@ public class US_ASCII
return new Encoder(this);
}
private static class Decoder extends CharsetDecoder {
private static class Decoder extends CharsetDecoder
implements ArrayDecoder {
private Decoder(Charset cs) {
super(cs, 1.0f, 1.0f);
@ -131,9 +129,27 @@ public class US_ASCII
return decodeBufferLoop(src, dst);
}
private char repl = '\uFFFD';
protected void implReplaceWith(String newReplacement) {
repl = newReplacement.charAt(0);
}
public int decode(byte[] src, int sp, int len, char[] dst) {
int dp = 0;
len = Math.min(len, dst.length);
while (dp < len) {
byte b = src[sp++];
if (b >= 0)
dst[dp++] = (char)b;
else
dst[dp++] = repl;
}
return dp;
}
}
private static class Encoder extends CharsetEncoder {
private static class Encoder extends CharsetEncoder
implements ArrayEncoder {
private Encoder(Charset cs) {
super(cs, 1.0f, 1.0f);
@ -143,8 +159,11 @@ public class US_ASCII
return c < 0x80;
}
private final Surrogate.Parser sgp = new Surrogate.Parser();
public boolean isLegalReplacement(byte[] repl) {
return (repl.length == 1 && repl[0] >= 0);
}
private final Surrogate.Parser sgp = new Surrogate.Parser();
private CoderResult encodeArrayLoop(CharBuffer src,
ByteBuffer dst)
{
@ -213,6 +232,32 @@ public class US_ASCII
return encodeBufferLoop(src, dst);
}
private byte repl = (byte)'?';
protected void implReplaceWith(byte[] newReplacement) {
repl = newReplacement[0];
}
public int encode(char[] src, int sp, int len, byte[] dst) {
int dp = 0;
int sl = sp + Math.min(len, dst.length);
while (sp < sl) {
char c = src[sp++];
if (c < 0x80) {
dst[dp++] = (byte)c;
continue;
}
if (Surrogate.isHigh(c) && sp < sl &&
Surrogate.isLow(src[sp])) {
if (len > dst.length) {
sl++;
len--;
}
sp++;
}
dst[dp++] = repl;
}
return dp;
}
}
}

View File

@ -2149,55 +2149,51 @@ public class ServiceDialog extends JDialog implements ActionListener {
}
}
}
}
rbPortrait.setEnabled(pSupported);
rbLandscape.setEnabled(lSupported);
rbRevPortrait.setEnabled(rpSupported);
rbRevLandscape.setEnabled(rlSupported);
OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory);
if (or == null ||
!psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) {
rbPortrait.setEnabled(pSupported);
rbLandscape.setEnabled(lSupported);
rbRevPortrait.setEnabled(rpSupported);
rbRevLandscape.setEnabled(rlSupported);
or = (OrientationRequested)psCurrent.getDefaultAttributeValue(orCategory);
// need to validate if default is not supported
if (!psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) {
or = null;
values =
psCurrent.getSupportedAttributeValues(orCategory,
docFlavor,
asCurrent);
if (values instanceof OrientationRequested[]) {
OrientationRequested[] orValues =
(OrientationRequested[])values;
if (orValues.length > 1) {
// get the first in the list
or = orValues[0];
}
OrientationRequested or = (OrientationRequested)asCurrent.get(orCategory);
if (or == null ||
!psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) {
or = (OrientationRequested)psCurrent.getDefaultAttributeValue(orCategory);
// need to validate if default is not supported
if ((or != null) &&
!psCurrent.isAttributeValueSupported(or, docFlavor, asCurrent)) {
or = null;
Object values =
psCurrent.getSupportedAttributeValues(orCategory,
docFlavor,
asCurrent);
if (values instanceof OrientationRequested[]) {
OrientationRequested[] orValues =
(OrientationRequested[])values;
if (orValues.length > 1) {
// get the first in the list
or = orValues[0];
}
}
if (or == null) {
or = OrientationRequested.PORTRAIT;
}
asCurrent.add(or);
}
if (or == OrientationRequested.PORTRAIT) {
rbPortrait.setSelected(true);
} else if (or == OrientationRequested.LANDSCAPE) {
rbLandscape.setSelected(true);
} else if (or == OrientationRequested.REVERSE_PORTRAIT) {
rbRevPortrait.setSelected(true);
} else { // if (or == OrientationRequested.REVERSE_LANDSCAPE)
rbRevLandscape.setSelected(true);
if (or == null) {
or = OrientationRequested.PORTRAIT;
}
} else {
rbPortrait.setEnabled(pSupported);
rbLandscape.setEnabled(lSupported);
rbRevPortrait.setEnabled(rpSupported);
rbRevLandscape.setEnabled(rlSupported);
asCurrent.add(or);
}
if (or == OrientationRequested.PORTRAIT) {
rbPortrait.setSelected(true);
} else if (or == OrientationRequested.LANDSCAPE) {
rbLandscape.setSelected(true);
} else if (or == OrientationRequested.REVERSE_PORTRAIT) {
rbRevPortrait.setSelected(true);
} else { // if (or == OrientationRequested.REVERSE_LANDSCAPE)
rbRevLandscape.setSelected(true);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2005-2009 Sun Microsystems, Inc. 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
@ -66,11 +66,11 @@ public class NegTokenInit extends SpNegoToken {
private byte[] mechTypes = null;
private Oid[] mechTypeList = null;
private byte[] reqFlags = null;
private BitArray reqFlags = null;
private byte[] mechToken = null;
private byte[] mechListMIC = null;
NegTokenInit(byte[] mechTypes, byte[] flags,
NegTokenInit(byte[] mechTypes, BitArray flags,
byte[] token, byte[] mechListMIC)
{
super(NEG_TOKEN_INIT_ID);
@ -101,7 +101,7 @@ public class NegTokenInit extends SpNegoToken {
// write context flags with CONTEXT 01
if (reqFlags != null) {
DerOutputStream flags = new DerOutputStream();
flags.putBitString(reqFlags);
flags.putUnalignedBitString(reqFlags);
initToken.write(DerValue.createTag(DerValue.TAG_CONTEXT,
true, (byte) 0x01), flags);
}
@ -237,7 +237,7 @@ public class NegTokenInit extends SpNegoToken {
return mechTypeList;
}
byte[] getReqFlags() {
BitArray getReqFlags() {
return reqFlags;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2005-2009 Sun Microsystems, Inc. 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
@ -53,13 +53,6 @@ public class SpNegoContext implements GSSContextSpi {
private int state = STATE_NEW;
private static final int CHECKSUM_DELEG_FLAG = 1;
private static final int CHECKSUM_MUTUAL_FLAG = 2;
private static final int CHECKSUM_REPLAY_FLAG = 4;
private static final int CHECKSUM_SEQUENCE_FLAG = 8;
private static final int CHECKSUM_CONF_FLAG = 16;
private static final int CHECKSUM_INTEG_FLAG = 32;
/*
* Optional features that the application can set and their default
* values.
@ -697,25 +690,17 @@ public class SpNegoContext implements GSSContextSpi {
/**
* get the context flags
*/
private byte[] getContextFlags() {
int flags = 0;
private BitArray getContextFlags() {
BitArray out = new BitArray(7);
if (getCredDelegState())
flags |= CHECKSUM_DELEG_FLAG;
if (getMutualAuthState())
flags |= CHECKSUM_MUTUAL_FLAG;
if (getReplayDetState())
flags |= CHECKSUM_REPLAY_FLAG;
if (getSequenceDetState())
flags |= CHECKSUM_SEQUENCE_FLAG;
if (getIntegState())
flags |= CHECKSUM_INTEG_FLAG;
if (getConfState())
flags |= CHECKSUM_CONF_FLAG;
if (getCredDelegState()) out.set(0, true);
if (getMutualAuthState()) out.set(1, true);
if (getReplayDetState()) out.set(2, true);
if (getSequenceDetState()) out.set(3, true);
if (getConfState()) out.set(5, true);
if (getIntegState()) out.set(6, true);
byte[] temp = new byte[1];
temp[0] = (byte)(flags & 0xff);
return temp;
return out;
}
private void setContextFlags() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2009 Sun Microsystems, Inc. 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
@ -28,8 +28,6 @@ package sun.security.provider.certpath;
import java.io.*;
import java.math.BigInteger;
import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CRLReason;
import java.security.cert.X509Certificate;
@ -335,7 +333,7 @@ class OCSPResponse {
// Check whether the cert returned by the responder is trusted
if (x509Certs != null && x509Certs[0] != null) {
X509Certificate cert = x509Certs[0];
X509CertImpl cert = x509Certs[0];
// First check if the cert matches the responder cert which
// was set locally.
@ -344,8 +342,8 @@ class OCSPResponse {
// Next check if the cert was issued by the responder cert
// which was set locally.
} else if (cert.getIssuerDN().equals(
responderCert.getSubjectDN())) {
} else if (cert.getIssuerX500Principal().equals(
responderCert.getSubjectX500Principal())) {
// Check for the OCSPSigning key purpose
List<String> keyPurposes = cert.getExtendedKeyUsage();
@ -360,6 +358,43 @@ class OCSPResponse {
"OCSP responses");
}
// check the validity
try {
Date dateCheckedAgainst = params.getDate();
if (dateCheckedAgainst == null) {
cert.checkValidity();
} else {
cert.checkValidity(dateCheckedAgainst);
}
} catch (GeneralSecurityException e) {
if (DEBUG != null) {
DEBUG.println("Responder's certificate is not " +
"within the validity period.");
}
throw new CertPathValidatorException(
"Responder's certificate not within the " +
"validity period");
}
// check for revocation
//
// A CA may specify that an OCSP client can trust a
// responder for the lifetime of the responder's
// certificate. The CA does so by including the
// extension id-pkix-ocsp-nocheck.
//
Extension noCheck =
cert.getExtension(PKIXExtensions.OCSPNoCheck_Id);
if (noCheck != null) {
if (DEBUG != null) {
DEBUG.println("Responder's certificate includes " +
"the extension id-pkix-ocsp-nocheck.");
}
} else {
// we should do the revocating checking of the
// authorized responder in a future update.
}
// verify the signature
try {
cert.verify(responderCert.getPublicKey());
@ -369,6 +404,14 @@ class OCSPResponse {
} catch (GeneralSecurityException e) {
responderCert = null;
}
} else {
if (DEBUG != null) {
DEBUG.println("Responder's certificate is not " +
"authorized to sign OCSP responses.");
}
throw new CertPathValidatorException(
"Responder's certificate not authorized to sign " +
"OCSP responses");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2009 Sun Microsystems, Inc. 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
@ -143,11 +143,15 @@ class PKIXMasterCertPathValidator {
}
} catch (CertPathValidatorException cpve) {
// Throw the saved OCSP exception
// (when the CRL check has also failed)
// Throw the saved OCSP exception unless the CRL
// checker has determined that the cert is revoked
if (ocspCause != null &&
currChecker instanceof CrlRevocationChecker) {
throw ocspCause;
currChecker instanceof CrlRevocationChecker) {
if (cpve.getReason() == BasicReason.REVOKED) {
throw cpve;
} else {
throw ocspCause;
}
}
/*
* Handle failover from OCSP to CRLs

Some files were not shown because too many files have changed in this diff Show More