com.sun.corba.se.impl.util.PackagePrefixChecker Java Examples

The following examples show how to use com.sun.corba.se.impl.util.PackagePrefixChecker. 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: Util.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static String correctPackageName(
        String p, boolean idl, boolean standardPackage){
    if (idl){
        return p;
    } else {
        if (standardPackage) {
            return p;
        } else {
          return PackagePrefixChecker.correctPackageName(p);
        }
    }
}
 
Example #2
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static String correctPackageName(
        String p, boolean idl, boolean standardPackage){
    if (idl){
        return p;
    } else {
        if (standardPackage) {
            return p;
        } else {
          return PackagePrefixChecker.correctPackageName(p);
        }
    }
}
 
Example #3
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static String correctPackageName(
        String p, boolean idl, boolean standardPackage){
    if (idl){
        return p;
    } else {
        if (standardPackage) {
            return p;
        } else {
          return PackagePrefixChecker.correctPackageName(p);
        }
    }
}
 
Example #4
Source File: Util.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static String correctPackageName(
        String p, boolean idl, boolean standardPackage){
    if (idl){
        return p;
    } else {
        if (standardPackage) {
            return p;
        } else {
          return PackagePrefixChecker.correctPackageName(p);
        }
    }
}
 
Example #5
Source File: Util.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static String correctPackageName(
        String p, boolean idl, boolean standardPackage){
    if (idl){
        return p;
    } else {
        if (standardPackage) {
            return p;
        } else {
          return PackagePrefixChecker.correctPackageName(p);
        }
    }
}
 
Example #6
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static String correctPackageName(
        String p, boolean idl, boolean standardPackage){
    if (idl){
        return p;
    } else {
        if (standardPackage) {
            return p;
        } else {
          return PackagePrefixChecker.correctPackageName(p);
        }
    }
}
 
Example #7
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static String correctPackageName(
        String p, boolean idl, boolean standardPackage){
    if (idl){
        return p;
    } else {
        if (standardPackage) {
            return p;
        } else {
          return PackagePrefixChecker.correctPackageName(p);
        }
    }
}
 
Example #8
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static String correctPackageName(
        String p, boolean idl, boolean standardPackage){
    if (idl){
        return p;
    } else {
        if (standardPackage) {
            return p;
        } else {
          return PackagePrefixChecker.correctPackageName(p);
        }
    }
}
 
Example #9
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static boolean hasOffendingPrefix(String p){
    return PackagePrefixChecker.hasOffendingPrefix(p);
}
 
Example #10
Source File: StubFactoryFactoryStaticImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example #11
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isOffendingPackage(String p){
    return PackagePrefixChecker.isOffendingPackage(p);
}
 
Example #12
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static boolean hasOffendingPrefix(String p){
    return PackagePrefixChecker.hasOffendingPrefix(p);
}
 
Example #13
Source File: StubGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void writePackageAndImports(IndentingWriter p) throws IOException {

        // Write package declaration...

        if (currentPackage != null) {
            p.pln("package " +
                     Util.correctPackageName(
                          currentPackage, false, standardPackage)
                   + ";");
            p.pln();
        }

        // Get imports into an array and sort them...

        String[] names = new String[importCount];
        int index = 0;
        for (Enumeration e = imports.elements() ; e.hasMoreElements() ;) {
            String it = (String) e.nextElement();
            if (it != NO_IMPORT) {
                names[index++] = it;
            }
        }

        Arrays.sort(names,new StringComparator());

        // Now dump them out...

        for (int i = 0; i < importCount; i++) {
            if(
               Util.isOffendingPackage(names[i])
               && names[i].endsWith("_Stub")
               && String.valueOf(names[i].charAt(names[i].lastIndexOf(".")+1)).equals("_")
               ){
                p.pln("import " + PackagePrefixChecker.packagePrefix()+names[i]+";");
            } else{
                p.pln("import " + names[i] + ";");
            }
        }
        p.pln();

        // Include offending packages . . .
        if ( currentPackage!=null && Util.isOffendingPackage(currentPackage) ){
            p.pln("import " + currentPackage +".*  ;");
        }
        p.pln();

    }
 
Example #14
Source File: StubFactoryFactoryStaticImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example #15
Source File: StubGenerator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void writePackageAndImports(IndentingWriter p) throws IOException {

        // Write package declaration...

        if (currentPackage != null) {
            p.pln("package " +
                     Util.correctPackageName(
                          currentPackage, false, standardPackage)
                   + ";");
            p.pln();
        }

        // Get imports into an array and sort them...

        String[] names = new String[importCount];
        int index = 0;
        for (Enumeration e = imports.elements() ; e.hasMoreElements() ;) {
            String it = (String) e.nextElement();
            if (it != NO_IMPORT) {
                names[index++] = it;
            }
        }

        Arrays.sort(names,new StringComparator());

        // Now dump them out...

        for (int i = 0; i < importCount; i++) {
            if(
               Util.isOffendingPackage(names[i])
               && names[i].endsWith("_Stub")
               && String.valueOf(names[i].charAt(names[i].lastIndexOf(".")+1)).equals("_")
               ){
                p.pln("import " + PackagePrefixChecker.packagePrefix()+names[i]+";");
            } else{
                p.pln("import " + names[i] + ";");
            }
        }
        p.pln();

        // Include offending packages . . .
        if ( currentPackage!=null && Util.isOffendingPackage(currentPackage) ){
            p.pln("import " + currentPackage +".*  ;");
        }
        p.pln();

    }
 
Example #16
Source File: Util.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isOffendingPackage(String p){
    return PackagePrefixChecker.isOffendingPackage(p);
}
 
Example #17
Source File: Util.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static boolean hasOffendingPrefix(String p){
    return PackagePrefixChecker.hasOffendingPrefix(p);
}
 
Example #18
Source File: StubGenerator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void writePackageAndImports(IndentingWriter p) throws IOException {

        // Write package declaration...

        if (currentPackage != null) {
            p.pln("package " +
                     Util.correctPackageName(
                          currentPackage, false, standardPackage)
                   + ";");
            p.pln();
        }

        // Get imports into an array and sort them...

        String[] names = new String[importCount];
        int index = 0;
        for (Enumeration e = imports.elements() ; e.hasMoreElements() ;) {
            String it = (String) e.nextElement();
            if (it != NO_IMPORT) {
                names[index++] = it;
            }
        }

        Arrays.sort(names,new StringComparator());

        // Now dump them out...

        for (int i = 0; i < importCount; i++) {
            if(
               Util.isOffendingPackage(names[i])
               && names[i].endsWith("_Stub")
               && String.valueOf(names[i].charAt(names[i].lastIndexOf(".")+1)).equals("_")
               ){
                p.pln("import " + PackagePrefixChecker.packagePrefix()+names[i]+";");
            } else{
                p.pln("import " + names[i] + ";");
            }
        }
        p.pln();

        // Include offending packages . . .
        if ( currentPackage!=null && Util.isOffendingPackage(currentPackage) ){
            p.pln("import " + currentPackage +".*  ;");
        }
        p.pln();

    }
 
Example #19
Source File: StubFactoryFactoryStaticImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example #20
Source File: StubFactoryFactoryStaticImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example #21
Source File: Util.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isOffendingPackage(String p){
    return PackagePrefixChecker.isOffendingPackage(p);
}
 
Example #22
Source File: Util.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static boolean hasOffendingPrefix(String p){
    return PackagePrefixChecker.hasOffendingPrefix(p);
}
 
Example #23
Source File: StubGenerator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void writePackageAndImports(IndentingWriter p) throws IOException {

        // Write package declaration...

        if (currentPackage != null) {
            p.pln("package " +
                     Util.correctPackageName(
                          currentPackage, false, standardPackage)
                   + ";");
            p.pln();
        }

        // Get imports into an array and sort them...

        String[] names = new String[importCount];
        int index = 0;
        for (Enumeration e = imports.elements() ; e.hasMoreElements() ;) {
            String it = (String) e.nextElement();
            if (it != NO_IMPORT) {
                names[index++] = it;
            }
        }

        Arrays.sort(names,new StringComparator());

        // Now dump them out...

        for (int i = 0; i < importCount; i++) {
            if(
               Util.isOffendingPackage(names[i])
               && names[i].endsWith("_Stub")
               && String.valueOf(names[i].charAt(names[i].lastIndexOf(".")+1)).equals("_")
               ){
                p.pln("import " + PackagePrefixChecker.packagePrefix()+names[i]+";");
            } else{
                p.pln("import " + names[i] + ";");
            }
        }
        p.pln();

        // Include offending packages . . .
        if ( currentPackage!=null && Util.isOffendingPackage(currentPackage) ){
            p.pln("import " + currentPackage +".*  ;");
        }
        p.pln();

    }
 
Example #24
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isOffendingPackage(String p){
    return PackagePrefixChecker.isOffendingPackage(p);
}
 
Example #25
Source File: StubFactoryFactoryStaticImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example #26
Source File: StubFactoryFactoryStaticImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example #27
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isOffendingPackage(String p){
    return PackagePrefixChecker.isOffendingPackage(p);
}
 
Example #28
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static boolean hasOffendingPrefix(String p){
    return PackagePrefixChecker.hasOffendingPrefix(p);
}
 
Example #29
Source File: StubGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void writePackageAndImports(IndentingWriter p) throws IOException {

        // Write package declaration...

        if (currentPackage != null) {
            p.pln("package " +
                     Util.correctPackageName(
                          currentPackage, false, standardPackage)
                   + ";");
            p.pln();
        }

        // Get imports into an array and sort them...

        String[] names = new String[importCount];
        int index = 0;
        for (Enumeration e = imports.elements() ; e.hasMoreElements() ;) {
            String it = (String) e.nextElement();
            if (it != NO_IMPORT) {
                names[index++] = it;
            }
        }

        Arrays.sort(names,new StringComparator());

        // Now dump them out...

        for (int i = 0; i < importCount; i++) {
            if(
               Util.isOffendingPackage(names[i])
               && names[i].endsWith("_Stub")
               && String.valueOf(names[i].charAt(names[i].lastIndexOf(".")+1)).equals("_")
               ){
                p.pln("import " + PackagePrefixChecker.packagePrefix()+names[i]+";");
            } else{
                p.pln("import " + names[i] + ";");
            }
        }
        p.pln();

        // Include offending packages . . .
        if ( currentPackage!=null && Util.isOffendingPackage(currentPackage) ){
            p.pln("import " + currentPackage +".*  ;");
        }
        p.pln();

    }
 
Example #30
Source File: StubFactoryFactoryStaticImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}