'java.lang.ClassFormatError: Class file version does not support constant tag 18 in class file com/test/main/TestClass

I came accross this error java.lang.ClassFormatError: Class file version does not support constant tag 18 in class file com/test/main/MathUtilsTest while compiling Junit Test Cases. Please find below code snippet and have tried both with java 8 & 11. Rest test cases are working fine.

 @Test 
      void divideTwoInputs() { 
          MathUtils mathu = new MathUtils();
          assertThrows(ArithmeticException.class, ()->mathu.divideGivenInputs(1,0),"given two inputs to be divided");
      } 

MathUtils class

public double divideGivenInputs(double a, double b) {
        return a/b;
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source