7022711: compiler crash in try-with-resources
authorjjg
Mon, 28 Feb 2011 13:42:24 -0800
changeset 8620 0b04e5235f25
parent 8619 15a69d0db208
child 8621 ce0bce60cffc
7022711: compiler crash in try-with-resources Reviewed-by: mcimadamore
langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java
langtools/test/tools/javac/TryWithResources/T7022711.java
langtools/test/tools/javac/TryWithResources/T7022711.out
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java	Mon Feb 28 13:37:48 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java	Mon Feb 28 13:42:24 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -163,6 +163,7 @@
         case PARAMETER:
         case LOCAL_VARIABLE:
         case EXCEPTION_PARAMETER:
+        case RESOURCE_VARIABLE:
             return KindName.VAR;
 
         case CONSTRUCTOR:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/T7022711.java	Mon Feb 28 13:42:24 2011 -0800
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7022711
+ * @summary compiler crash in try-with-resources
+ * @compile/fail/ref=T7022711.out -XDrawDiagnostics T7022711.java
+ */
+
+import java.io.*;
+
+class T7022711 {
+    public static void main (String args[]) throws Exception {
+        try (DataInputStream is = new DataInputStream(new FileInputStream("x"))) {
+            while (true) {
+                is.getChar();  // method not found
+            }
+        } catch (EOFException e) {
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/T7022711.out	Mon Feb 28 13:42:24 2011 -0800
@@ -0,0 +1,2 @@
+T7022711.java:14:19: compiler.err.cant.resolve.location.args: kindname.method, getChar, , , (compiler.misc.location.1: kindname.variable, is, java.io.DataInputStream)
+1 error