Eclipse 3.5 zu Eclipse 3.6 –> @SuppressWarnings("unchecked") und @SuppressWarnings("rawtypes")

Von http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.isv/porting/3.6/incompatibilities.html Punkt 3:

@SuppressWarnings("unchecked") does not ignore raw types warnings anymore

What is affected: Usage of @SuppressWarnings("unchecked").

Description: Up to Eclipse 3.5, @SuppressWarnings("unchecked") was used to suppress the unchecked and raw types warnings. This was not consistent with other compilers (e.g. javac). A new warning token "rawtypes" has been added to cover the case of raw type warnings exclusively. So in order to get rid of all warnings, in Eclipse 3.6, it might be required to add "rawtypes" in the warning token list.

If it is not possible to update the code, a system property (-DsuppressRawWhenUnchecked=true) can be added to the -vmargs list on startup. This preserves the old behavior. The projects need to be manually cleaned and rebuilt after toggling the property.

Action required: When new warnings that were previously ignored are now reported, add "rawtypes" to the list of warning tokens.

Before:

@SuppressWarnings("unchecked")
    void bar(List list) {
        List<String> ls2 = list;
    }
@SuppressWarnings("unchecked")
private List l;

After:

@SuppressWarnings({"unchecked", "rawtypes"})
    void bar(List list) {
        List<String> ls2 = list;
    }
@SuppressWarnings("rawtypes")
private List l;

Über Christian Ullenboom

Ich bin Christian Ullenboom und Autor der Bücher ›Java ist auch eine Insel. Einführung, Ausbildung, Praxis‹ und ›Java SE 8 Standard-Bibliothek. Das Handbuch für Java-Entwickler‹. Seit 1997 berate ich Unternehmen im Einsatz von Java. Sun ernannte mich 2005 zum ›Java-Champion‹.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.