diff --git a/jdk/make/com/sun/Makefile b/jdk/make/com/sun/Makefile index 77e93b8f13b..33d5824773c 100644 --- a/jdk/make/com/sun/Makefile +++ b/jdk/make/com/sun/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ SUBDIRS = java security net/ssl jarsigner SUBDIRS_management = jmx SUBDIRS_desktop = image SUBDIRS_enterprise = crypto/provider jndi \ - org xml rowset net/httpserver + org rowset net/httpserver SUBDIRS_misc = $(SCRIPT_SUBDIR) tracing servicetag nio demo # Omit mirror since it's built with the apt tool. diff --git a/jdk/make/com/sun/xml/Makefile b/jdk/make/com/sun/xml/Makefile deleted file mode 100644 index 2850c95ccb1..00000000000 --- a/jdk/make/com/sun/xml/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# Makefile for building packages under javax.xml -# - -BUILDDIR = ../../.. -PACKAGE = com.sun.xml -PRODUCT = xml -include $(BUILDDIR)/common/Defs.gmk - -# -# Files to compile -# -AUTO_FILES_JAVA_DIRS = com/sun/activation \ - org/relaxng/datatype - -# -# Rules -# -include $(BUILDDIR)/common/Classes.gmk diff --git a/jdk/make/common/internal/Defs-jaxws.gmk b/jdk/make/common/internal/Defs-jaxws.gmk index f17cd8cfc3c..105651c79fc 100644 --- a/jdk/make/common/internal/Defs-jaxws.gmk +++ b/jdk/make/common/internal/Defs-jaxws.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -55,6 +55,7 @@ IMPORT_TOOLS_PACKAGES += \ com/sun/tools/internal/xjc \ com/sun/tools/internal/ws \ com/sun/tools/internal/jxc \ + org/relaxng \ META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \ - META-INF/services/com.sun.tools.xjc.Plugin + META-INF/services/com.sun.tools.internal.xjc.Plugin diff --git a/jdk/make/java/jli/Makefile b/jdk/make/java/jli/Makefile index 928df6405f4..820dac8e40c 100644 --- a/jdk/make/java/jli/Makefile +++ b/jdk/make/java/jli/Makefile @@ -79,13 +79,17 @@ FILES_c = \ zutil.c ifneq ($(PLATFORM), windows) - -FILES_c += \ - $(CTARGDIR)ergo.c \ - $(CTARGDIR)ergo_$(ERGO_FAMILY).c + FILES_c += ergo.c + ERGO_ARCH_FILE = ergo_$(ERGO_FAMILY).c + # if the architecture specific ergo file exists then + # use it, else use the generic definitions from ergo.c + ifneq ($(wildcard $(LAUNCHER_PLATFORM_SRC)/$(ERGO_ARCH_FILE)),) + FILES_c += $(ERGO_ARCH_FILE) + else + OTHER_CPPFLAGS += -DUSE_GENERIC_ERGO + endif endif - # Names of arch directories LIBARCH_DEFINES = -DLIBARCHNAME='"$(LIBARCH)"' ifeq ($(PLATFORM), solaris) diff --git a/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java b/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java index 6688ec65ab2..787060c1614 100644 --- a/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java +++ b/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java @@ -115,6 +115,31 @@ public final class RhinoScriptEngine extends AbstractScriptEngine //construct object used to implement getInterface implementor = new InterfaceImplementor(this) { + protected boolean isImplemented(Object thiz, Class iface) { + Context cx = enterContext(); + try { + if (thiz != null && !(thiz instanceof Scriptable)) { + thiz = cx.toObject(thiz, topLevel); + } + Scriptable engineScope = getRuntimeScope(context); + Scriptable localScope = (thiz != null)? (Scriptable) thiz : + engineScope; + for (Method method : iface.getMethods()) { + // ignore methods of java.lang.Object class + if (method.getDeclaringClass() == Object.class) { + continue; + } + Object obj = ScriptableObject.getProperty(localScope, method.getName()); + if (! (obj instanceof Function)) { + return false; + } + } + return true; + } finally { + cx.exit(); + } + } + protected Object convertResult(Method method, Object res) throws ScriptException { Class desiredType = method.getReturnType(); diff --git a/jdk/src/share/classes/com/sun/script/util/InterfaceImplementor.java b/jdk/src/share/classes/com/sun/script/util/InterfaceImplementor.java index c7aafb97ac8..b209b4697e8 100644 --- a/jdk/src/share/classes/com/sun/script/util/InterfaceImplementor.java +++ b/jdk/src/share/classes/com/sun/script/util/InterfaceImplementor.java @@ -82,12 +82,19 @@ public class InterfaceImplementor { if (iface == null || !iface.isInterface()) { throw new IllegalArgumentException("interface Class expected"); } + if (! isImplemented(thiz, iface)) { + return null; + } AccessControlContext accCtxt = AccessController.getContext(); return iface.cast(Proxy.newProxyInstance(iface.getClassLoader(), new Class[]{iface}, new InterfaceImplementorInvocationHandler(thiz, accCtxt))); } + protected boolean isImplemented(Object thiz, Class iface) { + return true; + } + // called to convert method result after invoke protected Object convertResult(Method method, Object res) throws ScriptException { diff --git a/jdk/src/share/classes/java/net/URLConnection.java b/jdk/src/share/classes/java/net/URLConnection.java index 6db1f6e82b3..976e8f66cea 100644 --- a/jdk/src/share/classes/java/net/URLConnection.java +++ b/jdk/src/share/classes/java/net/URLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1422,7 +1422,7 @@ public abstract class URLConnection { if (!is.markSupported()) return null; - is.mark(12); + is.mark(16); int c1 = is.read(); int c2 = is.read(); int c3 = is.read(); @@ -1434,6 +1434,11 @@ public abstract class URLConnection { int c9 = is.read(); int c10 = is.read(); int c11 = is.read(); + int c12 = is.read(); + int c13 = is.read(); + int c14 = is.read(); + int c15 = is.read(); + int c16 = is.read(); is.reset(); if (c1 == 0xCA && c2 == 0xFE && c3 == 0xBA && c4 == 0xBE) { @@ -1461,6 +1466,13 @@ public abstract class URLConnection { } } + // big and little (identical) endian UTF-8 encodings, with BOM + if (c1 == 0xef && c2 == 0xbb && c3 == 0xbf) { + if (c4 == '<' && c5 == '?' && c6 == 'x') { + return "application/xml"; + } + } + // big and little endian UTF-16 encodings, with byte order mark if (c1 == 0xfe && c2 == 0xff) { if (c3 == 0 && c4 == '<' && c5 == 0 && c6 == '?' && @@ -1476,6 +1488,23 @@ public abstract class URLConnection { } } + // big and little endian UTF-32 encodings, with BOM + if (c1 == 0x00 && c2 == 0x00 && c3 == 0xfe && c4 == 0xff) { + if (c5 == 0 && c6 == 0 && c7 == 0 && c8 == '<' && + c9 == 0 && c10 == 0 && c11 == 0 && c12 == '?' && + c13 == 0 && c14 == 0 && c15 == 0 && c16 == 'x') { + return "application/xml"; + } + } + + if (c1 == 0xff && c2 == 0xfe && c3 == 0x00 && c4 == 0x00) { + if (c5 == '<' && c6 == 0 && c7 == 0 && c8 == 0 && + c9 == '?' && c10 == 0 && c11 == 0 && c12 == 0 && + c13 == 'x' && c14 == 0 && c15 == 0 && c16 == 0) { + return "application/xml"; + } + } + if (c1 == 'G' && c2 == 'I' && c3 == 'F' && c4 == '8') { return "image/gif"; } diff --git a/jdk/src/share/classes/org/relaxng/datatype/Datatype.java b/jdk/src/share/classes/org/relaxng/datatype/Datatype.java deleted file mode 100644 index f1b4d8df244..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/Datatype.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype; - -/** - * Datatype object. - * - * This object has the following functionality: - * - *
    - *
  1. functionality to identify a class of character sequences. This is - * done through the isValid method. - * - *
  2. functionality to produce a "value object" from a character sequence and - * context information. - * - *
  3. functionality to test the equality of two value objects. - *
- * - * This interface also defines the createStreamingValidator method, - * which is intended to efficiently support the validation of - * large character sequences. - * - * @author James Clark - * @author Kohsuke KAWAGUCHI - */ -public interface Datatype { - - /** - * Checks if the specified 'literal' matches this Datatype - * with respect to the current context. - * - * @param literal - * the lexical representation to be checked. - * @param context - * If this datatype is context-dependent - * (i.e. the {@link #isContextDependent} method returns true), - * then the caller must provide a non-null valid context object. - * Otherwise, the caller can pass null. - * - * @return - * true if the 'literal' is a member of this Datatype; - * false if it's not a member of this Datatype. - */ - boolean isValid( String literal, ValidationContext context ); - - /** - * Similar to the isValid method but throws an exception with diagnosis - * in case of errors. - * - *

- * If the specified 'literal' is a valid lexical representation for this - * datatype, then this method must return without throwing any exception. - * If not, the callee must throw an exception (with diagnosis message, - * if possible.) - * - *

- * The application can use this method to provide detailed error message - * to users. This method is kept separate from the isValid method to - * achieve higher performance during normal validation. - * - * @exception DatatypeException - * If the given literal is invalid, then this exception is thrown. - * If the callee supports error diagnosis, then the exception should - * contain a diagnosis message. - */ - void checkValid( String literal, ValidationContext context ) - throws DatatypeException; - - /** - * Creates an instance of a streaming validator for this type. - * - *

- * By using streaming validators instead of the isValid method, - * the caller can avoid keeping the entire string, which is - * sometimes quite big, in memory. - * - * @param context - * If this datatype is context-dependent - * (i.e. the {@link #isContextDependent} method returns true), - * then the caller must provide a non-null valid context object. - * Otherwise, the caller can pass null. - * The callee may keep a reference to this context object - * only while the returned streaming validator is being used. - */ - DatatypeStreamingValidator createStreamingValidator( ValidationContext context ); - - /** - * Converts lexcial value and the current context to the corresponding - * value object. - * - *

- * The caller cannot generally assume that the value object is - * a meaningful Java object. For example, the caller cannot expect - * this method to return java.lang.Number type for - * the "integer" type of XML Schema Part 2. - * - *

- * Also, the caller cannot assume that the equals method and - * the hashCode method of the value object are consistent with - * the semantics of the datatype. For that purpose, the sameValue - * method and the valueHashCode method have to be used. Note that - * this means you cannot use classes like - * java.util.Hashtable to store the value objects. - * - *

- * The returned value object should be used solely for the sameValue - * and valueHashCode methods. - * - * @param context - * If this datatype is context-dependent - * (when the {@link #isContextDependent} method returns true), - * then the caller must provide a non-null valid context object. - * Otherwise, the caller can pass null. - * - * @return null - * when the given lexical value is not a valid lexical - * value for this type. - */ - Object createValue( String literal, ValidationContext context ); - - /** - * Tests the equality of two value objects which were originally - * created by the createValue method of this object. - * - * The behavior is undefined if objects not created by this type - * are passed. It is the caller's responsibility to ensure that - * value objects belong to this type. - * - * @return - * true if two value objects are considered equal according to - * the definition of this datatype; false if otherwise. - */ - boolean sameValue( Object value1, Object value2 ); - - - /** - * Computes the hash code for a value object, - * which is consistent with the sameValue method. - * - * @return - * hash code for the specified value object. - */ - int valueHashCode( Object value ); - - - - - /** - * Indicates that the datatype doesn't have ID/IDREF semantics. - * - * This value is one of the possible return values of the - * {@link #getIdType} method. - */ - public static final int ID_TYPE_NULL = 0; - - /** - * Indicates that RELAX NG compatibility processors should - * treat this datatype as having ID semantics. - * - * This value is one of the possible return values of the - * {@link #getIdType} method. - */ - public static final int ID_TYPE_ID = 1; - - /** - * Indicates that RELAX NG compatibility processors should - * treat this datatype as having IDREF semantics. - * - * This value is one of the possible return values of the - * {@link #getIdType} method. - */ - public static final int ID_TYPE_IDREF = 2; - - /** - * Indicates that RELAX NG compatibility processors should - * treat this datatype as having IDREFS semantics. - * - * This value is one of the possible return values of the - * {@link #getIdType} method. - */ - public static final int ID_TYPE_IDREFS = 3; - - /** - * Checks if the ID/IDREF semantics is associated with this - * datatype. - * - *

- * This method is introduced to support the RELAX NG DTD - * compatibility spec. (Of course it's always free to use - * this method for other purposes.) - * - *

- * If you are implementing a datatype library and have no idea about - * the "RELAX NG DTD compatibility" thing, just return - * ID_TYPE_NULL is fine. - * - * @return - * If this datatype doesn't have any ID/IDREF semantics, - * it returns {@link #ID_TYPE_NULL}. If it has such a semantics - * (for example, XSD:ID, XSD:IDREF and comp:ID type), then - * it returns {@link #ID_TYPE_ID}, {@link #ID_TYPE_IDREF} or - * {@link #ID_TYPE_IDREFS}. - */ - public int getIdType(); - - - /** - * Checks if this datatype may need a context object for - * the validation. - * - *

- * The callee must return true even when the context - * is not always necessary. (For example, the "QName" type - * doesn't need a context object when validating unprefixed - * string. But nonetheless QName must return true.) - * - *

- * XSD's string and short types - * are examples of context-independent datatypes. - * Its QName and ENTITY types - * are examples of context-dependent datatypes. - * - *

- * When a datatype is context-independent, then - * the {@link #isValid} method, the {@link #checkValid} method, - * the {@link #createStreamingValidator} method and - * the {@link #createValue} method can be called without - * providing a context object. - * - * @return - * true if this datatype is context-dependent - * (it needs a context object sometimes); - * - * false if this datatype is context-independent - * (it never needs a context object). - */ - public boolean isContextDependent(); -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/DatatypeBuilder.java b/jdk/src/share/classes/org/relaxng/datatype/DatatypeBuilder.java deleted file mode 100644 index ea15f33cea2..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/DatatypeBuilder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype; - -/** - * Creates a user-defined type by adding parameters to - * the pre-defined type. - * - * @author James Clark - * @author Kohsuke KAWAGUCHI - */ -public interface DatatypeBuilder { - - /** - * Adds a new parameter. - * - * @param name - * The name of the parameter to be added. - * @param strValue - * The raw value of the parameter. Caller may not normalize - * this value because any white space is potentially significant. - * @param context - * The context information which can be used by the callee to - * acquire additional information. This context object is - * valid only during this method call. The callee may not - * keep a reference to this object. - * @exception DatatypeException - * When the given parameter is inappropriate for some reason. - * The callee is responsible to recover from this error. - * That is, the object should behave as if no such error - * was occured. - */ - void addParameter( String name, String strValue, ValidationContext context ) - throws DatatypeException; - - /** - * Derives a new Datatype from a Datatype by parameters that - * were already set through the addParameter method. - * - * @exception DatatypeException - * DatatypeException must be thrown if the derivation is - * somehow invalid. For example, a required parameter is missing, - * etc. The exception should contain a diagnosis message - * if possible. - */ - Datatype createDatatype() throws DatatypeException; -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/DatatypeException.java b/jdk/src/share/classes/org/relaxng/datatype/DatatypeException.java deleted file mode 100644 index aae00d0aa0b..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/DatatypeException.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype; - -/** - * Signals Datatype related exceptions. - * - * @author James Clark - * @author Kohsuke KAWAGUCHI - */ -public class DatatypeException extends Exception { - - public DatatypeException( int index, String msg ) { - super(msg); - this.index = index; - } - public DatatypeException( String msg ) { - this(UNKNOWN,msg); - } - /** - * A constructor for those datatype libraries which don't support any - * diagnostic information at all. - */ - public DatatypeException() { - this(UNKNOWN,null); - } - - - private final int index; - - public static final int UNKNOWN = -1; - - /** - * Gets the index of the content where the error occured. - * UNKNOWN can be returned to indicate that no index information - * is available. - */ - public int getIndex() { - return index; - } -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/DatatypeLibrary.java b/jdk/src/share/classes/org/relaxng/datatype/DatatypeLibrary.java deleted file mode 100644 index f3f790d91e2..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/DatatypeLibrary.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype; - -/** - * A Datatype library - * - * @author James Clark - * @author Kohsuke KAWAGUCHI - */ -public interface DatatypeLibrary { - - /** - * Creates a new instance of DatatypeBuilder. - * - * The callee should throw a DatatypeException in case of an error. - * - * @param baseTypeLocalName - * The local name of the base type. - * - * @return - * A non-null valid datatype object. - */ - DatatypeBuilder createDatatypeBuilder( String baseTypeLocalName ) - throws DatatypeException; - - /** - * Gets or creates a pre-defined type. - * - * This is just a short-cut of - * createDatatypeBuilder(typeLocalName).createDatatype(); - * - * The callee should throw a DatatypeException in case of an error. - * - * @return - * A non-null valid datatype object. - */ - Datatype createDatatype( String typeLocalName ) throws DatatypeException; -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/DatatypeLibraryFactory.java b/jdk/src/share/classes/org/relaxng/datatype/DatatypeLibraryFactory.java deleted file mode 100644 index e406c078894..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/DatatypeLibraryFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype; - -/** - * Factory class for the DatatypeLibrary class. - * - *

- * The datatype library should provide the implementation of - * this interface if it wants to be found by the schema processors. - * The implementor also have to place a file in your jar file. - * See the reference datatype library implementation for detail. - * - * @author James Clark - * @author Kohsuke KAWAGUCHI - */ -public interface DatatypeLibraryFactory -{ - /** - * Creates a new instance of a DatatypeLibrary that supports - * the specified namespace URI. - * - * @return - * null if the specified namespace URI is not - * supported. - */ - DatatypeLibrary createDatatypeLibrary( String namespaceURI ); -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/DatatypeStreamingValidator.java b/jdk/src/share/classes/org/relaxng/datatype/DatatypeStreamingValidator.java deleted file mode 100644 index 56663923278..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/DatatypeStreamingValidator.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype; - -/** - * Datatype streaming validator. - * - *

- * The streaming validator is an optional feature that is useful for - * certain Datatypes. It allows the caller to incrementally provide - * the literal. - * - * @author James Clark - * @author Kohsuke KAWAGUCHI - */ -public interface DatatypeStreamingValidator { - - /** - * Passes an additional fragment of the literal. - * - *

- * The application can call this method several times, then call - * the isValid method (or the checkValid method) to check the validity - * of the accumulated characters. - */ - void addCharacters( char[] buf, int start, int len ); - - /** - * Tells if the accumulated literal is valid with respect to - * the underlying Datatype. - * - * @return - * True if it is valid. False if otherwise. - */ - boolean isValid(); - - /** - * Similar to the isValid method, but this method throws - * Exception (with possibly diagnostic information), instead of - * returning false. - * - * @exception DatatypeException - * If the callee supports the diagnosis and the accumulated - * literal is invalid, then this exception that possibly - * contains diagnosis information is thrown. - */ - void checkValid() throws DatatypeException; -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/ValidationContext.java b/jdk/src/share/classes/org/relaxng/datatype/ValidationContext.java deleted file mode 100644 index 8e37b0ee6a5..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/ValidationContext.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype; - -/** - * An interface that must be implemented by caller to - * provide context information that is necessary to - * perform validation of some Datatypes. - * - * @author James Clark - * @author Kohsuke KAWAGUCHI - */ -public interface ValidationContext { - - /** - * Resolves a namespace prefix to the corresponding namespace URI. - * - * This method is used for validating the QName type, for example. - * - *

- * If the prefix is "" (empty string), it indicates - * an unprefixed value. The callee - * should resolve it as for an unprefixed - * element, rather than for an unprefixed attribute. - * - *

- * If the prefix is "xml", then the callee must resolve - * this prefix into "http://www.w3.org/XML/1998/namespace", - * as defined in the XML Namespaces Recommendation. - * - * @return - * namespace URI of this prefix. - * If the specified prefix is not declared, - * the implementation must return null. - */ - String resolveNamespacePrefix( String prefix ); - - /** - * Returns the base URI of the context. The null string may be returned - * if no base URI is known. - */ - String getBaseUri(); - - /** - * Checks if an unparsed entity is declared with the - * specified name. - * - * @return - * true - * if the DTD has an unparsed entity declaration for - * the specified name. - * false - * otherwise. - */ - boolean isUnparsedEntity( String entityName ); - - /** - * Checks if a notation is declared with the - * specified name. - * - * @return - * true - * if the DTD has a notation declaration for the specified name. - * false - * otherwise. - */ - boolean isNotation( String notationName ); -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java b/jdk/src/share/classes/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java deleted file mode 100644 index a3091b08780..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/helpers/DatatypeLibraryLoader.java +++ /dev/null @@ -1,262 +0,0 @@ -/** - * Copyright (c) 2001, Thai Open Source Software Center Ltd - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Thai Open Source Software Center Ltd nor - * the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.relaxng.datatype.helpers; - -import org.relaxng.datatype.DatatypeLibraryFactory; -import org.relaxng.datatype.DatatypeLibrary; -import java.util.Enumeration; -import java.util.NoSuchElementException; -import java.util.Vector; -import java.io.Reader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URL; - -/** - * Discovers the datatype library implementation from the classpath. - * - *

- * The call of the createDatatypeLibrary method finds an implementation - * from a given datatype library URI at run-time. - */ -public class DatatypeLibraryLoader implements DatatypeLibraryFactory { - private final Service service = new Service(DatatypeLibraryFactory.class); - - public DatatypeLibrary createDatatypeLibrary(String uri) { - for (Enumeration e = service.getProviders(); - e.hasMoreElements();) { - DatatypeLibraryFactory factory - = (DatatypeLibraryFactory)e.nextElement(); - DatatypeLibrary library = factory.createDatatypeLibrary(uri); - if (library != null) - return library; - } - return null; - } - - private static class Service { - private final Class serviceClass; - private final Enumeration configFiles; - private Enumeration classNames = null; - private final Vector providers = new Vector(); - private Loader loader; - - private class ProviderEnumeration implements Enumeration { - private int nextIndex = 0; - - public boolean hasMoreElements() { - return nextIndex < providers.size() || moreProviders(); - } - - public Object nextElement() { - try { - return providers.elementAt(nextIndex++); - } - catch (ArrayIndexOutOfBoundsException e) { - throw new NoSuchElementException(); - } - } - } - - private static class Singleton implements Enumeration { - private Object obj; - private Singleton(Object obj) { - this.obj = obj; - } - - public boolean hasMoreElements() { - return obj != null; - } - - public Object nextElement() { - if (obj == null) - throw new NoSuchElementException(); - Object tem = obj; - obj = null; - return tem; - } - } - - // JDK 1.1 - private static class Loader { - Enumeration getResources(String resName) { - ClassLoader cl = Loader.class.getClassLoader(); - URL url; - if (cl == null) - url = ClassLoader.getSystemResource(resName); - else - url = cl.getResource(resName); - return new Singleton(url); - } - - Class loadClass(String name) throws ClassNotFoundException { - return Class.forName(name); - } - } - - // JDK 1.2+ - private static class Loader2 extends Loader { - private ClassLoader cl; - - Loader2() { - cl = Loader2.class.getClassLoader(); - // If the thread context class loader has the class loader - // of this class as an ancestor, use the thread context class - // loader. Otherwise, the thread context class loader - // probably hasn't been set up properly, so don't use it. - ClassLoader clt = Thread.currentThread().getContextClassLoader(); - for (ClassLoader tem = clt; tem != null; tem = tem.getParent()) - if (tem == cl) { - cl = clt; - break; - } - } - - Enumeration getResources(String resName) { - try { - return cl.getResources(resName); - - } - catch (IOException e) { - return new Singleton(null); - } - } - - Class loadClass(String name) throws ClassNotFoundException { - return Class.forName(name, true, cl); - } - } - - public Service(Class cls) { - try { - loader = new Loader2(); - } - catch (NoSuchMethodError e) { - loader = new Loader(); - } - serviceClass = cls; - String resName = "META-INF/services/" + serviceClass.getName(); - configFiles = loader.getResources(resName); - } - - public Enumeration getProviders() { - return new ProviderEnumeration(); - } - - synchronized private boolean moreProviders() { - for (;;) { - while (classNames == null) { - if (!configFiles.hasMoreElements()) - return false; - classNames = parseConfigFile((URL)configFiles.nextElement()); - } - while (classNames.hasMoreElements()) { - String className = (String)classNames.nextElement(); - try { - Class cls = loader.loadClass(className); - Object obj = cls.newInstance(); - if (serviceClass.isInstance(obj)) { - providers.addElement(obj); - return true; - } - } - catch (ClassNotFoundException e) { } - catch (InstantiationException e) { } - catch (IllegalAccessException e) { } - catch (LinkageError e) { } - } - classNames = null; - } - } - - private static final int START = 0; - private static final int IN_NAME = 1; - private static final int IN_COMMENT = 2; - - private static Enumeration parseConfigFile(URL url) { - try { - InputStream in = url.openStream(); - Reader r; - try { - r = new InputStreamReader(in, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - r = new InputStreamReader(in, "UTF8"); - } - r = new BufferedReader(r); - Vector tokens = new Vector(); - StringBuffer tokenBuf = new StringBuffer(); - int state = START; - for (;;) { - int n = r.read(); - if (n < 0) - break; - char c = (char)n; - switch (c) { - case '\r': - case '\n': - state = START; - break; - case ' ': - case '\t': - break; - case '#': - state = IN_COMMENT; - break; - default: - if (state != IN_COMMENT) { - state = IN_NAME; - tokenBuf.append(c); - } - break; - } - if (tokenBuf.length() != 0 && state != IN_NAME) { - tokens.addElement(tokenBuf.toString()); - tokenBuf.setLength(0); - } - } - if (tokenBuf.length() != 0) - tokens.addElement(tokenBuf.toString()); - return tokens.elements(); - } - catch (IOException e) { - return null; - } - } - } - -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/helpers/ParameterlessDatatypeBuilder.java b/jdk/src/share/classes/org/relaxng/datatype/helpers/ParameterlessDatatypeBuilder.java deleted file mode 100644 index 8a5efb8b2dd..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/helpers/ParameterlessDatatypeBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype.helpers; - -import org.relaxng.datatype.*; - -/** - * Dummy implementation of {@link DatatypeBuilder}. - * - * This implementation can be used for Datatypes which have no parameters. - * Any attempt to add parameters will be rejected. - * - *

- * Typical usage would be: - *


- * class MyDatatypeLibrary implements DatatypeLibrary {
- *     ....
- *     DatatypeBuilder createDatatypeBuilder( String typeName ) {
- *         return new ParameterleessDatatypeBuilder(createDatatype(typeName));
- *     }
- *     ....
- * }
- * 
- * - * @author Kohsuke KAWAGUCHI - */ -public final class ParameterlessDatatypeBuilder implements DatatypeBuilder { - - /** This type object is returned for the derive method. */ - private final Datatype baseType; - - public ParameterlessDatatypeBuilder( Datatype baseType ) { - this.baseType = baseType; - } - - public void addParameter( String name, String strValue, ValidationContext context ) - throws DatatypeException { - throw new DatatypeException(); - } - - public Datatype createDatatype() throws DatatypeException { - return baseType; - } -} diff --git a/jdk/src/share/classes/org/relaxng/datatype/helpers/StreamingValidatorImpl.java b/jdk/src/share/classes/org/relaxng/datatype/helpers/StreamingValidatorImpl.java deleted file mode 100644 index 5f7cc79e967..00000000000 --- a/jdk/src/share/classes/org/relaxng/datatype/helpers/StreamingValidatorImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package org.relaxng.datatype.helpers; - -import org.relaxng.datatype.*; - -/** - * Dummy implementation of {@link DatatypeStreamingValidator}. - * - *

- * This implementation can be used as a quick hack when the performance - * of streaming validation is not important. And this implementation - * also shows you how to implement the DatatypeStreamingValidator interface. - * - *

- * Typical usage would be: - *


- * class MyDatatype implements Datatype {
- *     ....
- *     public DatatypeStreamingValidator createStreamingValidator( ValidationContext context ) {
- *         return new StreamingValidatorImpl(this,context);
- *     }
- *     ....
- * }
- * 
- * - * @author Kohsuke KAWAGUCHI - */ -public final class StreamingValidatorImpl implements DatatypeStreamingValidator { - - /** This buffer accumulates characters. */ - private final StringBuffer buffer = new StringBuffer(); - - /** Datatype obejct that creates this streaming validator. */ - private final Datatype baseType; - - /** The current context. */ - private final ValidationContext context; - - public void addCharacters( char[] buf, int start, int len ) { - // append characters to the current buffer. - buffer.append(buf,start,len); - } - - public boolean isValid() { - return baseType.isValid(buffer.toString(),context); - } - - public void checkValid() throws DatatypeException { - baseType.checkValid(buffer.toString(),context); - } - - public StreamingValidatorImpl( Datatype baseType, ValidationContext context ) { - this.baseType = baseType; - this.context = context; - } -} diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11Key.java b/jdk/src/share/classes/sun/security/pkcs11/P11Key.java index b54d0d3c190..56c40a97586 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11Key.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11Key.java @@ -999,18 +999,34 @@ abstract class P11Key implements Key { new CK_ATTRIBUTE(CKA_EC_PARAMS), }; fetchAttributes(attributes); + try { params = P11ECKeyFactory.decodeParameters (attributes[1].getByteArray()); - DerValue wECPoint = new DerValue(attributes[0].getByteArray()); - if (wECPoint.getTag() != DerValue.tag_OctetString) - throw new IOException("Unexpected tag: " + - wECPoint.getTag()); - params = P11ECKeyFactory.decodeParameters - (attributes[1].getByteArray()); - w = P11ECKeyFactory.decodePoint - (wECPoint.getDataBytes(), params.getCurve()); + /* + * An uncompressed EC point may be in either of two formats. + * First try the OCTET STRING encoding: + * 04 04 + * + * Otherwise try the raw encoding: + * 04 + */ + byte[] ecKey = attributes[0].getByteArray(); + + try { + DerValue wECPoint = new DerValue(ecKey); + if (wECPoint.getTag() != DerValue.tag_OctetString) + throw new IOException("Unexpected tag: " + + wECPoint.getTag()); + + w = P11ECKeyFactory.decodePoint + (wECPoint.getDataBytes(), params.getCurve()); + + } catch (IOException e) { + // Failover + w = P11ECKeyFactory.decodePoint(ecKey, params.getCurve()); + } } catch (Exception e) { throw new RuntimeException("Could not parse key values", e); diff --git a/jdk/src/share/lib/security/java.security b/jdk/src/share/lib/security/java.security index 5a0726de0a7..a89d40e194b 100644 --- a/jdk/src/share/lib/security/java.security +++ b/jdk/src/share/lib/security/java.security @@ -123,7 +123,7 @@ keystore.type=jks # passed to checkPackageAccess unless the # corresponding RuntimePermission ("accessClassInPackage."+package) has # been granted. -package.access=sun.,com.sun.imageio. +package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio. # # List of comma-separated packages that start with or equal this string diff --git a/jdk/src/share/lib/security/java.security-solaris b/jdk/src/share/lib/security/java.security-solaris index 8e9b1ffd791..1a19f44d231 100644 --- a/jdk/src/share/lib/security/java.security-solaris +++ b/jdk/src/share/lib/security/java.security-solaris @@ -124,7 +124,7 @@ keystore.type=jks # passed to checkPackageAccess unless the # corresponding RuntimePermission ("accessClassInPackage."+package) has # been granted. -package.access=sun.,com.sun.imageio. +package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio. # # List of comma-separated packages that start with or equal this string diff --git a/jdk/src/share/lib/security/java.security-windows b/jdk/src/share/lib/security/java.security-windows index 99eda51b910..3db627a4f32 100644 --- a/jdk/src/share/lib/security/java.security-windows +++ b/jdk/src/share/lib/security/java.security-windows @@ -124,7 +124,7 @@ keystore.type=jks # passed to checkPackageAccess unless the # corresponding RuntimePermission ("accessClassInPackage."+package) has # been granted. -package.access=sun.,com.sun.imageio. +package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio. # # List of comma-separated packages that start with or equal this string diff --git a/jdk/src/solaris/bin/ergo.c b/jdk/src/solaris/bin/ergo.c index e9e863e9ce5..2047087e7c5 100644 --- a/jdk/src/solaris/bin/ergo.c +++ b/jdk/src/solaris/bin/ergo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,6 +67,35 @@ ServerClassMachine(void) { } } +#ifdef USE_GENERIC_ERGO +/* Ask the OS how many processors there are. */ +static unsigned long +physical_processors(void) { + const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF); + JLI_TraceLauncher("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors); + return sys_processors; +} + +jboolean +ServerClassMachineImpl(void) { + jboolean result = JNI_FALSE; + /* How big is a server class machine? */ + const unsigned long server_processors = 2UL; + const uint64_t server_memory = 2UL * GB; + const uint64_t actual_memory = physical_memory(); + + /* Is this a server class machine? */ + if (actual_memory >= server_memory) { + const unsigned long actual_processors = physical_processors(); + if (actual_processors >= server_processors) { + result = JNI_TRUE; + } + } + JLI_TraceLauncher("unix_" LIBARCHNAME "_ServerClassMachine: %s\n", + (result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE")); + return result; +} +#endif /* Compute physical memory by asking the OS */ uint64_t diff --git a/jdk/src/solaris/bin/ergo_sparc.c b/jdk/src/solaris/bin/ergo_sparc.c deleted file mode 100644 index 9261a423de6..00000000000 --- a/jdk/src/solaris/bin/ergo_sparc.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include "ergo.h" - - -/* Methods for solaris-sparc and linux-sparc: these are easy. */ - -/* Ask the OS how many processors there are. */ -static unsigned long -physical_processors(void) { - const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF); - - JLI_TraceLauncher("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors); - return sys_processors; -} - -/* The sparc version of the "server-class" predicate. */ -jboolean -ServerClassMachineImpl(void) { - jboolean result = JNI_FALSE; - /* How big is a server class machine? */ - const unsigned long server_processors = 2UL; - const uint64_t server_memory = 2UL * GB; - const uint64_t actual_memory = physical_memory(); - - /* Is this a server class machine? */ - if (actual_memory >= server_memory) { - const unsigned long actual_processors = physical_processors(); - if (actual_processors >= server_processors) { - result = JNI_TRUE; - } - } - JLI_TraceLauncher("unix_" LIBARCHNAME "_ServerClassMachine: %s\n", - (result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE")); - return result; -} diff --git a/jdk/src/solaris/bin/ergo_zero.c b/jdk/src/solaris/bin/ergo_zero.c deleted file mode 100644 index 9261a423de6..00000000000 --- a/jdk/src/solaris/bin/ergo_zero.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include "ergo.h" - - -/* Methods for solaris-sparc and linux-sparc: these are easy. */ - -/* Ask the OS how many processors there are. */ -static unsigned long -physical_processors(void) { - const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF); - - JLI_TraceLauncher("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors); - return sys_processors; -} - -/* The sparc version of the "server-class" predicate. */ -jboolean -ServerClassMachineImpl(void) { - jboolean result = JNI_FALSE; - /* How big is a server class machine? */ - const unsigned long server_processors = 2UL; - const uint64_t server_memory = 2UL * GB; - const uint64_t actual_memory = physical_memory(); - - /* Is this a server class machine? */ - if (actual_memory >= server_memory) { - const unsigned long actual_processors = physical_processors(); - if (actual_processors >= server_processors) { - result = JNI_TRUE; - } - } - JLI_TraceLauncher("unix_" LIBARCHNAME "_ServerClassMachine: %s\n", - (result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE")); - return result; -} diff --git a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c index e6eaa0aa2f5..9a5b78e7723 100644 --- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c +++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c @@ -60,7 +60,7 @@ Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { char hostname[MAXHOSTNAMELEN+1]; hostname[0] = '\0'; - if (JVM_GetHostName(hostname, MAXHOSTNAMELEN)) { + if (JVM_GetHostName(hostname, sizeof(hostname))) { /* Something went wrong, maybe networking is not setup? */ strcpy(hostname, "localhost"); } else { @@ -83,6 +83,9 @@ Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { char *buf2[HENT_BUF_SIZE/(sizeof (char *))]; int h_error=0; + // ensure null-terminated + hostname[MAXHOSTNAMELEN] = '\0'; + #ifdef __GLIBC__ gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &hp, &h_error); #else diff --git a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c index 5db03bf36fa..835969d7761 100644 --- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c +++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c @@ -64,10 +64,12 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { char hostname[NI_MAXHOST+1]; hostname[0] = '\0'; - if (JVM_GetHostName(hostname, MAXHOSTNAMELEN)) { + if (JVM_GetHostName(hostname, sizeof(hostname))) { /* Something went wrong, maybe networking is not setup? */ strcpy(hostname, "localhost"); } else { + // ensure null-terminated + hostname[NI_MAXHOST] = '\0'; #ifdef __linux__ /* On Linux gethostname() says "host.domain.sun.com". On * Solaris gethostname() says "host", so extra work is needed. diff --git a/jdk/test/Makefile b/jdk/test/Makefile index d26d19c544a..d1171b96027 100644 --- a/jdk/test/Makefile +++ b/jdk/test/Makefile @@ -399,12 +399,12 @@ $(foreach i,$1,$(wildcard ${i})) $(foreach i,$1,$(wildcard closed/${i})) endef # Running batches of tests with or without samevm define RunSamevmBatch -$(ECHO) "Running tests in samevm mode: $(call TestDirs, $?)" -$(MAKE) TESTDIRS="$(call TestDirs, $?)" USE_JTREG_SAMEVM=true UNIQUE_DIR=$@ jtreg_tests +$(ECHO) "Running tests in samevm mode: $?" +$(MAKE) TESTDIRS="$?" USE_JTREG_SAMEVM=true UNIQUE_DIR=$@ jtreg_tests endef define RunOthervmBatch -$(ECHO) "Running tests in othervm mode: $(call TestDirs, $?)" -$(MAKE) TESTDIRS="$(call TestDirs, $?)" USE_JTREG_SAMEVM=false UNIQUE_DIR=$@ jtreg_tests +$(ECHO) "Running tests in othervm mode: $?" +$(MAKE) TESTDIRS="$?" USE_JTREG_SAMEVM=false UNIQUE_DIR=$@ jtreg_tests endef define SummaryInfo $(ECHO) "########################################################" @@ -420,27 +420,29 @@ JDK_ALL_TARGETS = # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has problems, and doesn't help performance as much as others. JDK_ALL_TARGETS += jdk_awt -jdk_awt: com/sun/awt java/awt sun/awt +jdk_awt: $(call TestDirs, com/sun/awt java/awt sun/awt) $(call RunOthervmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_beans1 -jdk_beans1: java/beans/beancontext java/beans/PropertyChangeSupport \ +jdk_beans1: $(call TestDirs, \ + java/beans/beancontext java/beans/PropertyChangeSupport \ java/beans/Introspector java/beans/Performance \ - java/beans/VetoableChangeSupport java/beans/Statement + java/beans/VetoableChangeSupport java/beans/Statement) $(call RunSamevmBatch) # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has serious problems with these tests JDK_ALL_TARGETS += jdk_beans2 -jdk_beans2: java/beans/Beans java/beans/EventHandler java/beans/XMLDecoder \ - java/beans/PropertyEditor +jdk_beans2: $(call TestDirs, \ + java/beans/Beans java/beans/EventHandler java/beans/XMLDecoder \ + java/beans/PropertyEditor) $(call RunOthervmBatch) # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has serious problems with these tests JDK_ALL_TARGETS += jdk_beans3 -jdk_beans3: java/beans/XMLEncoder +jdk_beans3: $(call TestDirs, java/beans/XMLEncoder) $(call RunOthervmBatch) # All beans tests @@ -449,24 +451,24 @@ jdk_beans: jdk_beans1 jdk_beans2 jdk_beans3 # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_io -jdk_io: java/io +jdk_io: $(call TestDirs, java/io) $(call RunSamevmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_lang -jdk_lang: java/lang +jdk_lang: $(call TestDirs, java/lang) $(call RunSamevmBatch) # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has serious problems with these tests JDK_ALL_TARGETS += jdk_management1 -jdk_management1: javax/management +jdk_management1: $(call TestDirs, javax/management) $(call RunOthervmBatch) # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has serious problems with these tests JDK_ALL_TARGETS += jdk_management2 -jdk_management2: com/sun/jmx com/sun/management sun/management +jdk_management2: $(call TestDirs, com/sun/jmx com/sun/management sun/management) $(call RunOthervmBatch) # All management tests @@ -475,36 +477,37 @@ jdk_management: jdk_management1 jdk_management2 # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_math -jdk_math: java/math +jdk_math: $(call TestDirs, java/math) $(call RunSamevmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_misc -jdk_misc: demo javax/imageio javax/naming javax/print javax/script \ +jdk_misc: $(call TestDirs, \ + demo javax/imageio javax/naming javax/print javax/script \ javax/smartcardio javax/sound com/sun/java com/sun/jndi \ - com/sun/org sun/misc sun/pisces + com/sun/org com/sun/xml sun/misc sun/pisces) $(call RunSamevmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_net -jdk_net: com/sun/net java/net sun/net +jdk_net: $(call TestDirs, com/sun/net java/net sun/net) $(call RunSamevmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_nio1 -jdk_nio1: java/nio/file +jdk_nio1: $(call TestDirs, java/nio/file) $(call RunSamevmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_nio2 -jdk_nio2: java/nio/Buffer java/nio/ByteOrder \ - java/nio/channels java/nio/BufferPoolMXBean java/nio/MappedByteBuffer +jdk_nio2: $(call TestDirs, java/nio/Buffer java/nio/ByteOrder \ + java/nio/channels java/nio/BufferPoolMXBean java/nio/MappedByteBuffer) $(call SharedLibraryPermissions,java/nio/channels) $(call RunSamevmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_nio3 -jdk_nio3: com/sun/nio sun/nio +jdk_nio3: $(call TestDirs, com/sun/nio sun/nio) $(call RunSamevmBatch) # All nio tests @@ -514,24 +517,25 @@ jdk_nio: jdk_nio1 jdk_nio2 jdk_nio3 # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has serious problems with these tests JDK_ALL_TARGETS += jdk_rmi -jdk_rmi: java/rmi javax/rmi sun/rmi +jdk_rmi: $(call TestDirs, java/rmi javax/rmi sun/rmi) $(call RunOthervmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_security1 -jdk_security1: java/security +jdk_security1: $(call TestDirs, java/security) $(call RunSamevmBatch) # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has serious problems with these tests JDK_ALL_TARGETS += jdk_security2 -jdk_security2: javax/crypto com/sun/crypto +jdk_security2: $(call TestDirs, javax/crypto com/sun/crypto) $(call RunOthervmBatch) # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has serious problems with these tests JDK_ALL_TARGETS += jdk_security3 -jdk_security3: com/sun/security lib/security javax/security sun/security +jdk_security3: $(call TestDirs, com/sun/security lib/security \ + javax/security sun/security) $(call SharedLibraryPermissions,sun/security) $(call RunOthervmBatch) @@ -542,23 +546,25 @@ jdk_security: jdk_security1 jdk_security2 jdk_security3 # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has problems, and doesn't help performance as much as others. JDK_ALL_TARGETS += jdk_swing -jdk_swing: javax/swing sun/java2d +jdk_swing: $(call TestDirs, javax/swing sun/java2d) $(call RunOthervmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_text -jdk_text: java/text sun/text +jdk_text: $(call TestDirs, java/text sun/text) $(call RunSamevmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_tools1 -jdk_tools1: com/sun/jdi +jdk_tools1: $(call TestDirs, com/sun/jdi) $(call RunSamevmBatch) # Stable othervm testruns (minus items from PROBLEM_LIST) # Using samevm has serious problems with these tests JDK_ALL_TARGETS += jdk_tools2 -jdk_tools2: com/sun/tools sun/jvmstat sun/tools tools vm com/sun/servicetag com/sun/tracing +jdk_tools2: $(call TestDirs, \ + com/sun/tools sun/jvmstat sun/tools tools vm \ + com/sun/servicetag com/sun/tracing) $(call SharedLibraryPermissions,tools/launcher) $(call RunSamevmBatch) @@ -568,7 +574,7 @@ jdk_tools: jdk_tools1 jdk_tools2 # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_util -jdk_util: java/util sun/util +jdk_util: $(call TestDirs, java/util sun/util) $(call RunSamevmBatch) # ------------------------------------------------------------------ diff --git a/jdk/test/java/net/URLConnection/GetXmlContentType.java b/jdk/test/java/net/URLConnection/GetXmlContentType.java index 5c3282d63ec..e89043a9781 100644 --- a/jdk/test/java/net/URLConnection/GetXmlContentType.java +++ b/jdk/test/java/net/URLConnection/GetXmlContentType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,8 @@ /* * @test - * @bug 4160195 - * @summary Check for correct detection of XML content type + * @bug 4160195 7026346 + * @summary Check for correct detection of XML content type, including BOM streams */ import java.io.*; @@ -34,6 +34,8 @@ import java.net.*; public class GetXmlContentType { static final String XML_MIME_TYPE = "application/xml"; + static final String XML_HEADER = " 0) + throw new RuntimeException ( + "Test failed; passed = " + passed + ", failed = " + failed); + } + + static void contentTypeFromFile() throws Exception { // POSITIVE tests: good data --> good result - // - for (int i = 0; i < goodFiles.length; i++) { - String result = getUrlContentType (goodFiles [i]); - if (!XML_MIME_TYPE.equals (result)) { - System.out.println ("Wrong MIME type: " - + goodFiles [i] - + " --> " + result - ); - sawError = true; + for (String goodFile : goodFiles) { + String result = getUrlContentType(goodFile); + + if (!XML_MIME_TYPE.equals(result)) { + System.out.println("Wrong MIME type: " + goodFile + " --> " + result); + failed++; + } else { + passed++; } } - // // NEGATIVE tests: bad data --> correct diagnostic - // - for (int i = 0; i < badFiles.length; i++) { - String result = getUrlContentType (badFiles [i]); + for (String badFile : badFiles) { + String result = getUrlContentType(badFile); - if (XML_MIME_TYPE.equals (result)) { - System.out.println ("Wrong MIME type: " - + badFiles [i] - + " --> " + result - ); - sawError = true; + if (XML_MIME_TYPE.equals(result)) { + System.out.println("Wrong MIME type: " + badFile + " --> " + result); + failed++; + } else { + passed++; } } - - if (sawError) - throw new Exception ( - "GetXmlContentType Test failed; see diagnostics."); } - static String getUrlContentType (String name) throws IOException { - File file = new File(System.getProperty("test.src", "."), "xml"); - URL u = new URL ("file:" - + file.getCanonicalPath() - + file.separator - + name); - URLConnection conn = u.openConnection (); + static String getUrlContentType(String name) throws IOException { + File file = new File(System.getProperty("test.src", "."), "xml"); + URL u = new URL("file:" + + file.getCanonicalPath() + + file.separator + + name); + URLConnection conn = u.openConnection(); - return conn.getContentType (); + return conn.getContentType(); } + static void contentTypeFromBOMStream() throws Exception { + final String[] encodings = new String[] + {"UTF-8", "UTF-16BE", "UTF-16LE", "UTF-32BE", "UTF-32LE"}; + for (String encoding : encodings) { + try (InputStream is = new ByteArrayInputStream(toBOMBytes(encoding))) { + String mime = URLConnection.guessContentTypeFromStream(is); + if ( !XML_MIME_TYPE.equals(mime) ) { + System.out.println("Wrong MIME type: " + encoding + " --> " + mime); + failed++; + } else { + passed++; + } + } + } + } + + static byte[] toBOMBytes(String encoding) throws Exception { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + switch (encoding) { + case "UTF-8" : + bos.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF }); + break; + case "UTF-16BE" : + bos.write(new byte[] { (byte) 0xFE, (byte) 0xFF }); + break; + case "UTF-16LE" : + bos.write(new byte[] { (byte) 0xFF, (byte) 0xFE }); + break; + case "UTF-32BE" : + bos.write(new byte[] { (byte) 0x00, (byte) 0x00, + (byte) 0xFE, (byte) 0xFF }); + break; + case "UTF-32LE" : + bos.write(new byte[] { (byte) 0xFF, (byte) 0xFE, + (byte) 0x00, (byte) 0x00 }); + } + + bos.write(XML_HEADER.getBytes(encoding)); + return bos.toByteArray(); + } } diff --git a/jdk/test/javax/script/GetInterfaceTest.java b/jdk/test/javax/script/GetInterfaceTest.java new file mode 100644 index 00000000000..d780a6db08b --- /dev/null +++ b/jdk/test/javax/script/GetInterfaceTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6960211 + * @summary JavaScript engine allows creation of interface although methods not available. + */ + +import javax.script.*; + +public class GetInterfaceTest { + public static void main(String[] args) throws Exception { + ScriptEngineManager manager = new ScriptEngineManager(); + ScriptEngine engine = manager.getEngineByName("js"); + + if (engine == null) { + System.out.println("Warning: No engine engine found; test vacuously passes."); + return; + } + + // don't define any function. + engine.eval(""); + + Runnable runnable = ((Invocable)engine).getInterface(Runnable.class); + if (runnable != null) { + throw new RuntimeException("runnable is not null!"); + } + + // now define "run" + engine.eval("function run() { println('this is run function'); }"); + runnable = ((Invocable)engine).getInterface(Runnable.class); + // should not return null now! + runnable.run(); + + // define only one method of "Foo2" + engine.eval("function bar() { println('bar function'); }"); + Foo2 foo2 = ((Invocable)engine).getInterface(Foo2.class); + if (foo2 != null) { + throw new RuntimeException("foo2 is not null!"); + } + + // now define other method of "Foo2" + engine.eval("function bar2() { println('bar2 function'); }"); + foo2 = ((Invocable)engine).getInterface(Foo2.class); + foo2.bar(); + foo2.bar2(); + } + + interface Foo { + public void bar(); + } + + interface Foo2 extends Foo { + public void bar2(); + } +}