43 * Objects of this constructor are used along with {@code "with"} statements and as such are not usable in ECMAScript
44 * strict mode. Example:
45 * <pre>
46 * var imports = new JavaImporter(java.util, java.io);
47 * with (imports) {
48 * var m = new HashMap(); // java.util.HashMap
49 * var f = new File("."); // java.io.File
50 * ...
51 * }
52 * </pre>
53 * Note however that the preferred way for accessing Java types in Nashorn is through the use of
54 * {@link NativeJava#type(Object, Object) Java.type()} method.
55 */
56 @ScriptClass("JavaImporter")
57 public final class NativeJavaImporter extends ScriptObject {
58 private final Object[] args;
59
60 // initialized by nasgen
61 private static PropertyMap $nasgenmap$;
62
63 static PropertyMap getInitialMap() {
64 return $nasgenmap$;
65 }
66
67 private NativeJavaImporter(final Object[] args, final ScriptObject proto, final PropertyMap map) {
68 super(proto, map);
69 this.args = args;
70 }
71
72 private NativeJavaImporter(final Object[] args, final Global global) {
73 this(args, global.getJavaImporterPrototype(), getInitialMap());
74 }
75
76 private NativeJavaImporter(final Object[] args) {
77 this(args, Global.instance());
78 }
79
80 @Override
81 public String getClassName() {
82 return "JavaImporter";
83 }
84
85 /**
86 * Constructor
87 * @param isNew is the new operator used for instantiating this NativeJavaImporter
88 * @param self self reference
89 * @param args arguments
90 * @return NativeJavaImporter instance
91 */
92 @Constructor(arity = 1)
93 public static Object constructor(final boolean isNew, final Object self, final Object... args) {
|
43 * Objects of this constructor are used along with {@code "with"} statements and as such are not usable in ECMAScript
44 * strict mode. Example:
45 * <pre>
46 * var imports = new JavaImporter(java.util, java.io);
47 * with (imports) {
48 * var m = new HashMap(); // java.util.HashMap
49 * var f = new File("."); // java.io.File
50 * ...
51 * }
52 * </pre>
53 * Note however that the preferred way for accessing Java types in Nashorn is through the use of
54 * {@link NativeJava#type(Object, Object) Java.type()} method.
55 */
56 @ScriptClass("JavaImporter")
57 public final class NativeJavaImporter extends ScriptObject {
58 private final Object[] args;
59
60 // initialized by nasgen
61 private static PropertyMap $nasgenmap$;
62
63 private NativeJavaImporter(final Object[] args, final ScriptObject proto, final PropertyMap map) {
64 super(proto, map);
65 this.args = args;
66 }
67
68 private NativeJavaImporter(final Object[] args, final Global global) {
69 this(args, global.getJavaImporterPrototype(), $nasgenmap$);
70 }
71
72 private NativeJavaImporter(final Object[] args) {
73 this(args, Global.instance());
74 }
75
76 @Override
77 public String getClassName() {
78 return "JavaImporter";
79 }
80
81 /**
82 * Constructor
83 * @param isNew is the new operator used for instantiating this NativeJavaImporter
84 * @param self self reference
85 * @param args arguments
86 * @return NativeJavaImporter instance
87 */
88 @Constructor(arity = 1)
89 public static Object constructor(final boolean isNew, final Object self, final Object... args) {
|