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

Regression: compiling program with lambda crashes compiler

    XMLWordPrintable

    Details

      Description

      This program started crashing in recent lambda builds:

      class CompilerCrash {
          // This crashes.
          private static void makeTask1() {
              class LocalClass {
                  private Runnable r = () -> {};
              }
          }
          // This crashes, too.
          private void makeTask2() {
              class LocalClass {
                  private Runnable r = () -> {};
              }
          }
          // This is fine.
          private class InnerClass {
              private Runnable r = () -> {};
          }
      }

      There is a bad cast in LambdaToMethod:

                  MethodSymbol owner = (MethodSymbol) localContext.owner;
                  ListBuffer<Attribute.TypeCompound> ownerTypeAnnos = new ListBuffer<Attribute.TypeCompound>();
                  ListBuffer<Attribute.TypeCompound> lambdaTypeAnnos = new ListBuffer<Attribute.TypeCompound>();

                  for (Attribute.TypeCompound tc : owner.getRawTypeAttributes()) {
                      if (tc.position.onLambda == tree) {
                          lambdaTypeAnnos.append(tc);
                      } else {
                          ownerTypeAnnos.append(tc);
                      }
                  }

      Those lines seem to have been added by this changeset:

      Changeset: ddb4a2bfcd82
      Author: jjg
      Date: 2013-05-14 15:04 -0700
      URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/ddb4a2bfcd82

      8013852: update reference impl for type-annotations
      Reviewed-by: jjg
      Contributed-by: wdietl@gmail.com, steve.sides@oracle.com, joel.franck@oracle.com, alex.buckley@oracle.com

      ! src/share/classes/com/sun/tools/classfile/ClassWriter.java
      ! src/share/classes/com/sun/tools/classfile/TypeAnnotation.java
      ! src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
      ! src/share/classes/com/sun/tools/javac/code/Annotations.java
      ! src/share/classes/com/sun/tools/javac/code/Attribute.java
      ! src/share/classes/com/sun/tools/javac/code/Printer.java
      ! src/share/classes/com/sun/tools/javac/code/Type.java
      ! src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java
      ! src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
      ! src/share/classes/com/sun/tools/javac/code/Types.java
      ! src/share/classes/com/sun/tools/javac/comp/Annotate.java
      ! src/share/classes/com/sun/tools/javac/comp/Attr.java
      ! src/share/classes/com/sun/tools/javac/comp/Check.java
      ! src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
      ! src/share/classes/com/sun/tools/javac/comp/Lower.java
      ! src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
      ! src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
      ! src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
      ! src/share/classes/com/sun/tools/javac/jvm/Code.java
      ! src/share/classes/com/sun/tools/javac/jvm/Gen.java
      ! src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
      ! src/share/classes/com/sun/tools/javac/parser/JavacParser.java
      ! src/share/classes/com/sun/tools/javac/resources/compiler.properties
      ! src/share/classes/com/sun/tools/javac/tree/JCTree.java
      ! src/share/classes/com/sun/tools/javac/tree/Pretty.java
      ! src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
      ! src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
      ! src/share/classes/com/sun/tools/javac/tree/TreeScanner.java
      ! src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
      ! src/share/classes/com/sun/tools/javac/util/List.java
      ! src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java
      ! src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java
      ! src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java
      ! src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java
      ! src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java
      ! src/share/classes/com/sun/tools/javadoc/JavadocEnter.java
      ! src/share/classes/com/sun/tools/javadoc/Messager.java
      ! src/share/classes/com/sun/tools/javadoc/TypeMaker.java
      ! src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java
      ! test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
      ! test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java
      ! test/com/sun/javadoc/typeAnnotations/smoke/pkg/TargetTypes.java
      ! test/tools/javac/annotations/typeAnnotations/attribution/Scopes.java
      ! test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java
      ! test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest1.java
      ! test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java
      + test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest3.java
      ! test/tools/javac/annotations/typeAnnotations/classfile/DeadCode.java
      ! test/tools/javac/annotations/typeAnnotations/classfile/NewTypeArguments.java
      + test/tools/javac/annotations/typeAnnotations/classfile/T8008762.java
      + test/tools/javac/annotations/typeAnnotations/classfile/T8008769.java
      + test/tools/javac/annotations/typeAnnotations/classfile/T8010015.java
      + test/tools/javac/annotations/typeAnnotations/classfile/TestNewCastArray.java
      ! test/tools/javac/annotations/typeAnnotations/classfile/TypeCasts.java
      ! test/tools/javac/annotations/typeAnnotations/classfile/Wildcards.java
      ! test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.java
      + test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.out
      ! test/tools/javac/annotations/typeAnnotations/failures/LintCast.out
      ! test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.java
      ! test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.out
      + test/tools/javac/annotations/typeAnnotations/failures/T8008751.java
      + test/tools/javac/annotations/typeAnnotations/failures/T8009360.java
      + test/tools/javac/annotations/typeAnnotations/failures/T8011722.java
      + test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.java
      + test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out
      + test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.java
      + test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.out
      ! test/tools/javac/annotations/typeAnnotations/failures/common/receiver/Nesting.java
      ! test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.out
      ! test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.java
      ! test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.out
      ! test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.java
      ! test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.out
      + test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.java
      + test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.out
      + test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java
      ! test/tools/javac/annotations/typeAnnotations/newlocations/Lambda.java
      ! test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java
      + test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/NewObjects.java
      ! test/tools/javac/annotations/typeAnnotations/referenceinfos/ReferenceInfoUtil.java
      + test/tools/javac/annotations/typeAnnotations/referenceinfos/Test.java
      ! test/tools/javac/api/TestJavacTaskScanner.java
      + test/tools/javac/diags/examples/ArrayAndReceiver.java
      + test/tools/javac/diags/examples/IncorrectConstructorReceiverName.java
      + test/tools/javac/diags/examples/IncorrectConstructorReceiverType.java
      + test/tools/javac/diags/examples/IncorrectReceiverName.java
      + test/tools/javac/diags/examples/ReceiverParameterNotApplicableConstructor.java
      + test/tools/javac/diags/examples/VarargsAndReceiver.java
      ! test/tools/javac/lib/DPrinter.java
      + test/tools/javac/processing/model/type/BasicAnnoTests.java
      ! test/tools/javac/tree/SourceTreeScannerTest.java
      ! test/tools/javap/output/RepeatingTypeAnnotations.java
      ! test/tools/javap/typeAnnotations/NewArray.java
      ! test/tools/javap/typeAnnotations/Presence.java
      ! test/tools/javap/typeAnnotations/TypeCasts.java

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jjg Jonathan Gibbons
              Reporter:
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: