java.lang.NoSuchMethodError: java.lang.Enum.foo2()Ljava/lang/String;

JDK Bug System | Webbug Group | 4 months ago
  1. 0

    FULL PRODUCT VERSION : openjdk version "1.8.0_102" OpenJDK Runtime Environment (build 1.8.0_102-b14) OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux localhost.localdomain 4.7.4-100.fc23.x86_64 #1 SMP Thu Sep 15 18:48:53 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : A return of <T extends Enum<T> & I2> is being assumed as Enum<T> rather than Enum<T> & I2. Hence any direct invocation of methods in I2 are not being executed at runtime and throwing a NoSuchMethodException as follows: Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Enum.foo2()Ljava/lang/String; at test.tourlandish.Test.main(Test.java:86) If you go ahead and typecast it to the Interface before invoking the method then everything works fine. Also there is no compilation error. This error is not occurring in Java 7.0.62. REGRESSION. Last worked in version 7u76 ADDITIONAL REGRESSION INFORMATION: openjdk version "1.8.0_102" OpenJDK Runtime Environment (build 1.8.0_102-b14) OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode) STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : package test.tourlandish; public class Test { public static class C1 implements I1 { @SuppressWarnings("unchecked") @Override public <T extends Enum<T> & I2> T foo1() { return (T) C2.A; } } public static enum C2 implements I2 { A; @Override public String foo2() { return "yoo"; } } public static interface I1 { public <T extends Enum<T> & I2> T foo1(); } public static interface I2 { public String foo2(); } public static void main(String[] args) { C1 c1 = new C1(); // This works System.out.println(((I2) c1.foo1()).foo2()); // This does not work System.out.println(c1.foo1().foo2()); } } Run the above code. The code in main() that throws the error is marked. The typecasting variation which works is also marked. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - yoo yoo ACTUAL - yooException in thread "main" java.lang.NoSuchMethodError: java.lang.Enum.foo2()Ljava/lang/String; at test.tourlandish.Test.main(Test.java:89) ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Enum.foo2()Ljava/lang/String; at test.tourlandish.Test.main(Test.java:89) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- package test.tourlandish; public class Test { public static class C1 implements I1 { @SuppressWarnings("unchecked") @Override public <T extends Enum<T> & I2> T foo1() { return (T) C2.A; } } public static enum C2 implements I2 { A; @Override public String foo2() { return "yoo"; } } public static interface I1 { public <T extends Enum<T> & I2> T foo1(); } public static interface I2 { public String foo2(); } public static void main(String[] args) { C1 c1 = new C1(); // This works System.out.println(((I2) c1.foo1()).foo2()); // This does not work System.out.println(c1.foo1().foo2()); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : Typecast the return to Interface and then execute it's method

    JDK Bug System | 4 months ago | Webbug Group
    java.lang.NoSuchMethodError: java.lang.Enum.foo2()Ljava/lang/String;
  2. 0

    db:: 4.30::How to authenticate Weblogic Admin Console through Active Directory as

    hivmr.com | 8 months ago
    java.lang.NoSuchMethodError: com.bea.utils.misc.ProcessUtil.getPropValues(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;
  3. 0

    TestNG : Exception in thread "main" java.lang.NoSuchMethodError:

    GitHub | 6 months ago | krabhishek30
    java.lang.NoSuchMethodError: org.testng.internal.Utils.defaultIfStringEmpty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    db:: 3.51::Unable to start applications/modules in weblogic Admin Server k1

    hivmr.com | 6 months ago
    java.lang.NoSuchMethodError: com.bea.utils.misc.ProcessUtil.getPropValues(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;
  6. 0

    Unable to Open the Admin Console

    Oracle Community | 6 years ago | 844867
    java.lang.NoSuchMethodError: com.bea.utils.misc.ProcessUtil.getPropValues(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NoSuchMethodError

      java.lang.Enum.foo2()Ljava/lang/String;

      at test.tourlandish.Test.main()
    2. test.tourlandish
      Test.main
      1. test.tourlandish.Test.main(Test.java:89)
      1 frame