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

Assertion failed in javac

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u40
    • Fix Version/s: 9
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86
    • OS:
      other

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_40-ea"
      Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b19)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS Yosemite 10.10.1 (14B25)

      A DESCRIPTION OF THE PROBLEM :
      Assertion fails in javac when I try to compile my class (see stacktrace below). Code sample is attached.

      ADDITIONAL REGRESSION INFORMATION:
      Yes, it worked in some previous java 8 release, but I don't remember which one.
      Assertion fails in 8u40 early access preview.
      It produces another exception (NullPointerException) in latest stable release (8u25)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute "javac Main.java"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Succesful compilation
      ACTUAL -
      Assertion failed in javac

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An exception has occurred in the compiler (1.8.0_40-ea). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.AssertionError: attribution shouldn't be happening here
      at com.sun.tools.javac.util.Assert.error(Assert.java:133)
      at com.sun.tools.javac.util.Assert.check(Assert.java:94)
      at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:591)
      at com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:479)
      at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:182)
      at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:567)
      at com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:604)
      at com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:3797)
      at com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3584)
      at com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3491)
      at com.sun.tools.javac.comp.Attr.checkMethodId(Attr.java:3470)
      at com.sun.tools.javac.comp.Attr.checkId(Attr.java:3457)
      at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3201)
      at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2011)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
      at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1806)
      at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
      at com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:386)
      at com.sun.tools.javac.comp.DeferredAttr$2.complete(DeferredAttr.java:279)
      at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:245)
      at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:232)
      at com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1003)
      at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:829)
      at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:734)
      at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:838)
      at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:579)
      at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1441)
      at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1628)
      at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1699)
      at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1672)
      at com.sun.tools.javac.comp.Resolve.findFun(Resolve.java:1832)
      at com.sun.tools.javac.comp.Resolve$8.doLookup(Resolve.java:2393)
      at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3084)
      at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3335)
      at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3320)
      at com.sun.tools.javac.comp.Resolve.resolveMethod(Resolve.java:2389)
      at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3134)
      at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2011)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
      at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1806)
      at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
      at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:608)
      at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1056)
      at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
      at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
      at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:651)
      at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1105)
      at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
      at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
      at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:994)
      at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
      at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
      at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4330)
      at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4240)
      at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4169)
      at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4144)
      at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248)
      at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
      at com.sun.tools.javac.main.Main.compile(Main.java:523)
      at com.sun.tools.javac.main.Main.compile(Main.java:381)
      at com.sun.tools.javac.main.Main.compile(Main.java:370)
      at com.sun.tools.javac.main.Main.compile(Main.java:361)
      at com.sun.tools.javac.Main.compile(Main.java:56)
      at com.sun.tools.javac.Main.main(Main.java:42)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Main {
          public static class Spectrum {
              public double[] getEnergy() {
                  return new double[0];
              }
          }

          protected Spectrum spectrum;

          public static class Ref<T> {
              T value;

              public Ref() {
              }

              public Ref(T value) {
                  this.value = value;
              }

              public boolean isNull() {
                  return value == null;
              }

              public T get() {
                  return value;
              }

              public void set(T value) {
                  this.value = value;
              }
          }

          public static <T>T maxKey(Stream<T> stream, Function<T, Double> function) {
              Ref<Double> max = new Ref<>();
              Ref<T> index = new Ref<>();
              stream.forEach(v -> {
                  Double value = function.apply(v);

                  if (max.isNull() || value > max.get()) {
                      max.set(value);
                      index.set(v);
                  }
              });

              return index.get();
          }

          public static int interpolate(int x, int x0, int x1, int y0, int y1) {
              return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
          }

          public static double interpolate(double x, double x0, double x1, double y0, double y1) {
              return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
          }

          protected int getXByFrequency(double frequency) {
              Insets insets = null;
              return (int) Math.round(interpolate(frequency, getMinSpectrumCoord(), getMaxSpectrumCoord(), insets.left, getWidth() - insets.right));
          }

          private int getWidth() {
              return 0;
          }

          private double getMaxSpectrumCoord() {
              return 0;
          }

          private double getMinSpectrumCoord() {
              return 0;
          }

          void foo() {
              int maxBpmIndex = 0;
              int xcur = getXByFrequency(maxKey(IntStream.range(0, maxBpmIndex).boxed(), i -> Math.abs(spectrum.getEnergy()[i])));
          }
      }

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sadayapalam Srikanth Adayapalam
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: