feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 java.lang.reflect.Modifier;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.codemodel.internal.JClass;
|
||||
import com.sun.tools.internal.xjc.outline.Aspect;
|
||||
import com.sun.tools.internal.xjc.outline.Outline;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class EagerNClass extends EagerNType implements NClass {
|
||||
/*package*/ final Class c;
|
||||
|
||||
public EagerNClass(Class type) {
|
||||
super(type);
|
||||
this.c = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBoxedType() {
|
||||
return boxedTypes.contains(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JClass toType(Outline o, Aspect aspect) {
|
||||
return o.getCodeModel().ref(c);
|
||||
}
|
||||
|
||||
public boolean isAbstract() {
|
||||
return Modifier.isAbstract(c.getModifiers());
|
||||
}
|
||||
|
||||
private static final Set<Class> boxedTypes = new HashSet<Class>();
|
||||
|
||||
static {
|
||||
boxedTypes.add(Boolean.class);
|
||||
boxedTypes.add(Character.class);
|
||||
boxedTypes.add(Byte.class);
|
||||
boxedTypes.add(Short.class);
|
||||
boxedTypes.add(Integer.class);
|
||||
boxedTypes.add(Long.class);
|
||||
boxedTypes.add(Float.class);
|
||||
boxedTypes.add(Double.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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 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;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
class EagerNType implements NType {
|
||||
/*package*/ final Type t;
|
||||
|
||||
public EagerNType(Type type) {
|
||||
this.t = type;
|
||||
assert t!=null;
|
||||
}
|
||||
|
||||
public JType toType(Outline o, Aspect aspect) {
|
||||
try {
|
||||
return o.getCodeModel().parseType(t.toString());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof EagerNType)) return false;
|
||||
|
||||
final EagerNType eagerNType = (EagerNType) o;
|
||||
|
||||
return t.equals(eagerNType.t);
|
||||
}
|
||||
|
||||
public boolean isBoxedType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return t.hashCode();
|
||||
}
|
||||
|
||||
public String fullName() {
|
||||
return Utils.REFLECTION_NAVIGATOR.getTypeName(t);
|
||||
}
|
||||
}
|
||||
39
jdkSrc/jdk8/com/sun/tools/internal/xjc/model/nav/NClass.java
Normal file
39
jdkSrc/jdk8/com/sun/tools/internal/xjc/model/nav/NClass.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.codemodel.internal.JClass;
|
||||
import com.sun.tools.internal.xjc.outline.Aspect;
|
||||
import com.sun.tools.internal.xjc.outline.Outline;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface NClass extends NType {
|
||||
JClass toType(Outline o, Aspect aspect);
|
||||
|
||||
boolean isAbstract();
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.codemodel.internal.JClass;
|
||||
import com.sun.tools.internal.xjc.outline.Aspect;
|
||||
import com.sun.tools.internal.xjc.outline.Outline;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
class NClassByJClass implements NClass {
|
||||
/*package*/ final JClass clazz;
|
||||
|
||||
NClassByJClass(JClass clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public JClass toType(Outline o, Aspect aspect) {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public boolean isAbstract() {
|
||||
return clazz.isAbstract();
|
||||
}
|
||||
|
||||
public boolean isBoxedType() {
|
||||
return clazz.getPrimitiveType()!=null;
|
||||
}
|
||||
|
||||
public String fullName() {
|
||||
return clazz.fullName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.codemodel.internal.JClass;
|
||||
import com.sun.tools.internal.xjc.outline.Aspect;
|
||||
import com.sun.tools.internal.xjc.outline.Outline;
|
||||
|
||||
/**
|
||||
* Parameterized type.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
final class NParameterizedType implements NClass {
|
||||
|
||||
final NClass rawType;
|
||||
final NType[] args;
|
||||
|
||||
NParameterizedType(NClass rawType, NType[] args) {
|
||||
this.rawType = rawType;
|
||||
this.args = args;
|
||||
assert args.length>0;
|
||||
}
|
||||
|
||||
public JClass toType(Outline o, Aspect aspect) {
|
||||
JClass r = rawType.toType(o,aspect);
|
||||
|
||||
for( NType arg : args )
|
||||
r = r.narrow(arg.toType(o,aspect).boxify());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
public boolean isAbstract() {
|
||||
return rawType.isAbstract();
|
||||
}
|
||||
|
||||
public boolean isBoxedType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public String fullName() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(rawType.fullName());
|
||||
buf.append('<');
|
||||
for( int i=0; i<args.length; i++ ) {
|
||||
if(i!=0)
|
||||
buf.append(',');
|
||||
buf.append(args[i].fullName());
|
||||
}
|
||||
buf.append('>');
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
77
jdkSrc/jdk8/com/sun/tools/internal/xjc/model/nav/NType.java
Normal file
77
jdkSrc/jdk8/com/sun/tools/internal/xjc/model/nav/NType.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.codemodel.internal.JType;
|
||||
import com.sun.tools.internal.xjc.outline.Aspect;
|
||||
import com.sun.tools.internal.xjc.outline.Outline;
|
||||
|
||||
/**
|
||||
* A type.
|
||||
*
|
||||
* See the package documentaion for details.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface NType {
|
||||
/**
|
||||
* Returns the representation of this type in code model.
|
||||
* <p>
|
||||
* This operation requires the whole model to be built,
|
||||
* and hence it takes {@link Outline}.
|
||||
* <p>
|
||||
* Under some code generation strategy, some bean classes
|
||||
* are considered implementation specific (such as impl.FooImpl class)
|
||||
* These classes always have accompanying "exposed" type (such as
|
||||
* the Foo interface).
|
||||
* <p>
|
||||
* For such Jekyll and Hyde type, the aspect parameter determines
|
||||
* which personality is returned.
|
||||
*
|
||||
* @param aspect
|
||||
* If {@link Aspect#IMPLEMENTATION}, this method returns the
|
||||
* implementation specific class that this type represents.
|
||||
* If {@link Aspect#EXPOSED}, this method returns the
|
||||
* publicly exposed type that this type represents.
|
||||
*
|
||||
* For ordinary classes, the aspect parameter is meaningless.
|
||||
*
|
||||
*/
|
||||
JType toType(Outline o, Aspect aspect);
|
||||
|
||||
/**
|
||||
* Returns true iff this type represents a class that has a unboxed form.
|
||||
*
|
||||
* For example, for {@link String} this is false, but for {@link Integer}
|
||||
* this is true.
|
||||
*/
|
||||
boolean isBoxedType();
|
||||
|
||||
/**
|
||||
* Human readable name of this type.
|
||||
*/
|
||||
String fullName();
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* 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
|
||||
* 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 java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sun.codemodel.internal.JClass;
|
||||
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
|
||||
import com.sun.xml.internal.bind.v2.runtime.Location;
|
||||
|
||||
/**
|
||||
* {@link Navigator} implementation for XJC.
|
||||
*
|
||||
* Most of the Navigator methods are used for parsing the model, which doesn't happen
|
||||
* in XJC. So Most of the methods aren't really implemented. Implementations should
|
||||
* be filled in as needed.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public final class NavigatorImpl implements Navigator<NType,NClass,Void,Void> {
|
||||
public static final NavigatorImpl theInstance = new NavigatorImpl();
|
||||
|
||||
private NavigatorImpl() {
|
||||
}
|
||||
|
||||
public NClass getSuperClass(NClass nClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NType getBaseClass(NType nt, NClass base) {
|
||||
if(nt instanceof EagerNType) {
|
||||
EagerNType ent = (EagerNType) nt;
|
||||
if (base instanceof EagerNClass) {
|
||||
EagerNClass enc = (EagerNClass) base;
|
||||
return create(Utils.REFLECTION_NAVIGATOR.getBaseClass(ent.t, enc.c));
|
||||
}
|
||||
// lazy class can never be a base type of an eager type
|
||||
return null;
|
||||
}
|
||||
if (nt instanceof NClassByJClass) {
|
||||
NClassByJClass nnt = (NClassByJClass) nt;
|
||||
if (base instanceof EagerNClass) {
|
||||
EagerNClass enc = (EagerNClass) base;
|
||||
return ref(nnt.clazz.getBaseClass(enc.c));
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getClassName(NClass nClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getTypeName(NType type) {
|
||||
return type.fullName();
|
||||
}
|
||||
|
||||
public String getClassShortName(NClass nClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Collection<? extends Void> getDeclaredFields(NClass nClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Void getDeclaredField(NClass clazz, String fieldName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Collection<? extends Void> getDeclaredMethods(NClass nClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NClass getDeclaringClassForField(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NClass getDeclaringClassForMethod(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NType getFieldType(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getFieldName(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getMethodName(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NType getReturnType(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NType[] getMethodParameters(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isStaticMethod(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isFinalMethod(Void aVoid) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isSubClassOf(NType sub, NType sup) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NClass ref(Class c) {
|
||||
return create(c);
|
||||
}
|
||||
|
||||
public NClass ref(JClass c) {
|
||||
if(c==null) return null;
|
||||
return new NClassByJClass(c);
|
||||
}
|
||||
|
||||
public NType use(NClass nc) {
|
||||
return nc;
|
||||
}
|
||||
|
||||
public NClass asDecl(NType nt) {
|
||||
if(nt instanceof NClass)
|
||||
return (NClass)nt;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public NClass asDecl(Class c) {
|
||||
return ref(c);
|
||||
}
|
||||
|
||||
public boolean isArray(NType nType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isArrayButNotByteArray(NType t) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
public NType getComponentType(NType nType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NType getTypeArgument(NType nt, int i) {
|
||||
if (nt instanceof EagerNType) {
|
||||
EagerNType ent = (EagerNType) nt;
|
||||
return create(Utils.REFLECTION_NAVIGATOR.getTypeArgument(ent.t,i));
|
||||
}
|
||||
if (nt instanceof NClassByJClass) {
|
||||
NClassByJClass nnt = (NClassByJClass) nt;
|
||||
return ref(nnt.clazz.getTypeParameters().get(i));
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isParameterizedType(NType nt) {
|
||||
if (nt instanceof EagerNType) {
|
||||
EagerNType ent = (EagerNType) nt;
|
||||
return Utils.REFLECTION_NAVIGATOR.isParameterizedType(ent.t);
|
||||
}
|
||||
if (nt instanceof NClassByJClass) {
|
||||
NClassByJClass nnt = (NClassByJClass) nt;
|
||||
return nnt.clazz.isParameterized();
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isPrimitive(NType type) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NType getPrimitive(Class primitiveType) {
|
||||
return create(primitiveType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("FinalStaticMethod")
|
||||
public static final NType create(Type t) {
|
||||
if(t==null) return null;
|
||||
if(t instanceof Class)
|
||||
return create((Class)t);
|
||||
|
||||
return new EagerNType(t);
|
||||
}
|
||||
|
||||
public static NClass create( Class c ) {
|
||||
if(c==null) return null;
|
||||
return new EagerNClass(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link NType} representation for a parameterized type
|
||||
* {@code RawType<ParamType1,ParamType2,...> }.
|
||||
*/
|
||||
public static NType createParameterizedType( NClass rawType, NType... args ) {
|
||||
return new NParameterizedType(rawType,args);
|
||||
}
|
||||
|
||||
public static NType createParameterizedType( Class rawType, NType... args ) {
|
||||
return new NParameterizedType(create(rawType),args);
|
||||
}
|
||||
|
||||
public Location getClassLocation(final NClass c) {
|
||||
// not really needed for XJC but doesn't hurt to have one
|
||||
return new Location() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return c.fullName();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Location getFieldLocation(Void v) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public Location getMethodLocation(Void v) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public boolean hasDefaultConstructor(NClass nClass) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isStaticField(Void aVoid) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public boolean isPublicMethod(Void aVoid) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public boolean isPublicField(Void aVoid) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public boolean isEnum(NClass c) {
|
||||
return isSubClassOf(c,create(Enum.class));
|
||||
}
|
||||
|
||||
public <T> NType erasure(NType type) {
|
||||
if(type instanceof NParameterizedType) {
|
||||
NParameterizedType pt = (NParameterizedType) type;
|
||||
return pt.rawType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isAbstract(NClass clazz) {
|
||||
return clazz.isAbstract();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* no class generated by XJC is final.
|
||||
*/
|
||||
public boolean isFinal(NClass clazz) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Void[] getEnumConstants(NClass clazz) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public NType getVoidType() {
|
||||
return ref(void.class);
|
||||
}
|
||||
|
||||
public String getPackageName(NClass clazz) {
|
||||
// TODO: implement this method later
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NClass loadObjectFactory(NClass referencePoint, String pkg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isBridgeMethod(Void method) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isOverriding(Void method,NClass clazz) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isInterface(NClass clazz) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isTransient(Void f) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean isInnerClass(NClass clazz) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(NType t1, NType t2) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
94
jdkSrc/jdk8/com/sun/tools/internal/xjc/model/nav/Utils.java
Normal file
94
jdkSrc/jdk8/com/sun/tools/internal/xjc/model/nav/Utils.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2014, 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.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR;
|
||||
|
||||
static { // we statically initializing REFLECTION_NAVIGATOR property
|
||||
try {
|
||||
final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
|
||||
|
||||
// requires accessClassInPackage privilege
|
||||
final Method getInstance = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Method>() {
|
||||
@Override
|
||||
public Method run() {
|
||||
try {
|
||||
Method getInstance = refNav.getDeclaredMethod("getInstance");
|
||||
getInstance.setAccessible(true);
|
||||
return getInstance;
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//noinspection unchecked
|
||||
REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IllegalStateException("Can't find ReflectionNavigator class");
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
|
||||
} catch (IllegalAccessException e) {
|
||||
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() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user