sun.tools.java.Identifier Java Examples

The following examples show how to use sun.tools.java.Identifier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrimitiveType.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * IDL_Naming
 * Create an PrimitiveType instance for the given class.
 */
private PrimitiveType(ContextStack stack, int typeCode) {
    super(stack,typeCode | TM_PRIMITIVE);

    // Validate type and set names...

    String idlName = IDLNames.getTypeName(typeCode,false);
    Identifier id = null;

    switch (typeCode) {
    case TYPE_VOID:         id = idVoid; break;
    case TYPE_BOOLEAN:      id = idBoolean; break;
    case TYPE_BYTE:         id = idByte; break;
    case TYPE_CHAR:         id = idChar; break;
    case TYPE_SHORT:        id = idShort; break;
    case TYPE_INT:          id = idInt; break;
    case TYPE_LONG:         id = idLong; break;
    case TYPE_FLOAT:        id = idFloat; break;
    case TYPE_DOUBLE:       id = idDouble; break;
    default:            throw new CompilerError("Not a primitive type");
    }

    setNames(id,null,idlName);
    setRepositoryID();
}
 
Example #2
Source File: Type.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set name and package. May only be called during initialization.
 */
protected void setNames(Identifier id, String[] idlModuleNames, String idlName) {

    this.id = id;
    name = Names.mangleClass(id).getName().toString();
    packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
        qualifiedName = packageName + NAME_SEPARATOR + name;
    } else {
        qualifiedName = name;
    }

    setIDLNames(idlModuleNames,idlName);
}
 
Example #3
Source File: PrimitiveType.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * IDL_Naming
 * Create an PrimitiveType instance for the given class.
 */
private PrimitiveType(ContextStack stack, int typeCode) {
    super(stack,typeCode | TM_PRIMITIVE);

    // Validate type and set names...

    String idlName = IDLNames.getTypeName(typeCode,false);
    Identifier id = null;

    switch (typeCode) {
    case TYPE_VOID:         id = idVoid; break;
    case TYPE_BOOLEAN:      id = idBoolean; break;
    case TYPE_BYTE:         id = idByte; break;
    case TYPE_CHAR:         id = idChar; break;
    case TYPE_SHORT:        id = idShort; break;
    case TYPE_INT:          id = idInt; break;
    case TYPE_LONG:         id = idLong; break;
    case TYPE_FLOAT:        id = idFloat; break;
    case TYPE_DOUBLE:       id = idDouble; break;
    default:            throw new CompilerError("Not a primitive type");
    }

    setNames(id,null,idlName);
    setRepositoryID();
}
 
Example #4
Source File: Type.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set name and package. May only be called during initialization.
 */
protected void setNames(Identifier id, String[] idlModuleNames, String idlName) {

    this.id = id;
    name = Names.mangleClass(id).getName().toString();
    packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
        qualifiedName = packageName + NAME_SEPARATOR + name;
    } else {
        qualifiedName = name;
    }

    setIDLNames(idlModuleNames,idlName);
}
 
Example #5
Source File: StubGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void write_tie_thisObject_method(IndentingWriter p,
                                        Identifier idCorbaObject)
    throws IOException
{
    if(POATie){
        p.plnI("public " + idCorbaObject + " thisObject() {");
        /*
        p.pln("org.omg.CORBA.Object objref = null;");
        p.pln("try{");
        p.pln("objref = _poa().servant_to_reference(this);");
        p.pln("}catch (org.omg.PortableServer.POAPackage.WrongPolicy exception){");
        catchWrongPolicy(p);
        p.pln("}catch (org.omg.PortableServer.POAPackage.ServantNotActive exception){");
        catchServantNotActive(p);
        p.pln("}");
        p.pln("return objref;");
        */
        p.pln("return _this_object();");
        p.pOln("}");
    } else {
        p.plnI("public " + idCorbaObject + " thisObject() {");
        p.pln("return this;");
        p.pOln("}");
    }
}
 
Example #6
Source File: PrimitiveType.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * IDL_Naming
 * Create an PrimitiveType instance for the given class.
 */
private PrimitiveType(ContextStack stack, int typeCode) {
    super(stack,typeCode | TM_PRIMITIVE);

    // Validate type and set names...

    String idlName = IDLNames.getTypeName(typeCode,false);
    Identifier id = null;

    switch (typeCode) {
    case TYPE_VOID:         id = idVoid; break;
    case TYPE_BOOLEAN:      id = idBoolean; break;
    case TYPE_BYTE:         id = idByte; break;
    case TYPE_CHAR:         id = idChar; break;
    case TYPE_SHORT:        id = idShort; break;
    case TYPE_INT:          id = idInt; break;
    case TYPE_LONG:         id = idLong; break;
    case TYPE_FLOAT:        id = idFloat; break;
    case TYPE_DOUBLE:       id = idDouble; break;
    default:            throw new CompilerError("Not a primitive type");
    }

    setNames(id,null,idlName);
    setRepositoryID();
}
 
Example #7
Source File: Names.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If necessary, convert a class name to its mangled form, i.e. the
 * non-inner class name used in the binary representation of
 * inner classes.  This is necessary to be able to name inner
 * classes in the generated source code in places where the language
 * does not permit it, such as when synthetically defining an inner
 * class outside of its outer class, and for generating file names
 * corresponding to inner classes.
 *
 * Currently this mangling involves modifying the internal names of
 * inner classes by converting occurrences of ". " into "$".
 *
 * This code is taken from the "mangleInnerType" method of
 * the "sun.tools.java.Type" class; this method cannot be accessed
 * itself because it is package protected.
 */
static final public Identifier mangleClass(Identifier className) {
    if (!className.isInner())
        return className;

    /*
     * Get '.' qualified inner class name (with outer class
     * qualification and no package qualification) and replace
     * each '.' with '$'.
     */
    Identifier mangled = Identifier.lookup(
                                           className.getFlatName().toString()
                                           .replace('.', sun.tools.java.Constants.SIGC_INNERCLASS));
    if (mangled.isInner())
        throw new Error("failed to mangle inner class name");

    // prepend package qualifier back for returned identifier
    return Identifier.lookup(className.getQualifier(), mangled);
}
 
Example #8
Source File: Type.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set name and package. May only be called during initialization.
 */
protected void setNames(Identifier id, String[] idlModuleNames, String idlName) {

    this.id = id;
    name = Names.mangleClass(id).getName().toString();
    packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
        qualifiedName = packageName + NAME_SEPARATOR + name;
    } else {
        qualifiedName = name;
    }

    setIDLNames(idlModuleNames,idlName);
}
 
Example #9
Source File: SpecialInterfaceType.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSpecial(sun.tools.java.Type type,
                                 ClassDefinition theClass,
                                 ContextStack stack) {
    if (type.isType(TC_CLASS)) {
        Identifier id = type.getClassName();

        if (id.equals(idRemote)) return true;
        if (id == idJavaIoSerializable) return true;
        if (id == idJavaIoExternalizable) return true;
        if (id == idCorbaObject) return true;
        if (id == idIDLEntity) return true;
        BatchEnvironment env = stack.getEnv();
        try {
            if (env.defCorbaObject.implementedBy(env,theClass.getClassDeclaration())) return true;
        } catch (ClassNotFound e) {
            classNotFound(stack,e);
        }
    }
    return false;
}
 
Example #10
Source File: PrimitiveType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * IDL_Naming
 * Create an PrimitiveType instance for the given class.
 */
private PrimitiveType(ContextStack stack, int typeCode) {
    super(stack,typeCode | TM_PRIMITIVE);

    // Validate type and set names...

    String idlName = IDLNames.getTypeName(typeCode,false);
    Identifier id = null;

    switch (typeCode) {
    case TYPE_VOID:         id = idVoid; break;
    case TYPE_BOOLEAN:      id = idBoolean; break;
    case TYPE_BYTE:         id = idByte; break;
    case TYPE_CHAR:         id = idChar; break;
    case TYPE_SHORT:        id = idShort; break;
    case TYPE_INT:          id = idInt; break;
    case TYPE_LONG:         id = idLong; break;
    case TYPE_FLOAT:        id = idFloat; break;
    case TYPE_DOUBLE:       id = idDouble; break;
    default:            throw new CompilerError("Not a primitive type");
    }

    setNames(id,null,idlName);
    setRepositoryID();
}
 
Example #11
Source File: SpecialInterfaceType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static boolean isSpecial(sun.tools.java.Type type,
                                 ClassDefinition theClass,
                                 ContextStack stack) {
    if (type.isType(TC_CLASS)) {
        Identifier id = type.getClassName();

        if (id.equals(idRemote)) return true;
        if (id == idJavaIoSerializable) return true;
        if (id == idJavaIoExternalizable) return true;
        if (id == idCorbaObject) return true;
        if (id == idIDLEntity) return true;
        BatchEnvironment env = stack.getEnv();
        try {
            if (env.defCorbaObject.implementedBy(env,theClass.getClassDeclaration())) return true;
        } catch (ClassNotFound e) {
            classNotFound(stack,e);
        }
    }
    return false;
}
 
Example #12
Source File: Names.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If necessary, convert a class name to its mangled form, i.e. the
 * non-inner class name used in the binary representation of
 * inner classes.  This is necessary to be able to name inner
 * classes in the generated source code in places where the language
 * does not permit it, such as when synthetically defining an inner
 * class outside of its outer class, and for generating file names
 * corresponding to inner classes.
 *
 * Currently this mangling involves modifying the internal names of
 * inner classes by converting occurrences of ". " into "$".
 *
 * This code is taken from the "mangleInnerType" method of
 * the "sun.tools.java.Type" class; this method cannot be accessed
 * itself because it is package protected.
 */
static final public Identifier mangleClass(Identifier className) {
    if (!className.isInner())
        return className;

    /*
     * Get '.' qualified inner class name (with outer class
     * qualification and no package qualification) and replace
     * each '.' with '$'.
     */
    Identifier mangled = Identifier.lookup(
                                           className.getFlatName().toString()
                                           .replace('.', sun.tools.java.Constants.SIGC_INNERCLASS));
    if (mangled.isInner())
        throw new Error("failed to mangle inner class name");

    // prepend package qualifier back for returned identifier
    return Identifier.lookup(className.getQualifier(), mangled);
}
 
Example #13
Source File: StubGenerator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void write_tie_thisObject_method(IndentingWriter p,
                                        Identifier idCorbaObject)
    throws IOException
{
    if(POATie){
        p.plnI("public " + idCorbaObject + " thisObject() {");
        /*
        p.pln("org.omg.CORBA.Object objref = null;");
        p.pln("try{");
        p.pln("objref = _poa().servant_to_reference(this);");
        p.pln("}catch (org.omg.PortableServer.POAPackage.WrongPolicy exception){");
        catchWrongPolicy(p);
        p.pln("}catch (org.omg.PortableServer.POAPackage.ServantNotActive exception){");
        catchServantNotActive(p);
        p.pln("}");
        p.pln("return objref;");
        */
        p.pln("return _this_object();");
        p.pOln("}");
    } else {
        p.plnI("public " + idCorbaObject + " thisObject() {");
        p.pln("return this;");
        p.pOln("}");
    }
}
 
Example #14
Source File: Names.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If necessary, convert a class name to its mangled form, i.e. the
 * non-inner class name used in the binary representation of
 * inner classes.  This is necessary to be able to name inner
 * classes in the generated source code in places where the language
 * does not permit it, such as when synthetically defining an inner
 * class outside of its outer class, and for generating file names
 * corresponding to inner classes.
 *
 * Currently this mangling involves modifying the internal names of
 * inner classes by converting occurrences of ". " into "$".
 *
 * This code is taken from the "mangleInnerType" method of
 * the "sun.tools.java.Type" class; this method cannot be accessed
 * itself because it is package protected.
 */
static final public Identifier mangleClass(Identifier className) {
    if (!className.isInner())
        return className;

    /*
     * Get '.' qualified inner class name (with outer class
     * qualification and no package qualification) and replace
     * each '.' with '$'.
     */
    Identifier mangled = Identifier.lookup(
                                           className.getFlatName().toString()
                                           .replace('.', sun.tools.java.Constants.SIGC_INNERCLASS));
    if (mangled.isInner())
        throw new Error("failed to mangle inner class name");

    // prepend package qualifier back for returned identifier
    return Identifier.lookup(className.getQualifier(), mangled);
}
 
Example #15
Source File: Type.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set name and package. May only be called during initialization.
 */
protected void setNames(Identifier id, String[] idlModuleNames, String idlName) {

    this.id = id;
    name = Names.mangleClass(id).getName().toString();
    packageName = null;

    if (id.isQualified()) {
        packageName = id.getQualifier().toString();
        qualifiedName = packageName + NAME_SEPARATOR + name;
    } else {
        qualifiedName = name;
    }

    setIDLNames(idlModuleNames,idlName);
}
 
Example #16
Source File: StubGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void write_tie_thisObject_method(IndentingWriter p,
                                        Identifier idCorbaObject)
    throws IOException
{
    if(POATie){
        p.plnI("public " + idCorbaObject + " thisObject() {");
        /*
        p.pln("org.omg.CORBA.Object objref = null;");
        p.pln("try{");
        p.pln("objref = _poa().servant_to_reference(this);");
        p.pln("}catch (org.omg.PortableServer.POAPackage.WrongPolicy exception){");
        catchWrongPolicy(p);
        p.pln("}catch (org.omg.PortableServer.POAPackage.ServantNotActive exception){");
        catchServantNotActive(p);
        p.pln("}");
        p.pln("return objref;");
        */
        p.pln("return _this_object();");
        p.pOln("}");
    } else {
        p.plnI("public " + idCorbaObject + " thisObject() {");
        p.pln("return this;");
        p.pOln("}");
    }
}
 
Example #17
Source File: Generator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the File object that should be used as the output file
 * for the given OutputType.
 * @param outputType The type to create a file for.
 * @param destinationDir The directory to use as the root of the
 * package heirarchy.  May be null, in which case the current
 * classpath is searched to find the directory in which to create
 * the output file.  If that search fails (most likely because the
 * package directory lives in a zip or jar file rather than the
 * file system), the current user directory is used.
 */
protected File getFileFor(OutputType outputType, File destinationDir) {
    // Calling this method does some crucial initialization
    // in a subclass implementation. Don't skip it.
    Identifier id = getOutputId(outputType);
    File packageDir = null;
    if(idl){
        packageDir = Util.getOutputDirectoryForIDL(id,destinationDir,env);
    } else {
        packageDir = Util.getOutputDirectoryForStub(id,destinationDir,env);
    }
    String classFileName = outputType.getName() + getFileNameExtensionFor(outputType);
    return new File(packageDir, classFileName);
}
 
Example #18
Source File: IDLGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Collect and filter methods for a type.
 * Remove any private or inherited methods.
 * @param ct The current CompoundType
 * @return Vector containing the methods
 */
protected Vector getMethods(
                            CompoundType ct ) {
    Vector vec = new Vector();
    int ctType = ct.getTypeCode();
    switch ( ctType ) {
    case TYPE_ABSTRACT:
    case TYPE_REMOTE:       break;
    case TYPE_NC_CLASS:
    case TYPE_NC_INTERFACE:
    case TYPE_VALUE:        if ( valueMethods ) break;
    default: return vec;
    }
    Identifier ctId = ct.getIdentifier();
    CompoundType.Method[] mths = ct.getMethods();
                            nextMethod:
    for ( int i1 = 0; i1 < mths.length; i1++ ) {               //forall methods
        if ( mths[i1].isPrivate() ||                            //private method?
             mths[i1].isInherited() )                         //inherited method?
            continue nextMethod;                                   //yes..ignore it
        if ( ctType == TYPE_VALUE ) {
            String mthName = mths[i1].getName();
            if ( "readObject"  .equals( mthName ) ||
                 "writeObject" .equals( mthName ) ||
                 "readExternal".equals( mthName ) ||
                 "writeExternal".equals( mthName ) )
                continue nextMethod;                                //ignore this one
        }
        if ( ( ctType == TYPE_NC_CLASS ||
               ctType == TYPE_NC_INTERFACE ) &&
             mths[i1].isConstructor() )   //init not valid for abstract valuetype
            continue nextMethod;                                  //ignore this one
        vec.addElement( mths[i1] );                                //add this one
    }
    return vec;
}
 
Example #19
Source File: StubGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
String getName(Type type) {
    if (type.isPrimitive()) {
        return type.getName() + type.getArrayBrackets();
    }
    Identifier id = type.getIdentifier();
    String name = IDLNames.replace(id.toString(),". ",".");
    return getName(name) + type.getArrayBrackets();
}
 
Example #20
Source File: StubGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void addClassInUse(Type type) {
    if (!type.isPrimitive()) {
        Identifier id = type.getIdentifier();
        String name = IDLNames.replace(id.getName().toString(),". ",".");
        String packageName = type.getPackageName();
        String qualifiedName;
        if (packageName != null) {
            qualifiedName = packageName+"."+name;
        } else {
            qualifiedName = name;
        }
        addClassInUse(name,qualifiedName,packageName);
    }
}
 
Example #21
Source File: StubGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
String getName(Type type) {
    if (type.isPrimitive()) {
        return type.getName() + type.getArrayBrackets();
    }
    Identifier id = type.getIdentifier();
    String name = IDLNames.replace(id.toString(),". ",".");
    return getName(name) + type.getArrayBrackets();
}
 
Example #22
Source File: RMIGenerator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write 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] + " = ");
        /*
         * Here we look up the Method object in the arbitrary interface
         * that we find in the RemoteClass.Method object.
         * REMIND: Is this arbitrary choice OK?
         * REMIND: Should this access be part of RemoteClass.Method's
         * abstraction?
         */
        RemoteClass.Method method = remoteMethods[i];
        MemberDefinition def = method.getMemberDefinition();
        Identifier methodName = method.getName();
        Type methodType = method.getType();
        Type paramTypes[] = methodType.getArgumentTypes();

        p.p(def.getClassDefinition().getName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j] + ".class");
        }
        p.pln("});");
    }
}
 
Example #23
Source File: RMIGenerator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the File object that should be used as the source file
 * for the given Java class, using the supplied destination
 * directory for the top of the package hierarchy.
 */
protected static File sourceFileForClass(Identifier className,
                                         Identifier outputClassName,
                                         File destDir,
                                         BatchEnvironment env)
{
    File packageDir = Util.getOutputDirectoryFor(className,destDir,env);
    String outputName = Names.mangleClass(outputClassName).getName().toString();

    // Is there any existing _Tie equivalent leftover from a
    // previous invocation of rmic -iiop? Only do this once per
    // class by looking for skeleton generation...

    if (outputName.endsWith("_Skel")) {
        String classNameStr = className.getName().toString();
        File temp = new File(packageDir, Utility.tieName(classNameStr) + ".class");
        if (temp.exists()) {

            // Found a tie. Is IIOP generation also being done?

            if (!env.getMain().iiopGeneration) {

                // No, so write a warning...

                env.error(0,"warn.rmic.tie.found",
                          classNameStr,
                          temp.getAbsolutePath());
            }
        }
    }

    String outputFileName = outputName + ".java";
    return new File(packageDir, outputFileName);
}
 
Example #24
Source File: CFCTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #25
Source File: CFCTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #26
Source File: CFCTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #27
Source File: CFCTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Failure is seen when getClassDefinition causes class read
 */
void exerciseClassDefinition() throws Exception {
    BatchEnvironment env = new BatchEnvironment(System.out,
            BatchEnvironment.createClassPath(testClassPath, null, null),
            null);
    try {
        ClassDeclaration decl = env.getClassDeclaration(
                Identifier.lookup(testClassName));
        decl.getClassDefinition(env);
    } finally {
        env.flushErrors();
        env.shutdown();
    }
}
 
Example #28
Source File: IDLGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Collect and filter methods for a type.
 * Remove any private or inherited methods.
 * @param ct The current CompoundType
 * @return Vector containing the methods
 */
protected Vector getMethods(
                            CompoundType ct ) {
    Vector vec = new Vector();
    int ctType = ct.getTypeCode();
    switch ( ctType ) {
    case TYPE_ABSTRACT:
    case TYPE_REMOTE:       break;
    case TYPE_NC_CLASS:
    case TYPE_NC_INTERFACE:
    case TYPE_VALUE:        if ( valueMethods ) break;
    default: return vec;
    }
    Identifier ctId = ct.getIdentifier();
    CompoundType.Method[] mths = ct.getMethods();
                            nextMethod:
    for ( int i1 = 0; i1 < mths.length; i1++ ) {               //forall methods
        if ( mths[i1].isPrivate() ||                            //private method?
             mths[i1].isInherited() )                         //inherited method?
            continue nextMethod;                                   //yes..ignore it
        if ( ctType == TYPE_VALUE ) {
            String mthName = mths[i1].getName();
            if ( "readObject"  .equals( mthName ) ||
                 "writeObject" .equals( mthName ) ||
                 "readExternal".equals( mthName ) ||
                 "writeExternal".equals( mthName ) )
                continue nextMethod;                                //ignore this one
        }
        if ( ( ctType == TYPE_NC_CLASS ||
               ctType == TYPE_NC_INTERFACE ) &&
             mths[i1].isConstructor() )   //init not valid for abstract valuetype
            continue nextMethod;                                  //ignore this one
        vec.addElement( mths[i1] );                                //add this one
    }
    return vec;
}
 
Example #29
Source File: Generator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the File object that should be used as the output file
 * for the given OutputType.
 * @param outputType The type to create a file for.
 * @param destinationDir The directory to use as the root of the
 * package heirarchy.  May be null, in which case the current
 * classpath is searched to find the directory in which to create
 * the output file.  If that search fails (most likely because the
 * package directory lives in a zip or jar file rather than the
 * file system), the current user directory is used.
 */
protected File getFileFor(OutputType outputType, File destinationDir) {
    // Calling this method does some crucial initialization
    // in a subclass implementation. Don't skip it.
    Identifier id = getOutputId(outputType);
    File packageDir = null;
    if(idl){
        packageDir = Util.getOutputDirectoryForIDL(id,destinationDir,env);
    } else {
        packageDir = Util.getOutputDirectoryForStub(id,destinationDir,env);
    }
    String classFileName = outputType.getName() + getFileNameExtensionFor(outputType);
    return new File(packageDir, classFileName);
}
 
Example #30
Source File: StubGenerator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
String getName(Type type) {
    if (type.isPrimitive()) {
        return type.getName() + type.getArrayBrackets();
    }
    Identifier id = type.getIdentifier();
    String name = IDLNames.replace(id.toString(),". ",".");
    return getName(name) + type.getArrayBrackets();
}