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

Method $proxy$xxx has illegal modifiers: 0x1008

    XMLWordPrintable

Details

    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu Linux 20.04, OpenJDK Runtime Environment (build 19-ea+25-1892)

      A DESCRIPTION OF THE PROBLEM :
      I have a sealed interface implemented by records and try pattern matching on the record types (JEP 405). The program fails to run and displays the message "Method $proxy$seq in class SubSequence has illegal modifiers: 0x1008"

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the source file below.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The program runs and prints "sip"
      ACTUAL -
      The program dies with the message

      Method $proxy$seq in class SubSequence has illegal modifiers: 0x1008

      ---------- BEGIN SOURCE ----------
      import java.util.*;

      sealed interface SubSequence extends CharSequence {
         CharSequence seq();

         default int start() {
            return 0;
         }

         default int end() {
            return seq().length();
         }

         default char charAt(int index) {
            Objects.checkIndex(index, length());
            return seq().charAt(start() + index);
         }

         default int length() {
            return end() - start();
         }
         
         default CharSequence subSequence(int s, int e) {
            return new SubSequence.Middle(seq(), start() + s, start() + e);
         }

         record Initial(CharSequence seq, int end) implements SubSequence {
            public Initial {
               Objects.checkIndex(end, seq.length());
            }
            public String toString() {
               return seq.subSequence(0, end).toString();
            }
         }
         record Final(CharSequence seq, int start) implements SubSequence {
            public Final {
               Objects.checkIndex(start, seq.length());
            }
            public String toString() {
               return seq.subSequence(start, seq.length()).toString();
            }
         }
         record Middle(CharSequence seq, int start, int end) implements SubSequence {
            public Middle {
               Objects.checkFromToIndex(start, end, seq.length());
            }
            public String toString() {
               return seq().subSequence(start, end).toString();
            }
         }
         static CharSequence simplify(SubSequence seq) {
            return switch (seq) {
            case Initial(var cs, var e) when e == cs.length() -> cs;
            case Final(var cs, var s) when s == 0 -> cs;
            case Middle(var cs, var s, var e) when s == 0 && e == cs.length() -> cs;
            default -> seq;
            };
         }
      }

      public class Test2 {
         public static void main(String[] args) {
            System.out.println(SubSequence.simplify(new SubSequence.Final(
                  new SubSequence.Initial("Mississippi", 6), 3)));
         }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Don't use pattern matching

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              jlahoda Jan Lahoda
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: