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

Illegal access error when calling method reference

    XMLWordPrintable

Details

    • b82
    • Verified

    Description


      This started to fail when BaseStream was made package private:

      import java.util.Arrays;
      import java.util.stream.Stream;

      public class IllegalAccessErrorTest {

           public static void main(String[] args) {

               Stream stream = Arrays.asList("a", "b").stream();
               System.err.println("iterator = " + stream.iterator());
               Iterable iterable = stream::iterator;
               System.err.println("iterable = " + iterable);
           }
      }

      when compiled/run on b73 the output is:


      iterator = java.util.stream.ReferencePipeline$6@3256a5
      Exception in thread "main" java.lang.IllegalAccessError: tried to access
      class java.util.stream.BaseStream from class IllegalAccessErrorTest
           at IllegalAccessErrorTest.main(IllegalAccessErrorTest.java:10)

      Attachments

        Issue Links

          Activity

            People

              mcimadamore Maurizio Cimadamore
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: