8010935: Better XML handling
8027378: Two closed/javax/xml/8005432 fails with jdk7u51b04 8028382: Two javax/xml/8005433 tests still fail after the fix JDK-8028147 Base fix + fixes for test regressions; fix also reviewed by Maxim Soloviev, Alexander Fomin Reviewed-by: mchung, mgrebac, mullan
This commit is contained in:
parent
805a34ccbe
commit
81ebc43924
@ -65,7 +65,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
|
||||
*/
|
||||
public class ApNavigator implements Navigator<TypeMirror, TypeElement, VariableElement, ExecutableElement> {
|
||||
public final class ApNavigator implements Navigator<TypeMirror, TypeElement, VariableElement, ExecutableElement> {
|
||||
|
||||
private final ProcessingEnvironment env;
|
||||
|
||||
@ -236,7 +236,7 @@ public class ApNavigator implements Navigator<TypeMirror, TypeElement, VariableE
|
||||
}
|
||||
|
||||
public boolean isFinal(TypeElement clazz) {
|
||||
return hasModifier(clazz,Modifier.FINAL);
|
||||
return hasModifier(clazz, Modifier.FINAL);
|
||||
}
|
||||
|
||||
public VariableElement[] getEnumConstants(TypeElement clazz) {
|
||||
@ -258,8 +258,9 @@ public class ApNavigator implements Navigator<TypeMirror, TypeElement, VariableE
|
||||
return env.getElementUtils().getPackageOf(clazz).getQualifiedName().toString();
|
||||
}
|
||||
|
||||
public TypeElement findClass(String className, TypeElement referencePoint) {
|
||||
return env.getElementUtils().getTypeElement(className);
|
||||
@Override
|
||||
public TypeElement loadObjectFactory(TypeElement referencePoint, String packageName) {
|
||||
return env.getElementUtils().getTypeElement(packageName + ".ObjectFactory");
|
||||
}
|
||||
|
||||
public boolean isBridgeMethod(ExecutableElement method) {
|
||||
|
@ -30,7 +30,6 @@ import java.lang.reflect.Type;
|
||||
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 @@ class EagerNType implements NType {
|
||||
}
|
||||
|
||||
public String fullName() {
|
||||
return Navigator.REFLECTION.getTypeName(t);
|
||||
return Utils.REFLECTION_NAVIGATOR.getTypeName(t);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public final class NavigatorImpl implements Navigator<NType,NClass,Void,Void> {
|
||||
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 final class NavigatorImpl implements Navigator<NType,NClass,Void,Void> {
|
||||
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 final class NavigatorImpl implements Navigator<NType,NClass,Void,Void> {
|
||||
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;
|
||||
@ -304,8 +304,8 @@ public final class NavigatorImpl implements Navigator<NType,NClass,Void,Void> {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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() {
|
||||
}
|
||||
}
|
@ -45,7 +45,6 @@ import com.sun.istack.internal.Nullable;
|
||||
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;
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -417,7 +416,7 @@ public abstract class JAXBRIContext extends JAXBContext {
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,6 @@ import java.util.Collection;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
|
||||
|
||||
/**
|
||||
* A reference to a JAXB-bound type.
|
||||
*
|
||||
@ -105,12 +103,11 @@ public final class TypeReference {
|
||||
// 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));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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() {
|
||||
}
|
||||
}
|
@ -289,23 +289,12 @@ public class ModelBuilder<T,C,F,M> implements ModelBuilderI<T,C,F,M> {
|
||||
String pkg = nav.getPackageName(clazz);
|
||||
if (!registries.containsKey(pkg)) {
|
||||
// insert the package's object factory
|
||||
C c = loadObjectFactory(clazz, pkg);
|
||||
C c = nav.loadObjectFactory(clazz, pkg);
|
||||
if (c != null)
|
||||
addRegistry(c, p);
|
||||
}
|
||||
}
|
||||
|
||||
private C loadObjectFactory(C clazz, String pkg) {
|
||||
C c;
|
||||
try {
|
||||
c = nav.findClass(pkg + ".ObjectFactory", clazz);
|
||||
} catch (SecurityException ignored) {
|
||||
// treat SecurityException in same way as ClassNotFoundException in this case
|
||||
c = null;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting parametrized classes of {@code JAXBElement<...>} property
|
||||
* @param p property which parametrized types we will try to get
|
||||
|
@ -36,7 +36,7 @@ import com.sun.xml.internal.bind.v2.runtime.Transducer;
|
||||
*/
|
||||
final class RuntimeAnyTypeImpl extends AnyTypeImpl<Type,Class> implements RuntimeNonElement {
|
||||
private RuntimeAnyTypeImpl() {
|
||||
super(Navigator.REFLECTION);
|
||||
super(Utils.REFLECTION_NAVIGATOR);
|
||||
}
|
||||
|
||||
public <V> Transducer<V> getTransducer() {
|
||||
|
@ -91,9 +91,6 @@ import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data;
|
||||
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext;
|
||||
import com.sun.xml.internal.bind.v2.util.ByteArrayOutputStreamEx;
|
||||
import com.sun.xml.internal.bind.v2.util.DataSourceSource;
|
||||
import java.util.logging.Logger;
|
||||
import com.sun.xml.internal.bind.Util;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
@ -108,8 +105,6 @@ import org.xml.sax.SAXException;
|
||||
public abstract class RuntimeBuiltinLeafInfoImpl<T> extends BuiltinLeafInfoImpl<Type,Class>
|
||||
implements RuntimeBuiltinLeafInfo, Transducer<T> {
|
||||
|
||||
private static final Logger logger = Util.getClassLogger();
|
||||
|
||||
private RuntimeBuiltinLeafInfoImpl(Class type, QName... typeNames) {
|
||||
super(type, typeNames);
|
||||
LEAVES.put(type,this);
|
||||
@ -201,7 +196,6 @@ public abstract class RuntimeBuiltinLeafInfoImpl<T> extends BuiltinLeafInfoImpl<
|
||||
public static final List<RuntimeBuiltinLeafInfoImpl<?>> builtinBeanInfos;
|
||||
|
||||
public static final String MAP_ANYURI_TO_URI = "mapAnyUriToUri";
|
||||
public static final String USE_OLD_GMONTH_MAPPING = "jaxb.ri.useOldGmonthMapping";
|
||||
|
||||
static {
|
||||
|
||||
@ -966,14 +960,7 @@ public abstract class RuntimeBuiltinLeafInfoImpl<T> extends BuiltinLeafInfoImpl<
|
||||
m.put(DatatypeConstants.DATETIME, "%Y-%M-%DT%h:%m:%s"+ "%z");
|
||||
m.put(DatatypeConstants.DATE, "%Y-%M-%D" +"%z");
|
||||
m.put(DatatypeConstants.TIME, "%h:%m:%s"+ "%z");
|
||||
if (System.getProperty(USE_OLD_GMONTH_MAPPING) == null) {
|
||||
m.put(DatatypeConstants.GMONTH, "--%M%z"); // E2-12 Error. http://www.w3.org/2001/05/xmlschema-errata#e2-12
|
||||
} else { // backw. compatibility
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, "Old GMonth mapping used.");
|
||||
}
|
||||
m.put(DatatypeConstants.GMONTH, "--%M--%z");
|
||||
}
|
||||
m.put(DatatypeConstants.GMONTH, "--%M--%z");
|
||||
m.put(DatatypeConstants.GDAY, "---%D" + "%z");
|
||||
m.put(DatatypeConstants.GYEAR, "%Y" + "%z");
|
||||
m.put(DatatypeConstants.GYEARMONTH, "%Y-%M" + "%z");
|
||||
|
@ -42,7 +42,6 @@ import com.sun.xml.internal.bind.v2.model.runtime.RuntimeElementPropertyInfo;
|
||||
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,8 @@ final class RuntimeElementInfoImpl extends ElementInfoImpl<Type,Class,Field,Meth
|
||||
}
|
||||
|
||||
public Class<? extends JAXBElement> getType() {
|
||||
return Navigator.REFLECTION.erasure(super.getType());
|
||||
//noinspection unchecked
|
||||
return (Class<? extends JAXBElement>) Utils.REFLECTION_NAVIGATOR.erasure(super.getType());
|
||||
}
|
||||
|
||||
public RuntimeClassInfo getScope() {
|
||||
|
@ -38,7 +38,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 +74,7 @@ public class RuntimeModelBuilder extends ModelBuilder<Type,Class,Field,Method> {
|
||||
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 +108,6 @@ public class RuntimeModelBuilder extends ModelBuilder<Type,Class,Field,Method> {
|
||||
return new RuntimeArrayInfoImpl(this, upstream, (Class)arrayType);
|
||||
}
|
||||
|
||||
public ReflectionNavigator getNavigator() {
|
||||
return (ReflectionNavigator)nav;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RuntimeTypeInfoSetImpl createTypeInfoSet() {
|
||||
return new RuntimeTypeInfoSetImpl(reader);
|
||||
|
@ -35,7 +35,6 @@ import javax.xml.namespace.QName;
|
||||
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.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;
|
||||
|
||||
@ -46,7 +45,7 @@ import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet;
|
||||
*/
|
||||
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
|
||||
@ -54,10 +53,6 @@ final class RuntimeTypeInfoSetImpl extends TypeInfoSetImpl<Type,Class,Field,Meth
|
||||
return RuntimeAnyTypeImpl.theInstance;
|
||||
}
|
||||
|
||||
public ReflectionNavigator getNavigator() {
|
||||
return (ReflectionNavigator)super.getNavigator();
|
||||
}
|
||||
|
||||
public RuntimeNonElement getTypeInfo( Type type ) {
|
||||
return (RuntimeNonElement)super.getTypeInfo(type);
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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() {
|
||||
}
|
||||
}
|
@ -25,6 +25,10 @@
|
||||
|
||||
package com.sun.xml.internal.bind.v2.model.nav;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.xml.internal.bind.v2.runtime.Location;
|
||||
@ -240,10 +244,6 @@ public interface Navigator<T,C,F,M> {
|
||||
*/
|
||||
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 +357,14 @@ public interface Navigator<T,C,F,M> {
|
||||
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.
|
||||
|
@ -44,16 +44,19 @@ import com.sun.xml.internal.bind.v2.runtime.Location;
|
||||
* {@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.
|
||||
*
|
||||
* Use {@link Navigator#REFLECTION}
|
||||
*/
|
||||
ReflectionNavigator() {
|
||||
// ---------- Singleton -----------------
|
||||
private static final ReflectionNavigator INSTANCE = new ReflectionNavigator();
|
||||
|
||||
/*package*/static ReflectionNavigator getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private ReflectionNavigator() {
|
||||
}
|
||||
// ---------------------------------------
|
||||
|
||||
public Class getSuperClass(Class clazz) {
|
||||
if (clazz == Object.class) {
|
||||
return null;
|
||||
@ -64,6 +67,7 @@ public final class ReflectionNavigator implements Navigator<Type, Class, Field,
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
|
||||
private static final TypeVisitor<Type, Class> baseClassFinder = new TypeVisitor<Type, Class>() {
|
||||
|
||||
public Type onClass(Class c, Class sup) {
|
||||
@ -496,7 +500,7 @@ public final class ReflectionNavigator implements Navigator<Type, Class, Field,
|
||||
c.getDeclaredConstructor();
|
||||
return true;
|
||||
} catch (NoSuchMethodException e) {
|
||||
return false;
|
||||
return false; // todo: do this WITHOUT exception throw
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,13 +548,14 @@ public final class ReflectionNavigator implements Navigator<Type, Class, Field,
|
||||
}
|
||||
}
|
||||
|
||||
public Class findClass(String className, Class referencePoint) {
|
||||
@Override
|
||||
public Class loadObjectFactory(Class referencePoint, String pkg) {
|
||||
ClassLoader cl= SecureLoader.getClassClassLoader(referencePoint);
|
||||
if (cl == null)
|
||||
cl = SecureLoader.getSystemClassLoader();
|
||||
|
||||
try {
|
||||
ClassLoader cl = SecureLoader.getClassClassLoader(referencePoint);
|
||||
if (cl == null) {
|
||||
cl = SecureLoader.getSystemClassLoader();
|
||||
}
|
||||
return cl.loadClass(className);
|
||||
return cl.loadClass(pkg + ".ObjectFactory");
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import java.util.Map;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.bind.v2.model.core.TypeInfoSet;
|
||||
import com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator;
|
||||
|
||||
/**
|
||||
* {@link TypeInfoSet} refined for runtime.
|
||||
@ -51,5 +50,4 @@ public interface RuntimeTypeInfoSet extends TypeInfoSet<Type,Class,Field,Method>
|
||||
RuntimeElementInfo getElementInfo( Class scope, QName name );
|
||||
Map<QName,? extends RuntimeElementInfo> getElementMappings( Class scope );
|
||||
Iterable<? extends RuntimeElementInfo> getAllElements();
|
||||
ReflectionNavigator getNavigator();
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ import com.sun.xml.internal.bind.api.AccessorException;
|
||||
import com.sun.xml.internal.bind.v2.ClassFactory;
|
||||
import com.sun.xml.internal.bind.v2.WellKnownNamespace;
|
||||
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.runtime.RuntimeClassInfo;
|
||||
import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo;
|
||||
import com.sun.xml.internal.bind.v2.runtime.property.AttributeProperty;
|
||||
@ -347,7 +346,7 @@ public final class ClassBeanInfoImpl<BeanT> extends JaxBeanInfo<BeanT> implement
|
||||
} else if (isThereAnOverridingProperty) {
|
||||
// need to double check the override - it should be safe to do after the model has been created because it's targeted to override properties only
|
||||
Class beanClass = bean.getClass();
|
||||
if (Navigator.REFLECTION.getDeclaredField(beanClass, p.getFieldName()) == null) {
|
||||
if (Utils.REFLECTION_NAVIGATOR.getDeclaredField(beanClass, p.getFieldName()) == null) {
|
||||
p.serializeBody(bean, target, null);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import javax.xml.stream.XMLStreamException;
|
||||
|
||||
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 @@ public final class ElementBeanInfoImpl extends JaxBeanInfo<JAXBElement> {
|
||||
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 {
|
||||
|
@ -65,7 +65,6 @@ import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.sax.SAXResult;
|
||||
import javax.xml.transform.sax.SAXTransformerFactory;
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
@ -90,7 +89,6 @@ import com.sun.xml.internal.bind.v2.model.core.Ref;
|
||||
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;
|
||||
@ -118,7 +116,6 @@ import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* This class provides the implementation of JAXBContext.
|
||||
@ -363,7 +360,7 @@ public final class JAXBContextImpl extends JAXBRIContext {
|
||||
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);
|
||||
@ -371,7 +368,7 @@ public final class JAXBContextImpl extends JAXBRIContext {
|
||||
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);
|
||||
@ -382,7 +379,7 @@ public final class JAXBContextImpl extends JAXBRIContext {
|
||||
}
|
||||
|
||||
if(a!=null) {
|
||||
erasedType = nav.erasure(a.defaultType);
|
||||
erasedType = (Class) nav.erasure(a.defaultType);
|
||||
}
|
||||
|
||||
Name name = nameBuilder.createElementName(tr.tagName);
|
||||
@ -877,7 +874,7 @@ public final class JAXBContextImpl extends JAXBRIContext {
|
||||
// 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;
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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() {
|
||||
}
|
||||
}
|
@ -27,7 +27,6 @@ package com.sun.xml.internal.bind.v2.runtime.property;
|
||||
|
||||
|
||||
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 @@ abstract class ArrayProperty<BeanT,ListT,ItemT> extends PropertyImpl<BeanT> {
|
||||
|
||||
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;
|
||||
|
@ -42,7 +42,6 @@ import com.sun.xml.internal.bind.api.AccessorException;
|
||||
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 @@ final class SingleMapNodeProperty<BeanT,ValueT extends Map> extends PropertyImpl
|
||||
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?
|
||||
@ -140,23 +140,22 @@ final class SingleMapNodeProperty<BeanT,ValueT extends Map> extends PropertyImpl
|
||||
*/
|
||||
private final Loader itemsLoader = new Loader(false) {
|
||||
|
||||
private ThreadLocal<Stack<BeanT>> target = new ThreadLocal<Stack<BeanT>>();
|
||||
private ThreadLocal<Stack<ValueT>> map = new ThreadLocal<Stack<ValueT>>();
|
||||
private ThreadLocal<BeanT> target = new ThreadLocal<BeanT>();
|
||||
private ThreadLocal<ValueT> map = new ThreadLocal<ValueT>();
|
||||
private int depthCounter = 0; // needed to clean ThreadLocals
|
||||
|
||||
@Override
|
||||
public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException {
|
||||
// create or obtain the Map object
|
||||
try {
|
||||
BeanT target = (BeanT) state.prev.target;
|
||||
ValueT mapValue = acc.get(target);
|
||||
if(mapValue == null)
|
||||
mapValue = ClassFactory.create(mapImplClass);
|
||||
else
|
||||
mapValue.clear();
|
||||
|
||||
Stack.push(this.target, target);
|
||||
Stack.push(map, mapValue);
|
||||
state.target = mapValue;
|
||||
target.set((BeanT)state.prev.target);
|
||||
map.set(acc.get(target.get()));
|
||||
depthCounter++;
|
||||
if(map.get() == null) {
|
||||
map.set(ClassFactory.create(mapImplClass));
|
||||
}
|
||||
map.get().clear();
|
||||
state.target = map.get();
|
||||
} catch (AccessorException e) {
|
||||
// recover from error by setting a dummy Map that receives and discards the values
|
||||
handleGenericException(e,true);
|
||||
@ -168,7 +167,11 @@ final class SingleMapNodeProperty<BeanT,ValueT extends Map> extends PropertyImpl
|
||||
public void leaveElement(State state, TagName ea) throws SAXException {
|
||||
super.leaveElement(state, ea);
|
||||
try {
|
||||
acc.set(Stack.pop(target), Stack.pop(map));
|
||||
acc.set(target.get(), map.get());
|
||||
if (--depthCounter == 0) {
|
||||
target.remove();
|
||||
map.remove();
|
||||
}
|
||||
} catch (AccessorException ex) {
|
||||
handleGenericException(ex,true);
|
||||
}
|
||||
@ -286,36 +289,4 @@ final class SingleMapNodeProperty<BeanT,ValueT extends Map> extends PropertyImpl
|
||||
return acc;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final class Stack<T> {
|
||||
private Stack<T> parent;
|
||||
private T value;
|
||||
|
||||
private Stack(Stack<T> parent, T value) {
|
||||
this.parent = parent;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private Stack(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private static <T> void push(ThreadLocal<Stack<T>> holder, T value) {
|
||||
Stack<T> parent = holder.get();
|
||||
if (parent == null)
|
||||
holder.set(new Stack<T>(value));
|
||||
else
|
||||
holder.set(new Stack<T>(parent, value));
|
||||
}
|
||||
|
||||
private static <T> T pop(ThreadLocal<Stack<T>> holder) {
|
||||
Stack<T> current = holder.get();
|
||||
if (current.parent == null)
|
||||
holder.remove();
|
||||
else
|
||||
holder.set(current.parent);
|
||||
return current.value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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() {
|
||||
}
|
||||
}
|
@ -46,7 +46,6 @@ import com.sun.xml.internal.bind.api.AccessorException;
|
||||
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;
|
||||
@ -198,7 +197,7 @@ public abstract class Accessor<BeanT, ValueT> implements Receiver {
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ import com.sun.xml.internal.bind.v2.ClassFactory;
|
||||
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 abstract class Lister<BeanT,PropT,ItemT,PackT> {
|
||||
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 @@ public abstract class Lister<BeanT,PropT,ItemT,PackT> {
|
||||
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));
|
||||
|
@ -39,7 +39,6 @@ import com.sun.xml.internal.bind.WhiteSpaceProcessor;
|
||||
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 @@ public abstract class TransducedAccessor<BeanT> {
|
||||
|
||||
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)
|
||||
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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() {
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, 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
|
||||
@ -58,6 +58,12 @@ import javax.xml.ws.soap.SOAPFaultException;
|
||||
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;
|
||||
@ -556,11 +562,40 @@ public abstract class SOAPFaultBuilder {
|
||||
// ignore
|
||||
}
|
||||
captureStackTrace = tmpVal;
|
||||
JAXB_CONTEXT = createJAXBContext();
|
||||
}
|
||||
|
||||
try {
|
||||
JAXB_CONTEXT = JAXBContext.newInstance(SOAP11Fault.class, SOAP12Fault.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new Error(e); // this must be a bug in our code
|
||||
private static JAXBContext 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<JAXBContext>() {
|
||||
@Override
|
||||
public JAXBContext run() {
|
||||
try {
|
||||
return JAXBContext.newInstance(SOAP11Fault.class, SOAP12Fault.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
new AccessControlContext(new ProtectionDomain[]{new ProtectionDomain(null, permissions)})
|
||||
);
|
||||
|
||||
} else {
|
||||
try {
|
||||
return JAXBContext.newInstance(SOAP11Fault.class, SOAP12Fault.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isJDKRuntime() {
|
||||
return SOAPFaultBuilder.class.getName().contains("internal");
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ import com.sun.xml.internal.ws.model.soap.SOAPBindingImpl;
|
||||
import com.sun.xml.internal.ws.resources.ModelerMessages;
|
||||
import com.sun.xml.internal.ws.resources.ServerMessages;
|
||||
import com.sun.xml.internal.ws.spi.db.BindingContext;
|
||||
import com.sun.xml.internal.ws.spi.db.BindingHelper;
|
||||
import com.sun.xml.internal.ws.spi.db.TypeInfo;
|
||||
import com.sun.xml.internal.ws.spi.db.WrapperComposite;
|
||||
|
||||
@ -886,7 +885,7 @@ public class RuntimeModeler {
|
||||
//set the actual type argument of Holder in the TypeReference
|
||||
if (isHolder) {
|
||||
if(clazzType==Holder.class){
|
||||
clazzType = BindingHelper.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
|
||||
clazzType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
|
||||
}
|
||||
}
|
||||
Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
|
||||
@ -1101,7 +1100,7 @@ public class RuntimeModeler {
|
||||
//set the actual type argument of Holder in the TypeReference
|
||||
if (isHolder) {
|
||||
if (clazzType==Holder.class)
|
||||
clazzType = BindingHelper.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]) {
|
||||
@ -1347,7 +1346,7 @@ public class RuntimeModeler {
|
||||
//set the actual type argument of Holder in the TypeReference
|
||||
if (isHolder) {
|
||||
if (clazzType==Holder.class)
|
||||
clazzType = BindingHelper.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
|
||||
clazzType = (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)genericParameterTypes[pos]).getActualTypeArguments()[0]);
|
||||
}
|
||||
|
||||
Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
|
||||
@ -1435,14 +1434,14 @@ public class RuntimeModeler {
|
||||
private Class getAsyncReturnType(Method method, Class returnType) {
|
||||
if(Response.class.isAssignableFrom(returnType)){
|
||||
Type ret = method.getGenericReturnType();
|
||||
return BindingHelper.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 BindingHelper.erasure(((ParameterizedType)types[i]).getActualTypeArguments()[0]);
|
||||
return (Class) Utils.REFLECTION_NAVIGATOR.erasure(((ParameterizedType)types[i]).getActualTypeArguments()[0]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -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() {
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@ public class WrapperBeanGenerator {
|
||||
|
||||
private static final AbstractWrapperBeanGenerator RUNTIME_GENERATOR =
|
||||
new RuntimeWrapperBeanGenerator(new RuntimeInlineAnnotationReader(),
|
||||
Navigator.REFLECTION, FIELD_FACTORY);
|
||||
(Navigator<java.lang.reflect.Type, Class, ?, Method>) Utils.REFLECTION_NAVIGATOR, FIELD_FACTORY);
|
||||
|
||||
private static final class RuntimeWrapperBeanGenerator extends AbstractWrapperBeanGenerator<java.lang.reflect.Type, Class, java.lang.reflect.Method, Field> {
|
||||
|
||||
|
@ -136,10 +136,10 @@ public class BindingHelper {
|
||||
* @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);
|
||||
}
|
||||
|
||||
public static <T> Class<T> erasure(Type t) {
|
||||
return Navigator.REFLECTION.erasure(t);
|
||||
return (Class<T>) Utils.REFLECTION_NAVIGATOR.erasure(t);
|
||||
}
|
||||
}
|
||||
|
@ -119,12 +119,11 @@ public final class TypeInfo {
|
||||
// if we are to reinstitute this check, check JAXB annotations only
|
||||
// assert annotations.length==0; // not designed to work with adapters.
|
||||
Type t = (genericType != null)? genericType : type;
|
||||
Type base = Navigator.REFLECTION.getBaseClass(t, Collection.class);
|
||||
Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(t, Collection.class);
|
||||
if(base==null)
|
||||
return this; // not a collection
|
||||
|
||||
return new TypeInfo(tagName,
|
||||
Navigator.REFLECTION.getTypeArgument(base,0));
|
||||
return new TypeInfo(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0));
|
||||
}
|
||||
|
||||
public Map<String, Object> properties() {
|
||||
@ -188,9 +187,9 @@ public final class TypeInfo {
|
||||
}
|
||||
// if (type instanceof Class && java.util.Collection.class.isAssignableFrom((Class)type)) {
|
||||
Type t = (genericType != null)? genericType : type;
|
||||
Type base = Navigator.REFLECTION.getBaseClass(t, Collection.class);
|
||||
Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(t, Collection.class);
|
||||
if ( base != null) {
|
||||
return new TypeInfo(tagName, Navigator.REFLECTION.getTypeArgument(base,0), annotations);
|
||||
return new TypeInfo(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0), annotations);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -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.spi.db;
|
||||
|
||||
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() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user