Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8026480

Unnecessary Signature attribute generated for enum constructors

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8, 9
    • tools
    • None

      Consider:
      ---
      enum E { A; }
      ---

      This compiled&decompiled leads to:
      ---
        private E();
          descriptor: (Ljava/lang/String;I)V
          flags: ACC_PRIVATE
          Code:
            stack=3, locals=3, args_size=3
               0: aload_0
               1: aload_1
               2: iload_2
               3: invokespecial #6 // Method java/lang/Enum."<init>":(Ljava/lang/String;I)V
               6: return
            LineNumberTable:
              line 1: 0
          Signature: #24 // ()V
      ---

      The Signature attribute is not mandatory in this case (as the constructor's parameters are not generic). Avoiding the attribute may provide smaller, cleaner classfiles, and so should be considered.

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: