RFR(m): 8145468 deprecations for java.lang

Stuart Marks stuart.marks at oracle.com
Thu Apr 14 22:17:08 UTC 2016


On 4/14/16 6:21 AM, Remi Forax wrote:
> you are not the first one to try to change the integers defined in org.objectweb.asm.Opcodes, those values are compared by ref (not by value) inside ASM.
> You're patch will change the behavior of any Interpreters that also use some Integers created by Integer.valueOf() because valueOf may cache the Integer references.
>
> I will add a comment in the ASM trunk for avoid such refactoring in the future.

Hi Remi,

Oh! This is the kind of issue that I was concerned about. Most code doesn't 
depend on identity semantics, and it's sometimes hard to tell if it does. I'll 
revert the autoboxing changes.

Since we still need to get rid of the warnings, we'll need to suppress them. I 
think adding @SuppressWarnings at the top of the file is a little cleaner than 
adding it in front of each declaration, even though it's farther away. What do 
you think of the diff below?

(I agree with Brian's comments about cleaning up this code, but I think that 
should be done separately from this changeset.)

Thanks,

s'marks



diff -r 36025112dfdb 
src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java 
Thu Apr 14 12:17:23 2016 -0700
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java 
Thu Apr 14 15:14:46 2016 -0700
@@ -70,6 +70,7 @@
   * @author Eric Bruneton
   * @author Eugene Kuleshov
   */
+ at SuppressWarnings("deprecation") // for Integer(int) constructor
  public interface Opcodes {

      // ASM API versions
@@ -176,6 +177,8 @@
       */
      int F_SAME1 = 4;

+    // For reference comparison purposes, construct new instances
+    // instead of using valueOf() or autoboxing.
      Integer TOP = new Integer(0);
      Integer INTEGER = new Integer(1);
      Integer FLOAT = new Integer(2);



More information about the core-libs-dev mailing list