changeset 968:67d6b2df47ba

7022711: compiler crash in try-with-resources Reviewed-by: mcimadamore
author jjg
date Mon, 28 Feb 2011 13:42:24 -0800
parents bf9f162c7104
children 938dda0bec17
files src/share/classes/com/sun/tools/javac/code/Kinds.java test/tools/javac/TryWithResources/T7022711.java test/tools/javac/TryWithResources/T7022711.out
diffstat 3 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Kinds.java	Mon Feb 28 13:37:48 2011 -0800
+++ b/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/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/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