类com.sun.javadoc.Type源码实例Demo

下面列出了怎么用com.sun.javadoc.Type的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u-dev-jdk   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码2 项目: dragonwell8_jdk   文件: StubSkeletonWriter.java
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
 
源代码3 项目: jdk8u-dev-jdk   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码4 项目: openjdk-8-source   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码5 项目: TencentKona-8   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码6 项目: TencentKona-8   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码7 项目: jdk8u-dev-jdk   文件: RemoteClass.java
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
 
源代码8 项目: jdk8u-jdk   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码9 项目: jdk8u60   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码10 项目: jdk8u_jdk   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码11 项目: sarl   文件: SarlLinkFactory.java
/** Build the link for the wildcard.
 *
 * @param link the link.
 * @param linkInfo the information on the link.
 * @param type the type.
 */
protected void getLinkForWildcard(Content link, LinkInfo linkInfo, Type type) {
	linkInfo.isTypeBound = true;
	link.addContent("?"); //$NON-NLS-1$
	final WildcardType wildcardType = type.asWildcardType();
	final Type[] extendsBounds = wildcardType.extendsBounds();
	final SARLFeatureAccess kw = Utils.getKeywords();
	for (int i = 0; i < extendsBounds.length; i++) {
		link.addContent(i > 0 ? kw.getCommaKeyword() + " " //$NON-NLS-1$
				: " " + kw.getExtendsKeyword() + " "); //$NON-NLS-1$ //$NON-NLS-2$
		setBoundsLinkInfo(linkInfo, extendsBounds[i]);
		link.addContent(getLink(linkInfo));
	}
	final Type[] superBounds = wildcardType.superBounds();
	for (int i = 0; i < superBounds.length; i++) {
		link.addContent(i > 0 ? kw.getCommaKeyword() + " " //$NON-NLS-1$
				: " " + kw.getSuperKeyword() + " "); //$NON-NLS-1$ //$NON-NLS-2$
		setBoundsLinkInfo(linkInfo, superBounds[i]);
		link.addContent(getLink(linkInfo));
	}
}
 
源代码12 项目: jdk8u60   文件: StubSkeletonWriter.java
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
 
源代码13 项目: openjdk-8-source   文件: StubSkeletonWriter.java
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
 
源代码14 项目: jdk8u60   文件: RemoteClass.java
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
 
源代码15 项目: jdk8u-jdk   文件: RemoteClass.java
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
 
源代码16 项目: hottub   文件: StubSkeletonWriter.java
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
 
源代码17 项目: jdk8u-jdk   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码18 项目: openjdk-jdk8u   文件: StubSkeletonWriter.java
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
 
源代码19 项目: openjdk-jdk8u   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码20 项目: openjdk-jdk8u   文件: RemoteClass.java
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
 
源代码21 项目: hottub   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码22 项目: openjdk-8   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码23 项目: openjdk-jdk8u-backup   文件: StubSkeletonWriter.java
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
 
源代码24 项目: openjdk-jdk8u-backup   文件: StubSkeletonWriter.java
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
源代码25 项目: openjdk-jdk8u-backup   文件: RemoteClass.java
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
 
源代码26 项目: hottub   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码27 项目: openjdk-jdk9   文件: StubSkeletonWriter.java
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
 
源代码28 项目: dragonwell8_jdk   文件: Util.java
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
源代码29 项目: jdk8u_jdk   文件: StubSkeletonWriter.java
/**
 * Writes Java statements to marshal a series of values in order
 * as named in the "names" array, with types as specified in the
 * "types" array, to the java.io.ObjectOutput stream named
 * "stream".
 **/
private static void writeMarshalArguments(IndentingWriter p,
                                          String streamName,
                                          Type[] types, String[] names)
    throws IOException
{
    assert types.length == names.length;

    for (int i = 0; i < types.length; i++) {
        writeMarshalArgument(p, streamName, types[i], names[i]);
        p.pln(";");
    }
}
 
源代码30 项目: sarl   文件: SarlLinkFactory.java
/** Create the label for a procedure lambda.
 *
 * @param linkInfo the type.
 * @return the label.
 */
protected Content createProcedureLambdaLabel(LinkInfoImpl linkInfo) {
	final ParameterizedType type = linkInfo.type.asParameterizedType();
	if (type != null) {
		final Type[] arguments = type.typeArguments();
		if (arguments != null && arguments.length > 0) {
			return createLambdaLabel(linkInfo, arguments, arguments.length);
		}
	}
	return linkInfo.label;
}