jdk.nashorn.internal.runtime.NativeJavaPackage Java Examples

The following examples show how to use jdk.nashorn.internal.runtime.NativeJavaPackage. 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: NativeJavaImporter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #2
Source File: NativeJavaImporter.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            try {
                return StaticClass.forClass(Class.forName(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #3
Source File: NativeJavaImporter.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #4
Source File: NativeJavaImporter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #5
Source File: NativeJavaImporter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #6
Source File: NativeJavaImporter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #7
Source File: NativeJavaImporter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #8
Source File: NativeJavaImporter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #9
Source File: NativeJavaImporter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #10
Source File: NativeJavaImporter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
Example #11
Source File: Global.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
}
 
Example #12
Source File: Global.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
}
 
Example #13
Source File: Global.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
}
 
Example #14
Source File: Global.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
    this.builtinJavaImporter = initConstructor("JavaImporter");
    this.builtinJavaApi = initConstructor("Java");
}
 
Example #15
Source File: Global.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
}
 
Example #16
Source File: Global.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
    this.builtinJavaImporter = initConstructor("JavaImporter");
    this.builtinJavaApi = initConstructor("Java");
}
 
Example #17
Source File: Global.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
}
 
Example #18
Source File: Global.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
}
 
Example #19
Source File: Global.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
    this.builtinJavaImporter = initConstructor("JavaImporter");
    this.builtinJavaApi = initConstructor("Java");
}
 
Example #20
Source File: Global.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void initJavaAccess() {
    final ScriptObject objectProto = getObjectPrototype();
    this.builtinPackages = new NativeJavaPackage("", objectProto);
    this.builtinCom = new NativeJavaPackage("com", objectProto);
    this.builtinEdu = new NativeJavaPackage("edu", objectProto);
    this.builtinJava = new NativeJavaPackage("java", objectProto);
    this.builtinJavafx = new NativeJavaPackage("javafx", objectProto);
    this.builtinJavax = new NativeJavaPackage("javax", objectProto);
    this.builtinOrg = new NativeJavaPackage("org", objectProto);
}