JDK-7090499 : missing rawtypes warnings in anonymous inner class
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2011-09-14
  • Updated: 2012-04-20
  • Resolved: 2012-04-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b10Fixed
Related Reports
Relates :  
Relates :  
Description
This code:

class Test<X> {
    { new Object() {
       Test x;
    }; }
     
}

should generate a warning when compiled with the -Xlint:rawtypes flag, but it doesn't.

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/47147081d5b4
06-10-2011

EVALUATION JDK part of this change: Changeset: ff5e57dc1fb3 Author: chegar Date: 2011-10-06 12:15 +0100 URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/ff5e57dc1fb3 7090499: missing rawtypes warnings in anonymous inner class Summary: Fix anonymous inner classes with raw types currently being built in the jdk with -Werror Reviewed-by: mcimadamore, alanb ! src/share/classes/java/net/DatagramSocket.java ! src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java ! src/share/classes/sun/security/pkcs11/SunPKCS11.java
06-10-2011

EVALUATION The problem is in the check for generating raw types warnings: void checkRaw(JCTree tree, Env<AttrContext> env) { if (lint.isEnabled(LintCategory.RAW) && tree.type.tag == CLASS && !TreeInfo.isDiamond(tree) && !env.enclClass.name.isEmpty() && //<--------------------------------- tree.type.isRaw()) { log.warning(LintCategory.RAW, tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type); } } The condition has been added in order to avoid spurious warnings in the anon inner class default constructor - however the condition is too broad, and ends up with disabling all raw types warnings when the enclosing class is an anonymous class.
14-09-2011