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

Multi-catch leads to IllegalAccessError when least-upper-bound is inaccessible

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • tbd
    • 19, 20
    • tools

    Description

      The following run-time exception is raised

          > Exception in thread "main" java.lang.IllegalAccessError:
          > failed to access class pkg.Exceptions$EBase from class ExceptionsTest
          > (pkg.Exceptions$EBase and ExceptionsTest are in unnamed module of loader 'app')
          > at ExceptionsTest.main(ExceptionsTest.java:8)

      when running "java ExceptionsTest" program with

          > package pkg;
          > public class Exceptions {
          > private static class EBase extends Exception {
          > public void m() {}
          > }
          > public static class E1 extends EBase {}
          > public static class E2 extends EBase {}
          > }

      and

          > import pkg.Exceptions;
          > public class ExceptionsTest {
          > public static void main(String[] args) {
          > try {
          > m1();
          > } catch (Exceptions.E1 | Exceptions.E2 e) {
          > e.m();
          > }
          > }
          > private static void m1() throws Exceptions.E1, Exceptions.E2 {
          > throw new Exceptions.E1();
          > }
          > }

      Source(s):
      - https://gist.github.com/DasBrain/61d2859a66183d29cb2eb9bf4cc1c81b
      - https://twitter.com/lukaseder/status/1544713480024068098

      Attachments

        Issue Links

          Activity

            People

              vromero Vicente Arturo Romero Zaldivar
              cstein Christian Stein
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: