< prev index next >

test/script/nosecurity/JDK-8044798.js

Print this page
rev 1904 : 8138882: Performance regression due to anonymous classloading
Reviewed-by: attila, sundar


 109     print(valueAsStringMethod.invoke(null, value));
 110 }
 111 
 112 printValue(undefined);
 113 printValue(null);
 114 printValue("hello");
 115 printValue(Math.PI);
 116 printValue(this);
 117 
 118 // The below are not part of DebuggerSupport. But we need these to
 119 // test DebuggerSupport.getSourceInfo etc. which need compiled script class
 120 
 121 var Source = Java.type("jdk.nashorn.internal.runtime.Source");
 122 var Context = Java.type("jdk.nashorn.internal.runtime.Context");
 123 var sourceCls = Source.class;
 124 var errorMgrCls = Java.type("jdk.nashorn.internal.runtime.ErrorManager").class;
 125 var booleanCls = Java.type("java.lang.Boolean").TYPE;
 126 
 127 // private compile method of Context class
 128 var compileMethod = Context.class.getDeclaredMethod("compile",
 129                 sourceCls, errorMgrCls, booleanCls);
 130 compileMethod.accessible = true;
 131 
 132 var scriptCls = compileMethod.invoke(Context.context,
 133     Source.sourceFor("test", "print('hello')"),
 134     new Context.ThrowErrorManager(), false);
 135 
 136 var SCRIPT_CLASS_NAME_PREFIX = "jdk.nashorn.internal.scripts.Script$";
 137 print("script class name pattern satisfied? " +
 138     scriptCls.name.startsWith(SCRIPT_CLASS_NAME_PREFIX));
 139 
 140 var srcInfo = getSourceInfoMethod.invoke(null, scriptCls);
 141 var srcInfoFields = srcInfo.class.declaredFields;
 142 Arrays.sort(srcInfoFields, function(f1, f2) f1.name.compareTo(f2.name));
 143 
 144 print("Source info");
 145 for each (var f in srcInfoFields) {
 146     f.accessible = true;
 147     var fieldValue = f.get(srcInfo);
 148     if (fieldValue instanceof CharArray) {
 149         fieldValue = new java.lang.String(fieldValue);
 150     }
 151 
 152     print(f.name, "=", fieldValue);
 153 }


 109     print(valueAsStringMethod.invoke(null, value));
 110 }
 111 
 112 printValue(undefined);
 113 printValue(null);
 114 printValue("hello");
 115 printValue(Math.PI);
 116 printValue(this);
 117 
 118 // The below are not part of DebuggerSupport. But we need these to
 119 // test DebuggerSupport.getSourceInfo etc. which need compiled script class
 120 
 121 var Source = Java.type("jdk.nashorn.internal.runtime.Source");
 122 var Context = Java.type("jdk.nashorn.internal.runtime.Context");
 123 var sourceCls = Source.class;
 124 var errorMgrCls = Java.type("jdk.nashorn.internal.runtime.ErrorManager").class;
 125 var booleanCls = Java.type("java.lang.Boolean").TYPE;
 126 
 127 // private compile method of Context class
 128 var compileMethod = Context.class.getDeclaredMethod("compile",
 129                 sourceCls, errorMgrCls, booleanCls, booleanCls);
 130 compileMethod.accessible = true;
 131 
 132 var scriptCls = compileMethod.invoke(Context.context,
 133     Source.sourceFor("test", "print('hello')"),
 134     new Context.ThrowErrorManager(), false, false);
 135 
 136 var SCRIPT_CLASS_NAME_PREFIX = "jdk.nashorn.internal.scripts.Script$";
 137 print("script class name pattern satisfied? " +
 138     scriptCls.name.startsWith(SCRIPT_CLASS_NAME_PREFIX));
 139 
 140 var srcInfo = getSourceInfoMethod.invoke(null, scriptCls);
 141 var srcInfoFields = srcInfo.class.declaredFields;
 142 Arrays.sort(srcInfoFields, function(f1, f2) f1.name.compareTo(f2.name));
 143 
 144 print("Source info");
 145 for each (var f in srcInfoFields) {
 146     f.accessible = true;
 147     var fieldValue = f.get(srcInfo);
 148     if (fieldValue instanceof CharArray) {
 149         fieldValue = new java.lang.String(fieldValue);
 150     }
 151 
 152     print(f.name, "=", fieldValue);
 153 }
< prev index next >