Status of JEP159?

Robbin Ehn robbin.ehn at oracle.com
Mon Oct 16 13:55:31 UTC 2017


On 10/16/2017 03:31 PM, Alan Bateman wrote:
> 
> 
> On 16/10/2017 14:21, Robbin Ehn wrote:
>> Hi, if you use class file load hook you can add/remove public methods.
>> Since this is before the class have been published we don't know how it should look.
>> Whether this is according to spec or not, I have no clue.
>>
>> Is it on CFLH ?
>>
> No issue adding or removing methods or making any other changes to the class file in the CFLH but only for the initial load. The CFLH will be re-run when the class is 
> transformed (RetransformClasses) but that cannot add/remove methods or do other schema changes.

There is actually an issue, we start all transformation with 'on' disk version.
If the agent that did the addition of a public method e.g. exits(removeTransformer) we can never re-transform it, instead we get:
"error method delete"
It have been suggested that we should use 'first published' class version as a baseline (the version after CFLH), but would break current agents (I assume).

This is my old patch for it:
diff -r 46a21d1c5f1c src/share/vm/prims/jvmtiExport.cpp
--- a/src/share/vm/prims/jvmtiExport.cpp    Fri Aug 12 14:12:55 2016 -0700
+++ b/src/share/vm/prims/jvmtiExport.cpp    Tue Aug 16 16:22:29 2016 +0200
@@ -661,7 +661,8 @@
        if (env->is_retransformable() && env->is_enabled(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK)) {
          // retransformable agents need to cache the original class file
          // bytes if changes are made via the ClassFileLoadHook
-        post_to_env(env, true);
+        // cache the last version after load is completed, hence the published version
+        post_to_env(env, _load_kind != jvmti_class_load_kind_load);
        }
      }
    }

Is it a bug or work as intended? (or a bug we can't fix)

/Robbin

> 
> -Alan


More information about the serviceability-dev mailing list