JDK-8057043 : Type annotations not retained during class redefine / retransform
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 8u20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-09-02
  • Updated: 2015-06-03
  • Resolved: 2014-10-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b40Fixed
Related Reports
Duplicate :  
Relates :  
Description
SYNOPSIS
--------
Type annotations not retained during class retransformation

OPERATING SYSTEMS
-----------------
Tested on Linux, but the problem is believed to be platform independent.

FULL JDK VERSION(S)
-------------------
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b23)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)

PROBLEM DESCRIPTION
-------------------
Type annotations are not retained during class retransformation.

Observed behaviour:
--------
jdk-8u20/jdk1.8.0_20/jre/bin/java -javaagent:agent.jar -cp agent.jar 
TestTypeAnnotationsAgent

Dump type annotations
@TestAnn(site=formalParameterAnnotation)
@TestAnn(site=returnTypeAnnotation)
@TestAnn(site=throwsAnnotation)
retransform
Dumping classfile to : 
/tmp/TestTypeAnnotationsAgent$TypeAnnotatedTestClass.class

Dump type annotations
<no output>
--------

Expected behaviour:
Expect to see type annotations in the classfile provided to the transformer.

Please see documentation for JSR308, also section 4.7.20 of the Java virtual 
machine spec.

TESTCASE
--------
Attached.

REPRODUCTION INSTRUCTIONS
-------------------------
1. java -javaagent:agent.jar -cp agent.jar TestTypeAnnotationsAgent 

Comments
Something similar to JDK-6422541 needs to be done for type annotations in HotSpot
11-09-2014

This is a dup of JDK-8025934 I'm ok with keeping this open as there are two components to this fix, one in hotspot rewriting the Runtime[In]VisibleTypeAnnotation attribute and one in core-libs updating Executable
11-09-2014

Moving to hotspot/jvmti since RedefineClasses() and RetransformClasses() belong to JVM/Ti.
10-09-2014