Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8227043 JEP 360: Sealed Classes (Preview)
  3. JDK-8228833

enforce that permitted subtypes are direct subtypes of the sealed class

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • None
    • tools
    • None

      Test case, 3 files, compilation OK, javap used to display class files.


      $ more play/demo2/src/*.java
      ::::::::::::::
      play/demo2/src/A.java
      ::::::::::::::
      sealed abstract class A permits C { }
      ::::::::::::::
      play/demo2/src/B.java
      ::::::::::::::
      sealed abstract class B permits C { }
      ::::::::::::::
      play/demo2/src/C.java
      ::::::::::::::
      class C extends B { }
      $ ./build/linux-x86_64-server-release/images/jdk/bin/javac -d play/demo2/classes play/demo2/src/*.java
      $ for i in $(ls play/demo2/classes/*.class) ; do ./build/linux-x86_64-server-release/images/jdk/bin/javap -v -p $i ; done
      Classfile /w/jjg/work/jdk.amber/play/demo2/classes/A.class
        Last modified Jul 30, 2019; size 213 bytes
        SHA-256 checksum 29dad7fd3236e3f8e381aafb2e5768d0a49e23306afbfc47bbbe39bfac4f09ea
        Compiled from "A.java"
      final abstract class A
        minor version: 0
        major version: 58
        flags: (0x0430) ACC_FINAL, ACC_SUPER, ACC_ABSTRACT
        this_class: #7 // A
        super_class: #2 // java/lang/Object
        interfaces: 0, fields: 0, methods: 1, attributes: 2
      Constant pool:
         #1 = Methodref #2.#3 // java/lang/Object."<init>":()V
         #2 = Class #4 // java/lang/Object
         #3 = NameAndType #5:#6 // "<init>":()V
         #4 = Utf8 java/lang/Object
         #5 = Utf8 <init>
         #6 = Utf8 ()V
         #7 = Class #8 // A
         #8 = Utf8 A
         #9 = Utf8 Code
        #10 = Utf8 LineNumberTable
        #11 = Utf8 SourceFile
        #12 = Utf8 A.java
        #13 = Utf8 PermittedSubtypes
        #14 = Class #15 // C
        #15 = Utf8 C
      {
        A();
          descriptor: ()V
          flags: (0x0000)
          Code:
            stack=1, locals=1, args_size=1
               0: aload_0
               1: invokespecial #1 // Method java/lang/Object."<init>":()V
               4: return
            LineNumberTable:
              line 1: 0
      }
      SourceFile: "A.java"
      PermittedSubtypes:
        C
      Classfile /w/jjg/work/jdk.amber/play/demo2/classes/B.class
        Last modified Jul 30, 2019; size 213 bytes
        SHA-256 checksum 2ce3a92c924a6a59f5d14e7c7bd3f80b3bfa4b092b449237bc388b3bae8057fc
        Compiled from "B.java"
      final abstract class B
        minor version: 0
        major version: 58
        flags: (0x0430) ACC_FINAL, ACC_SUPER, ACC_ABSTRACT
        this_class: #7 // B
        super_class: #2 // java/lang/Object
        interfaces: 0, fields: 0, methods: 1, attributes: 2
      Constant pool:
         #1 = Methodref #2.#3 // java/lang/Object."<init>":()V
         #2 = Class #4 // java/lang/Object
         #3 = NameAndType #5:#6 // "<init>":()V
         #4 = Utf8 java/lang/Object
         #5 = Utf8 <init>
         #6 = Utf8 ()V
         #7 = Class #8 // B
         #8 = Utf8 B
         #9 = Utf8 Code
        #10 = Utf8 LineNumberTable
        #11 = Utf8 SourceFile
        #12 = Utf8 B.java
        #13 = Utf8 PermittedSubtypes
        #14 = Class #15 // C
        #15 = Utf8 C
      {
        B();
          descriptor: ()V
          flags: (0x0000)
          Code:
            stack=1, locals=1, args_size=1
               0: aload_0
               1: invokespecial #1 // Method java/lang/Object."<init>":()V
               4: return
            LineNumberTable:
              line 1: 0
      }
      SourceFile: "B.java"
      PermittedSubtypes:
        C
      Classfile /w/jjg/work/jdk.amber/play/demo2/classes/C.class
        Last modified Jul 30, 2019; size 161 bytes
        SHA-256 checksum 513ec1291b94119ebf0c5beab95d2f2b8a446c341e3fa20e61d35637b5b8589f
        Compiled from "C.java"
      final class C extends B
        minor version: 0
        major version: 58
        flags: (0x0030) ACC_FINAL, ACC_SUPER
        this_class: #7 // C
        super_class: #2 // B
        interfaces: 0, fields: 0, methods: 1, attributes: 1
      Constant pool:
         #1 = Methodref #2.#3 // B."<init>":()V
         #2 = Class #4 // B
         #3 = NameAndType #5:#6 // "<init>":()V
         #4 = Utf8 B
         #5 = Utf8 <init>
         #6 = Utf8 ()V
         #7 = Class #8 // C
         #8 = Utf8 C
         #9 = Utf8 Code
        #10 = Utf8 LineNumberTable
        #11 = Utf8 SourceFile
        #12 = Utf8 C.java
      {
        C();
          descriptor: ()V
          flags: (0x0000)
          Code:
            stack=1, locals=1, args_size=1
               0: aload_0
               1: invokespecial #1 // Method B."<init>":()V
               4: return
            LineNumberTable:
              line 1: 0
      }
      SourceFile: "C.java"
      $

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: