src/share/classes/com/sun/tools/javac/comp/Check.java

Print this page

        

@@ -1601,10 +1601,26 @@
             }
         }
         return false;
     }
 
+    /**
+     * Check that a resource is a valid arm resource (e.g. the resource type must be
+     * a subtype of java.lang.autoCloseable).
+     *
+     * @param resource resource tree
+     */
+    void checkArmResource(JCTree resource) {
+        if (types.asSuper(resource.type, syms.autoCloseableType.tsym) == null) {
+            typeError(resource.pos(),
+                    diags.fragment("arm.not.applicable.to.type"),
+                    resource.type,
+                    syms.autoCloseableType);
+            resource.type = types.createErrorType(resource.type);
+        }
+    }
+
     /** Check that a given method conforms with any method it overrides.
      *  @param tree         The tree from which positions are extracted
      *                      for errors.
      *  @param m            The overriding method.
      */