changeset 34:49be04cc6389 default tip java9-try

cyclic dependency ...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 19 Dec 2017 11:21:23 +0900
parents a0b1b1aa6cdf
children
files build.xml src/annotations/module-info.java src/classes/module-info.java src/main/gov/nasa/jpf/vm/HashedAllocationContext.java src/main/module-info.java
diffstat 5 files changed, 36 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/build.xml	Tue Dec 19 09:05:20 2017 +0900
+++ b/build.xml	Tue Dec 19 11:21:23 2017 +0900
@@ -119,7 +119,7 @@
     <javac srcdir="src/peers" destdir="build/peers" includeantruntime="false"
            debug="${debug}" deprecation="${deprecation}" classpathref="lib.path">
     	<compilerarg value="-XDenableSunApiLintControl"/>
-    	<compilerarg value="-Xlint:all,-sunapi,-serial"/>    	
+        <!-- <compilerarg value="-Xlint:all,-sunapi,-serial"/>    	 -->
      </javac>
   </target>
   
@@ -127,8 +127,12 @@
     <mkdir dir="build/classes"/>
     <javac srcdir="src/classes" destdir="build/classes" includeantruntime="false"
            debug="${debug}" deprecation="${deprecation}">
+      <compilerarg value="--module-path"/>
+      <compilerarg value="build/annotations"/> 
       <compilerarg value="-XDenableSunApiLintControl"/>
-      <compilerarg value="-Xlint:all,-sunapi"/>   
+      <compilerarg value="--patch-module"/>
+      <compilerarg value="java.base=src/classes"/>
+      <!-- <compilerarg value="-Xlint:all,-sunapi"/>    -->
       <classpath>
         <path refid="lib.path"/>
         <pathelement location="build/annotations"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/annotations/module-info.java	Tue Dec 19 11:21:23 2017 +0900
@@ -0,0 +1,4 @@
+module gov.nasa.jpf.annotation {
+    exports gov.nasa.jpf.annotation;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/classes/module-info.java	Tue Dec 19 11:21:23 2017 +0900
@@ -0,0 +1,3 @@
+module java.base {
+    requires gov.nasa.jpf.annotation;
+}
--- a/src/main/gov/nasa/jpf/vm/HashedAllocationContext.java	Tue Dec 19 09:05:20 2017 +0900
+++ b/src/main/gov/nasa/jpf/vm/HashedAllocationContext.java	Tue Dec 19 11:21:23 2017 +0900
@@ -20,8 +20,11 @@
 // see mixinJPFStack() comments
 //import sun.misc.SharedSecrets;
 //import sun.misc.JavaLangAccess;
-import jdk.internal.misc.SharedSecrets;
-import jdk.internal.misc.JavaLangAccess;
+// import jdk.internal.misc.SharedSecrets;
+// import jdk.internal.misc.JavaLangAccess;
+import java.lang.StackWalker;
+import java.util.stream.Stream;
+import java.util.Optional;
 
 import gov.nasa.jpf.Config;
 import static gov.nasa.jpf.util.OATHash.*;
@@ -84,7 +87,7 @@
    *   if (e.getClassName().equals("gov.nasa.jpf.vm.MJIEnv") && e.getMethodName().startsWith("new")){ ..
    */ 
   
-   static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
+   // static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
    static final String ENV_CLSNAME = MJIEnv.class.getName();
   
   // <2do> this method is problematic - we should not assume a fixed stack position
@@ -94,7 +97,7 @@
   // those are convenience methods used from a gazillion of places that might share
    // the same SUT state
   static int mixinJPFStack (int h) {
-    throwable.fillInStackTrace();
+    // throwable.fillInStackTrace();
     
     // we know the callstack is at least 4 levels deep:
     //   0: mixinJPFStack
@@ -108,12 +111,17 @@
     // this would create state leaks for allocations that are triggered by SUT threads and
     // have different native paths (e.g. Class object creation caused by different SUT thread context)
     
-    StackTraceElement e = JLA.getStackTraceElement(throwable, 4); // see note below regarding fixed call depth fragility
+    // StackTraceElement e = JLA.getStackTraceElement(throwable, 4); // see note below regarding fixed call depth fragility
     // <2do> this sucks - MJIEnv.newObject/newArray/newString are used from a gazillion of places that might not differ in SUT state
-    if (e.getClassName() == ENV_CLSNAME && e.getMethodName().startsWith("new")){
+    // if (e.getClassName() == ENV_CLSNAME && e.getMethodName().startsWith("new")){
       // there is not much use to loop, since we don't have a good end condition
-      e = JLA.getStackTraceElement(throwable, 5);
-    }
+    //   e = JLA.getStackTraceElement(throwable, 5);
+    // }
+
+    Optional<StackWalker.StackFrame> o = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk(s ->
+     s.dropWhile(f -> f.getClassName() == ENV_CLSNAME && f.getMethodName().startsWith("new")) .findFirst());
+    if (!o.isPresent()) return h;
+    StackWalker.StackFrame e = o.get();
           
     // NOTE - this is fragile since it is implementation dependent and differs
     // between JPF runs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/module-info.java	Tue Dec 19 11:21:23 2017 +0900
@@ -0,0 +1,7 @@
+module gov.nasa.jpf {
+    requires jdk.unsupported;
+    requires java.logging;
+    requires java.management;
+    requires javafx.swing;
+    requires gov.nasa.jpf.annotation;
+}