Mercurial > hg > release > icedtea7-forest-2.5 > jaxws
changeset 768:d4ba4e1ed3ec jdk7u60-b03
Merge
author | asaha |
---|---|
date | Thu, 02 Jan 2014 09:45:01 -0800 |
parents | a57f209a4a5a (current diff) f660bfe052d9 (diff) |
children | a840edf95760 bef313c7ff7a |
files | .hgtags src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/ModelBuilder.java |
diffstat | 31 files changed, 736 insertions(+), 125 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Wed Dec 18 15:56:48 2013 -0800 +++ b/.hgtags Thu Jan 02 09:45:01 2014 -0800 @@ -381,6 +381,24 @@ 65b0f3ccdc8bcff0d79e1b543a8cefb817529b3f jdk7u45-b18 c32c6a662d18d7195fc02125178c7543ce09bb00 jdk7u45-b30 6802a1c098c48b2c8336e06f1565254759025bab jdk7u45-b31 +e040abab3625fbced33b30cba7c0307236268211 jdk7u45-b33 +e7df5d6b23c64509672d262187f51cde14db4e66 jdk7u45-b34 +5524cced32d3959d95ed414add230273bc10c38d jdk7u51-b00 +db9e3328f393313e52cbf3fee5236aa2429028d0 jdk7u51-b01 +92a4787cb3617005a329fb49247c550e8d7eb47a jdk7u51-b02 +2240523feb968d7921e22f6730c299246a4125d0 jdk7u51-b03 +c4f7cc35e47a4db7f380d62127dd2b49713f5552 jdk7u51-b04 +f8f0617c0310b638855add08df58c5b9cd7e2dcb jdk7u51-b05 +49fc29e8890c52e771beb3fd9bf3cbb9ecbf5f5e jdk7u51-b06 +da128632f015df99d0f6a53547484dbe44f722fb jdk7u51-b07 +71a314d55844bd6fe18aed56ce065b8df5c5cb82 jdk7u51-b08 +3b53d5ea0aec473b637cd0e49f227304bac848a7 jdk7u51-b09 +53a566a724e59f31bbd25a6a21f0f36adb36e82b jdk7u51-b10 +708507f4795cad1f0cf7e19ff2dc16fe9d441754 jdk7u51-b11 +7c7c2ea4b6808d0abf7fd48d11440d75b0c08d3a jdk7u51-b12 +81a1b110f70c37d2c2f0de7c0ef3bd2d04aba475 jdk7u51-b13 +5dbeb9983f104be717da35c9b14923d71dd248d7 jdk7u51-b30 +eb79f394916efba85f4f6c7ef562966699f2c1e8 jdk7u51-b31 cb5f95263f620967f5097c5ff8e0b27cfb9e8c44 jdk7u60-b00 f675dfce1e61a6ed01732ae7cfbae941791cba74 jdk7u60-b01 8a3b9e8492a5ac4e2e0c166dbfc5d058be244377 jdk7u60-b02
--- a/src/share/jaxws_classes/com/sun/tools/internal/jxc/model/nav/APTNavigator.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/tools/internal/jxc/model/nav/APTNavigator.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -71,8 +71,7 @@ * * @author Kohsuke Kawaguchi (kk@kohsuke.org) */ -public class APTNavigator implements Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration> { - +public final class APTNavigator implements Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration> { private final AnnotationProcessorEnvironment env; private final PrimitiveType primitiveByte; @@ -277,8 +276,9 @@ return clazz.getPackage().getQualifiedName(); } - public TypeDeclaration findClass(String className, TypeDeclaration referencePoint) { - return env.getTypeDeclaration(className); + @Override + public TypeDeclaration loadObjectFactory(TypeDeclaration referencePoint, String packageName) { + return env.getTypeDeclaration(packageName + ".ObjectFactory"); } public boolean isBridgeMethod(MethodDeclaration method) {
--- a/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/nav/EagerNType.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/nav/EagerNType.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -30,7 +30,6 @@ import com.sun.codemodel.internal.JType; import com.sun.tools.internal.xjc.outline.Aspect; import com.sun.tools.internal.xjc.outline.Outline; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; /** * @author Kohsuke Kawaguchi @@ -69,6 +68,6 @@ } public String fullName() { - return Navigator.REFLECTION.getTypeName(t); + return Utils.REFLECTION_NAVIGATOR.getTypeName(t); } }
--- a/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/nav/NavigatorImpl.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/nav/NavigatorImpl.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -56,7 +56,7 @@ EagerNType ent = (EagerNType) nt; if (base instanceof EagerNClass) { EagerNClass enc = (EagerNClass) base; - return create(REFLECTION.getBaseClass(ent.t, enc.c)); + return create(Utils.REFLECTION_NAVIGATOR.getBaseClass(ent.t, enc.c)); } // lazy class can never be a base type of an eager type return null; @@ -176,7 +176,7 @@ public NType getTypeArgument(NType nt, int i) { if (nt instanceof EagerNType) { EagerNType ent = (EagerNType) nt; - return create(REFLECTION.getTypeArgument(ent.t,i)); + return create(Utils.REFLECTION_NAVIGATOR.getTypeArgument(ent.t,i)); } if (nt instanceof NClassByJClass) { NClassByJClass nnt = (NClassByJClass) nt; @@ -189,7 +189,7 @@ public boolean isParameterizedType(NType nt) { if (nt instanceof EagerNType) { EagerNType ent = (EagerNType) nt; - return REFLECTION.isParameterizedType(ent.t); + return Utils.REFLECTION_NAVIGATOR.isParameterizedType(ent.t); } if (nt instanceof NClassByJClass) { NClassByJClass nnt = (NClassByJClass) nt; @@ -303,8 +303,8 @@ throw new UnsupportedOperationException(); } - public NClass findClass(String className, NClass referencePoint) { - // TODO: implement this method later + @Override + public NClass loadObjectFactory(NClass referencePoint, String pkg) { throw new UnsupportedOperationException(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/nav/Utils.java Thu Jan 02 09:45:01 2014 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.tools.internal.xjc.model.nav; + +import com.sun.xml.internal.bind.v2.model.nav.Navigator; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utils class. + * + * WARNING: If you are doing any changes don't forget to change other Utils classes in different packages. + * + * Has *package private* access to avoid inappropriate usage. + */ +/* package */ final class Utils { + + private static final Logger LOGGER = Logger.getLogger(Utils.class.getName()); + + /** + * static ReflectionNavigator field to avoid usage of reflection every time we use it. + */ + /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR; + + static { // we statically initializing REFLECTION_NAVIGATOR property + Class refNav = null; + try { + refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator"); + //noinspection unchecked + Method getInstance = refNav.getDeclaredMethod("getInstance"); + getInstance.setAccessible(true); + //noinspection unchecked + REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new IllegalStateException("Can't find ReflectionNavigator class"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception"); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance can't be found"); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible"); + } catch (SecurityException e) { + LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e); + throw e; + } + } + + /** + * private constructor to avoid util class instantiating + */ + private Utils() { + } +}
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/api/JAXBRIContext.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/api/JAXBRIContext.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -45,7 +45,6 @@ import com.sun.xml.internal.bind.api.impl.NameConverter; import com.sun.xml.internal.bind.v2.ContextFactory; import com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet; /** @@ -404,7 +403,7 @@ * @since 2.0 FCS */ public static @Nullable Type getBaseType(@NotNull Type type, @NotNull Class baseType) { - return Navigator.REFLECTION.getBaseClass(type,baseType); + return Utils.REFLECTION_NAVIGATOR.getBaseClass(type, baseType); }
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/api/TypeReference.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/api/TypeReference.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -31,8 +31,6 @@ import javax.xml.namespace.QName; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; - /** * A reference to a JAXB-bound type. * @@ -104,11 +102,10 @@ // if we are to reinstitute this check, check JAXB annotations only // assert annotations.length==0; // not designed to work with adapters. - Type base = Navigator.REFLECTION.getBaseClass(type, Collection.class); + Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(type, Collection.class); if(base==null) return this; // not a collection - return new TypeReference(tagName, - Navigator.REFLECTION.getTypeArgument(base,0)); + return new TypeReference(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0)); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/api/Utils.java Thu Jan 02 09:45:01 2014 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.xml.internal.bind.api; + +import com.sun.xml.internal.bind.v2.model.nav.Navigator; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utils class. + * + * WARNING: If you are doing any changes don't forget to change other Utils classes in different packages. + * + * Has *package private* access to avoid inappropriate usage. + */ +/* package */ final class Utils { + + private static final Logger LOGGER = Logger.getLogger(Utils.class.getName()); + + /** + * static ReflectionNavigator field to avoid usage of reflection every time we use it. + */ + /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR; + + static { // we statically initializing REFLECTION_NAVIGATOR property + Class refNav = null; + try { + refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator"); + //noinspection unchecked + Method getInstance = refNav.getDeclaredMethod("getInstance"); + getInstance.setAccessible(true); + //noinspection unchecked + REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new IllegalStateException("Can't find ReflectionNavigator class"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception"); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance can't be found"); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible"); + } catch (SecurityException e) { + LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e); + throw e; + } + } + + /** + * private constructor to avoid util class instantiating + */ + private Utils() { + } +}
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/ModelBuilder.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/ModelBuilder.java Thu Jan 02 09:45:01 2014 -0800 @@ -235,7 +235,7 @@ String pkg = nav.getPackageName(ci.getClazz()); if(!registries.containsKey(pkg)) { // insert the package's object factory - C c = loadObjectFactory(ci, pkg); + C c = nav.loadObjectFactory(clazz, pkg); if(c!=null) addRegistry(c,(Locatable)p); } @@ -264,15 +264,6 @@ return r; } - private C loadObjectFactory(ClassInfoImpl<T, C, F, M> ci, String pkg) { - try { - return nav.findClass(pkg + ".ObjectFactory", ci.getClazz()); - } catch (SecurityException ignored) { - // treat SecurityException in same way as ClassNotFoundException in this case - return null; - } - } - /** * Checks the uniqueness of the type name. */
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeAnyTypeImpl.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeAnyTypeImpl.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -27,7 +27,6 @@ import java.lang.reflect.Type; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeNonElement; import com.sun.xml.internal.bind.v2.runtime.Transducer; @@ -36,7 +35,7 @@ */ final class RuntimeAnyTypeImpl extends AnyTypeImpl<Type,Class> implements RuntimeNonElement { private RuntimeAnyTypeImpl() { - super(Navigator.REFLECTION); + super(Utils.REFLECTION_NAVIGATOR); } public <V> Transducer<V> getTransducer() {
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeElementInfoImpl.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeElementInfoImpl.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -42,7 +42,6 @@ import com.sun.xml.internal.bind.v2.model.runtime.RuntimeNonElement; import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeRef; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationException; import com.sun.xml.internal.bind.v2.runtime.Transducer; import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; @@ -122,7 +121,7 @@ } public Class<? extends JAXBElement> getType() { - return Navigator.REFLECTION.erasure(super.getType()); + return (Class<? extends JAXBElement>) Utils.REFLECTION_NAVIGATOR.erasure(super.getType()); } public RuntimeClassInfo getScope() {
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeModelBuilder.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeModelBuilder.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -37,8 +37,6 @@ import com.sun.xml.internal.bind.v2.model.annotation.Locatable; import com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader; import com.sun.xml.internal.bind.v2.model.core.ID; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; -import com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeNonElement; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeNonElementRef; import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo; @@ -75,7 +73,7 @@ public final @Nullable JAXBContextImpl context; public RuntimeModelBuilder(JAXBContextImpl context, RuntimeAnnotationReader annotationReader, Map<Class, Class> subclassReplacements, String defaultNamespaceRemap) { - super(annotationReader, Navigator.REFLECTION, subclassReplacements, defaultNamespaceRemap); + super(annotationReader, Utils.REFLECTION_NAVIGATOR, subclassReplacements, defaultNamespaceRemap); this.context = context; } @@ -109,10 +107,6 @@ return new RuntimeArrayInfoImpl(this, upstream, (Class)arrayType); } - public ReflectionNavigator getNavigator() { - return (ReflectionNavigator)nav; - } - @Override protected RuntimeTypeInfoSetImpl createTypeInfoSet() { return new RuntimeTypeInfoSetImpl(reader);
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeTypeInfoSetImpl.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeTypeInfoSetImpl.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -34,9 +34,6 @@ import com.sun.xml.internal.bind.v2.model.annotation.AnnotationReader; import com.sun.xml.internal.bind.v2.model.core.TypeInfoSet; -import com.sun.xml.internal.bind.v2.model.core.NonElement; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; -import com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeNonElement; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet; @@ -47,7 +44,7 @@ */ final class RuntimeTypeInfoSetImpl extends TypeInfoSetImpl<Type,Class,Field,Method> implements RuntimeTypeInfoSet { public RuntimeTypeInfoSetImpl(AnnotationReader<Type,Class,Field,Method> reader) { - super(Navigator.REFLECTION,reader,RuntimeBuiltinLeafInfoImpl.LEAVES); + super(Utils.REFLECTION_NAVIGATOR,reader,RuntimeBuiltinLeafInfoImpl.LEAVES); } @Override @@ -55,10 +52,6 @@ return RuntimeAnyTypeImpl.theInstance; } - public ReflectionNavigator getNavigator() { - return (ReflectionNavigator)super.getNavigator(); - } - public RuntimeNonElement getTypeInfo( Type type ) { return (RuntimeNonElement)super.getTypeInfo(type); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Utils.java Thu Jan 02 09:45:01 2014 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.xml.internal.bind.v2.model.impl; + +import com.sun.xml.internal.bind.v2.model.nav.Navigator; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utils class. + * + * WARNING: If you are doing any changes don't forget to change other Utils classes in different packages. + * + * Has *package private* access to avoid inappropriate usage. + */ +/* package */ final class Utils { + + private static final Logger LOGGER = Logger.getLogger(Utils.class.getName()); + + /** + * static ReflectionNavigator field to avoid usage of reflection every time we use it. + */ + /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR; + + static { // we statically initializing REFLECTION_NAVIGATOR property + Class refNav = null; + try { + refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator"); + //noinspection unchecked + Method getInstance = refNav.getDeclaredMethod("getInstance"); + getInstance.setAccessible(true); + //noinspection unchecked + REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new IllegalStateException("Can't find ReflectionNavigator class"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception"); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance can't be found"); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible"); + } catch (SecurityException e) { + LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e); + throw e; + } + } + + /** + * private constructor to avoid util class instantiating + */ + private Utils() { + } +}
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/Navigator.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/Navigator.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -240,10 +240,6 @@ */ T getComponentType(T t); - - /** The singleton instance. */ - public static final ReflectionNavigator REFLECTION = new ReflectionNavigator(); - /** * Gets the i-th type argument from a parameterized type. * @@ -357,14 +353,14 @@ String getPackageName(C clazz); /** - * Finds the class/interface/enum/annotation of the given name. + * Finds ObjectFactory for the given referencePoint. * * @param referencePoint * The class that refers to the specified class. * @return * null if not found. */ - C findClass(String className, C referencePoint); + C loadObjectFactory(C referencePoint, String packageName); /** * Returns true if this method is a bridge method as defined in JLS.
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/nav/ReflectionNavigator.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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,16 +44,19 @@ * {@link Navigator} implementation for {@code java.lang.reflect}. * */ -public final class ReflectionNavigator implements Navigator<Type, Class, Field, Method> { +/*package*/final class ReflectionNavigator implements Navigator<Type, Class, Field, Method> { + +// ---------- Singleton ----------------- + private static final ReflectionNavigator INSTANCE = new ReflectionNavigator(); - /** - * Singleton. - * - * Use {@link Navigator#REFLECTION} - */ - ReflectionNavigator() { + /*package*/static ReflectionNavigator getInstance() { // accessible through reflection from Utils classes + return INSTANCE; } + private ReflectionNavigator() { + } +// --------------------------------------- + public Class getSuperClass(Class clazz) { if (clazz == Object.class) { return null; @@ -64,6 +67,7 @@ } return sc; } + private static final TypeVisitor<Type, Class> baseClassFinder = new TypeVisitor<Type, Class>() { public Type onClass(Class c, Class sup) { @@ -496,7 +500,7 @@ c.getDeclaredConstructor(); return true; } catch (NoSuchMethodException e) { - return false; + return false; // todo: do this WITHOUT exception throw } } @@ -544,13 +548,15 @@ } } - public Class findClass(String className, Class referencePoint) { + @Override + public Class loadObjectFactory(Class referencePoint, String pkg) { + String clName = pkg + ".ObjectFactory"; + ClassLoader cl = referencePoint.getClassLoader(); + if (cl == null) + cl = ClassLoader.getSystemClassLoader(); + try { - ClassLoader cl = referencePoint.getClassLoader(); - if (cl == null) { - cl = ClassLoader.getSystemClassLoader(); - } - return cl.loadClass(className); + return cl.loadClass(clName); } catch (ClassNotFoundException e) { return null; } @@ -569,7 +575,7 @@ // class Base<T> { // T getX() { ... } // } - // to be overrided. Handling this correctly needs a careful implementation + // to be overriden. Handling this correctly needs a careful implementation String name = method.getName(); Class[] params = method.getParameterTypes();
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/runtime/RuntimeTypeInfoSet.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/runtime/RuntimeTypeInfoSet.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -33,8 +33,6 @@ import javax.xml.namespace.QName; import com.sun.xml.internal.bind.v2.model.core.TypeInfoSet; -import com.sun.xml.internal.bind.v2.model.core.NonElement; -import com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator; /** * {@link TypeInfoSet} refined for runtime. @@ -52,5 +50,4 @@ RuntimeElementInfo getElementInfo( Class scope, QName name ); Map<QName,? extends RuntimeElementInfo> getElementMappings( Class scope ); Iterable<? extends RuntimeElementInfo> getAllElements(); - ReflectionNavigator getNavigator(); }
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ElementBeanInfoImpl.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ElementBeanInfoImpl.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -36,7 +36,6 @@ import com.sun.xml.internal.bind.api.AccessorException; import com.sun.xml.internal.bind.v2.model.core.PropertyKind; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeElementInfo; import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo; import com.sun.xml.internal.bind.v2.runtime.property.Property; @@ -81,10 +80,10 @@ this.property = PropertyFactory.create(grammar,rei.getProperty()); tagName = rei.getElementName(); - expectedType = Navigator.REFLECTION.erasure(rei.getContentInMemoryType()); + expectedType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(rei.getContentInMemoryType()); scope = rei.getScope()==null ? JAXBElement.GlobalScope.class : rei.getScope().getClazz(); - Class type = Navigator.REFLECTION.erasure(rei.getType()); + Class type = (Class) Utils.REFLECTION_NAVIGATOR.erasure(rei.getType()); if(type==JAXBElement.class) constructor = null; else {
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -90,7 +90,6 @@ import com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl; import com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder; import com.sun.xml.internal.bind.v2.model.nav.Navigator; -import com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeArrayInfo; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeBuiltinLeafInfo; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeClassInfo; @@ -358,7 +357,7 @@ beanInfoMap.put( e.getKey(), beanInfoMap.get(e.getValue()) ); // build bridges - ReflectionNavigator nav = typeSet.getNavigator(); + Navigator<Type, Class, Field, Method> nav = typeSet.getNavigator(); for (TypeReference tr : typeRefs) { XmlJavaTypeAdapter xjta = tr.get(XmlJavaTypeAdapter.class); @@ -366,7 +365,7 @@ XmlList xl = tr.get(XmlList.class); // eventually compute the in-memory type - Class erasedType = nav.erasure(tr.type); + Class erasedType = (Class) nav.erasure(tr.type); if(xjta!=null) { a = new Adapter<Type,Class>(xjta.value(),nav); @@ -377,7 +376,7 @@ } if(a!=null) { - erasedType = nav.erasure(a.defaultType); + erasedType = (Class) nav.erasure(a.defaultType); } Name name = nameBuilder.createElementName(tr.tagName); @@ -873,7 +872,7 @@ // this is a special class we introduced for JAX-WS that we *don't* want in the schema } else { NonElement<Type,Class> typeInfo = getXmlType(tis,tr); - xsdgen.add(tr.tagName, !Navigator.REFLECTION.isPrimitive(tr.type),typeInfo); + xsdgen.add(tr.tagName, !tis.getNavigator().isPrimitive(tr.type),typeInfo); } } return xsdgen;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Utils.java Thu Jan 02 09:45:01 2014 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.xml.internal.bind.v2.runtime; + +import com.sun.xml.internal.bind.v2.model.nav.Navigator; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utils class. + * + * WARNING: If you are doing any changes don't forget to change other Utils classes in different packages. + * + * Has *package private* access to avoid inappropriate usage. + */ +/* package */ final class Utils { + + private static final Logger LOGGER = Logger.getLogger(Utils.class.getName()); + + /** + * static ReflectionNavigator field to avoid usage of reflection every time we use it. + */ + /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR; + + static { // we statically initializing REFLECTION_NAVIGATOR property + Class refNav = null; + try { + refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator"); + //noinspection unchecked + Method getInstance = refNav.getDeclaredMethod("getInstance"); + getInstance.setAccessible(true); + //noinspection unchecked + REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new IllegalStateException("Can't find ReflectionNavigator class"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception"); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance can't be found"); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible"); + } catch (SecurityException e) { + LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e); + throw e; + } + } + + /** + * private constructor to avoid util class instantiating + */ + private Utils() { + } +}
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/ArrayProperty.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/ArrayProperty.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -27,7 +27,6 @@ import com.sun.xml.internal.bind.api.AccessorException; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo; import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor; @@ -49,7 +48,7 @@ assert prop.isCollection(); lister = Lister.create( - Navigator.REFLECTION.erasure(prop.getRawType()),prop.id(),prop.getAdapter()); + Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType()),prop.id(),prop.getAdapter()); assert lister!=null; acc = prop.getAccessor().optimize(context); assert acc!=null;
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/SingleMapNodeProperty.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/SingleMapNodeProperty.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -42,7 +42,6 @@ import com.sun.xml.internal.bind.v2.ClassFactory; import com.sun.xml.internal.bind.v2.util.QNameMap; import com.sun.xml.internal.bind.v2.model.core.PropertyKind; -import com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeMapPropertyInfo; import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; import com.sun.xml.internal.bind.v2.runtime.JaxBeanInfo; @@ -98,7 +97,8 @@ this.valueBeanInfo = context.getOrCreate(prop.getValueType()); // infer the implementation class - Class<ValueT> sig = ReflectionNavigator.REFLECTION.erasure(prop.getRawType()); + //noinspection unchecked + Class<ValueT> sig = (Class<ValueT>) Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType()); mapImplClass = ClassFactory.inferImplClass(sig,knownImplClasses); // TODO: error check for mapImplClass==null // what is the error reporting path for this part of the code?
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/Utils.java Thu Jan 02 09:45:01 2014 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.xml.internal.bind.v2.runtime.property; + +import com.sun.xml.internal.bind.v2.model.nav.Navigator; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utils class. + * + * WARNING: If you are doing any changes don't forget to change other Utils classes in different packages. + * + * Has *package private* access to avoid inappropriate usage. + */ +/* package */ final class Utils { + + private static final Logger LOGGER = Logger.getLogger(Utils.class.getName()); + + /** + * static ReflectionNavigator field to avoid usage of reflection every time we use it. + */ + /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR; + + static { // we statically initializing REFLECTION_NAVIGATOR property + Class refNav = null; + try { + refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator"); + //noinspection unchecked + Method getInstance = refNav.getDeclaredMethod("getInstance"); + getInstance.setAccessible(true); + //noinspection unchecked + REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new IllegalStateException("Can't find ReflectionNavigator class"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception"); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance can't be found"); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible"); + } catch (SecurityException e) { + LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e); + throw e; + } + } + + /** + * private constructor to avoid util class instantiating + */ + private Utils() { + } +}
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Accessor.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -48,7 +48,6 @@ import com.sun.xml.internal.bind.api.JAXBRIContext; import com.sun.xml.internal.bind.v2.model.core.Adapter; import com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl; import com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory; import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader; @@ -193,7 +192,7 @@ public final <T> Accessor<BeanT, T> adapt(Adapter<Type, Class> adapter) { return new AdaptedAccessor<BeanT, ValueT, T>( - (Class<T>) Navigator.REFLECTION.erasure(adapter.defaultType), + (Class<T>) Utils.REFLECTION_NAVIGATOR.erasure(adapter.defaultType), this, adapter.adapterType); }
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Lister.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Lister.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -51,7 +51,6 @@ import com.sun.xml.internal.bind.v2.TODO; import com.sun.xml.internal.bind.v2.model.core.Adapter; import com.sun.xml.internal.bind.v2.model.core.ID; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Patcher; import com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext; @@ -116,7 +115,7 @@ public static <BeanT,PropT,ItemT,PackT> Lister<BeanT,PropT,ItemT,PackT> create(Type fieldType,ID idness, Adapter<Type,Class> adapter) { - Class rawType = Navigator.REFLECTION.erasure(fieldType); + Class rawType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(fieldType); Class itemType; Lister l; @@ -125,9 +124,9 @@ l = getArrayLister(itemType); } else if( Collection.class.isAssignableFrom(rawType) ) { - Type bt = Navigator.REFLECTION.getBaseClass(fieldType,Collection.class); + Type bt = Utils.REFLECTION_NAVIGATOR.getBaseClass(fieldType,Collection.class); if(bt instanceof ParameterizedType) - itemType = Navigator.REFLECTION.erasure(((ParameterizedType)bt).getActualTypeArguments()[0]); + itemType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)bt).getActualTypeArguments()[0]); else itemType = Object.class; l = new CollectionLister(getImplClass(rawType));
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/TransducedAccessor.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/TransducedAccessor.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -39,7 +39,6 @@ import com.sun.xml.internal.bind.api.AccessorException; import com.sun.xml.internal.bind.v2.model.core.ID; import com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.bind.v2.model.runtime.RuntimeNonElementRef; import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo; import com.sun.xml.internal.bind.v2.runtime.Name; @@ -144,8 +143,7 @@ if(prop.isCollection()) { return new ListTransducedAccessorImpl(xducer,prop.getAccessor(), - Lister.create(Navigator.REFLECTION.erasure(prop.getRawType()),prop.id(), - prop.getAdapter())); + Lister.create(Utils.REFLECTION_NAVIGATOR.erasure(prop.getRawType()), prop.id(), prop.getAdapter())); } if(prop.id()==ID.IDREF)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Utils.java Thu Jan 02 09:45:01 2014 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.xml.internal.bind.v2.runtime.reflect; + +import com.sun.xml.internal.bind.v2.model.nav.Navigator; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utils class. + * + * WARNING: If you are doing any changes don't forget to change other Utils classes in different packages. + * + * Has *package private* access to avoid inappropriate usage. + */ +/* package */ final class Utils { + + private static final Logger LOGGER = Logger.getLogger(Utils.class.getName()); + + /** + * static ReflectionNavigator field to avoid usage of reflection every time we use it. + */ + /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR; + + static { // we statically initializing REFLECTION_NAVIGATOR property + Class refNav = null; + try { + refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator"); + //noinspection unchecked + Method getInstance = refNav.getDeclaredMethod("getInstance"); + getInstance.setAccessible(true); + //noinspection unchecked + REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new IllegalStateException("Can't find ReflectionNavigator class"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception"); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance can't be found"); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible"); + } catch (SecurityException e) { + LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e); + throw e; + } + } + + /** + * private constructor to avoid util class instantiating + */ + private Utils() { + } +}
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/fault/SOAPFaultBuilder.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -59,6 +59,12 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.ReflectPermission; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.Permissions; +import java.security.PrivilegedAction; +import java.security.ProtectionDomain; import java.util.Iterator; import java.util.Map; import java.util.logging.Level; @@ -546,10 +552,40 @@ // ignore } - try { - JAXB_CONTEXT = (JAXBRIContext)JAXBContext.newInstance(SOAP11Fault.class, SOAP12Fault.class); - } catch (JAXBException e) { - throw new Error(e); // this must be a bug in our code + JAXB_CONTEXT = createJAXBContext(); + } + + private static JAXBRIContext createJAXBContext() { + + // in jdk runtime doPrivileged is necessary since JAX-WS internal classes are in restricted packages + if (isJDKRuntime()) { + Permissions permissions = new Permissions(); + permissions.add(new RuntimePermission("accessClassInPackage.com.sun." + "xml.internal.ws.fault")); + permissions.add(new ReflectPermission("suppressAccessChecks")); + return AccessController.doPrivileged( + new PrivilegedAction<JAXBRIContext>() { + @Override + public JAXBRIContext run() { + try { + return (JAXBRIContext) JAXBContext.newInstance(SOAP11Fault.class, SOAP12Fault.class); + } catch (JAXBException e) { + throw new Error(e); + } + } + }, + new AccessControlContext(new ProtectionDomain[]{new ProtectionDomain(null, permissions)}) + ); + + } else { + try { + return (JAXBRIContext) JAXBContext.newInstance(SOAP11Fault.class, SOAP12Fault.class); + } catch (JAXBException e) { + throw new Error(e); + } } } + + private static boolean isJDKRuntime() { + return SOAPFaultBuilder.class.getName().contains("internal"); + } }
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/model/RuntimeModeler.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/model/RuntimeModeler.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -28,7 +28,6 @@ import com.sun.istack.internal.NotNull; import com.sun.xml.internal.bind.api.CompositeStructure; import com.sun.xml.internal.bind.api.TypeReference; -import com.sun.xml.internal.bind.v2.model.nav.Navigator; import com.sun.xml.internal.ws.api.BindingID; import com.sun.xml.internal.ws.api.SOAPVersion; import com.sun.xml.internal.ws.api.model.ExceptionType; @@ -735,7 +734,7 @@ //set the actual type argument of Holder in the TypeReference if (isHolder) { if(clazzType==Holder.class){ - clazzType = Navigator.REFLECTION.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]); + clazzType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]); } } Mode paramMode = isHolder ? Mode.INOUT : Mode.IN; @@ -932,7 +931,7 @@ //set the actual type argument of Holder in the TypeReference if (isHolder) { if (clazzType==Holder.class) - clazzType = Navigator.REFLECTION.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]); + clazzType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]); } Mode paramMode = isHolder ? Mode.INOUT : Mode.IN; for (Annotation annotation : pannotations[pos]) { @@ -1172,7 +1171,7 @@ //set the actual type argument of Holder in the TypeReference if (isHolder) { if (clazzType==Holder.class) - clazzType = Navigator.REFLECTION.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]); + clazzType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]); } Mode paramMode = isHolder ? Mode.INOUT : Mode.IN; @@ -1258,14 +1257,14 @@ private Class getAsyncReturnType(Method method, Class returnType) { if(Response.class.isAssignableFrom(returnType)){ Type ret = method.getGenericReturnType(); - return Navigator.REFLECTION.erasure(((ParameterizedType)ret).getActualTypeArguments()[0]); + return (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)ret).getActualTypeArguments()[0]); }else{ Type[] types = method.getGenericParameterTypes(); Class[] params = method.getParameterTypes(); int i = 0; for(Class cls : params){ if(AsyncHandler.class.isAssignableFrom(cls)){ - return Navigator.REFLECTION.erasure(((ParameterizedType)types[i]).getActualTypeArguments()[0]); + return (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)types[i]).getActualTypeArguments()[0]); } i++; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/model/Utils.java Thu Jan 02 09:45:01 2014 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.xml.internal.ws.model; + +import com.sun.xml.internal.bind.v2.model.nav.Navigator; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utils class. + * + * WARNING: If you are doing any changes don't forget to change other Utils classes in different packages. + * + * Has *package private* access to avoid inappropriate usage. + */ +/* package */ final class Utils { + + private static final Logger LOGGER = Logger.getLogger(Utils.class.getName()); + + /** + * static ReflectionNavigator field to avoid usage of reflection every time we use it. + */ + /* package */ static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR; + + static { // we statically initializing REFLECTION_NAVIGATOR property + Class refNav = null; + try { + refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator"); + //noinspection unchecked + Method getInstance = refNav.getDeclaredMethod("getInstance"); + getInstance.setAccessible(true); + //noinspection unchecked + REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new IllegalStateException("Can't find ReflectionNavigator class"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception"); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance can't be found"); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible"); + } catch (SecurityException e) { + LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e); + throw e; + } + } + + /** + * private constructor to avoid util class instantiating + */ + private Utils() { + } +}
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/model/WrapperBeanGenerator.java Wed Dec 18 15:56:48 2013 -0800 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/model/WrapperBeanGenerator.java Thu Jan 02 09:45:01 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2013, 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 @@ -61,7 +61,7 @@ private static final AbstractWrapperBeanGenerator RUNTIME_GENERATOR = new RuntimeWrapperBeanGenerator(new RuntimeInlineAnnotationReader(), - Navigator.REFLECTION, FIELD_FACTORY); + Utils.REFLECTION_NAVIGATOR, FIELD_FACTORY); private static final class RuntimeWrapperBeanGenerator extends AbstractWrapperBeanGenerator<java.lang.reflect.Type, Class, java.lang.reflect.Method, Field> {