Unchecked Assignment Intellij Vs Eclipse

Last Updated on 15 October 2017   |    Print  Email

Java Spring Framework Masterclass: Beginner to Professional

The @SuppressWarnings annotation type allows Java programmers to disable compilation warnings for a certain part of a program (type, field, method, parameter, constructor, and local variable). Normally warnings are good. However in some cases they would be inappropriate and annoying. So programmers can choose to tell the compiler ignoring such warnings if needed. This annotation type must be used with one or more warnings as its arguments, for example:@SuppressWarnings("unchecked") @SuppressWarnings({"unchecked", "deprecation"}) List of warnings vary among Java compilers. The Java Language Specification mentions only “unchecked” warning (section To see the list of warnings which would be issued by the Oracle’s Java compiler, type the following command:

javac -X

We’ll see the complete list of warnings after the line starts with -Xlint:{, as shown in the following screenshot: So the warnings issued by Oracle’s Java compiler (as of Java 1.7) are: all, cast, classfile, deprecation, dep-ann, divzero, empty, fallthrough, finally, options, overrides, path, processing, rawtypes, serial, static, try, unchecked, varargs. Different IDEs provide different list of warnings issued by their own compilers, e.g. list of suppress warnings provided by Eclipse IDE’s Java compiler. Here are some of the most commonly used warnings which have same meaning across compilers: all, deprecation, unchecked.


  • Suppressing warnings on using unchecked generic types operations:@SuppressWarnings("unchecked") void uncheckedGenerics() { List words = new ArrayList(); words.add("hello"); // this causes unchecked warning } If the above code is compiled without @SuppressWarnings("unchecked")annotation, the compiler will complain like this:XYZ.java uses unchecked or unsafe operations.
  • Suppressing warnings on using deprecated APIs:
    @SuppressWarnings("deprecation") public void showDialog() { JDialog dialog = new JDialog(); dialog.show(); // this is a deprecated method }
  • Without the @SuppressWarnings("deprecation") annotation, the compiler will issue this warning:

    XYZ.java uses or overrides a deprecated API.  
  • Suppressing multiple warnings:Suppress all unchecked and deprecation warnings for all code inside the Foo class below:@SuppressWarnings({"unchecked", "deprecation"}) class Foo { // code that may issue unchecked and deprecation warnings }
  • Suppressing warnings on local variable declaration:
    void foo(List inputList) { @SuppressWarnings("unchecked") List<String> list = (List<String>) inputList; // unsafe cast }




    • Undefined warnings have no effect, e.g. @SuppressWarnings(“blahblah”). The compiler will ignore that silently.
    • When a program’s element is annotated by the @SuppressWarnings, all of its sub elements are also affected. For example, if you suppress a warning at class level, then all code inside that class is also applied.
    • It’s recommend to this annotation on the most deeply nested element wherever possible.


      Recommended Course: Complete Java Master Class

Why we dropped Eclipse in favour of IntelliJ

September 12, 2013 by Nikita Salnikov-Tarnovski Filed under: Java

As background – all of us in Plumbr have been using Eclipse for as long as we can possibly remember. But when I just looked around in the office I saw our whole team being converted to IntelliJ IDEA users. So what made us jump the old free-to-ride warhorse and go with something we need to pay up to $600 per seat for? If you bear with me I will give you several reasons why you might also consider the move.

For years, our friend Anton Arhipov has tried to convince us. He kept failing until he demoed something as simple asALT+ENTER. Based on the documentation it is not doing much – just using the suggested quick fix. But this feature is backed by something that makes many other IntelliJ features so much more pleasing to use.

Indexing. Whatever the JetBrains guys are doing under the hood, their indexing is blazingly fast and supports different content. These fast indexing benefits are paying off in several different usability features:

  • As-you-type code smells and warnings. In Eclipse you have to launch analysis manually, in IntelliJ you will have the feedback on those immediately.
  • Code completion and code generation support offered is orders of magnitude better due to the very same indexes.  I guess all of you remember the infamous java.awt.List autoimport on Lists which took years to be removed from “top recommendation”. No such annoyances when using IntelliJ.
  • The fixes offered by the ALT+ENTER make sense in so many occasions that it already starts to frighten me. In some cases I have suspected they have an Amazon Mechanical Turk watching me as I type – the recommendations are just so good.

Language support. They way IntelliJ is behaving on different content types just feels natural and uniform. Whether I am editing a Java, Javascript, HTML or a JPA query – the syntax support is really good and the operations I perform are uniform across languages. I do not need to learn a set of new shortcuts each time I switch away from Java. And the code completion support, especially in Javascript, is something I failed to see in Eclipse. It just wasn’t there.

Perspectives. Or actually the lack of perspectives. Eclipse tried to offer “the best perspective” for me while I was dealing with different issues at hand. For me it meant that my screen layout got mangled each time I switched from development to debugging or refactoring. It always annoyed me and now having just one extra context-dependent window for the additional operations I feel I have a solution I am actually enjoying

Out of context – we know. What if you would always know what you need to change in your code when it doesn’t perform in production? Try Plumbr – automatic root cause detection of Java performance issues.

Debugger. It is blazingly fast. And I will not even start on the Eclipse debugging perspective, which has to be someone’s evil joke driving me nuts every time I recall using it. And the feature set is also more pleasant, my favourite being the “Smart step into” which allows me to select which method to step into, if I have a code line with multiple method calls.

Support. Eclipse is built by a foundation. This is not bad per se, but the different interest groups in this foundation make the governing and execution somewhat difficult. For me as a developer it results in support tickets disappearing into a void for weeks. No such problems with IntelliJ where I always have my questions answered in time and without bouncing the topics between different areas of responsibility.

Several minor things I will only list some of the recent favourable discoveries:

  • JPA query syntax correctness is being checked as you type. Has already saved me a day or two by not having to discover the errors in runtime.
  • Property files integration. While in a property file, I can see where this property is being used in the source code and I can detect unused properties immediately.
  • Integration with different browsers. To test my HTML, I can launch different browsers right from the IDE itself, so I do not have to go the extra mile (ok, an inch) and open them by myself.
  • CSS colors are visible right from the IDE, so I do not even have to check the browser for this.

So I can only ensure that after your monthly trial will end there is no going back. But to be fully honest, there is one thing I do miss from Eclipse as well – “Save Actions”. If you haven’t used it, this is a possibility to create triggers being launched when you press CTRL+S. So for example I can have the imports organized, code formatted and @Override annotations added without any effort on my part. Haven’t found the IntelliJ equivalent for this one so far.

So, even though we cannot actually measure if we are more productive after the conversion, we are somewhat happier with the tools at hand. And we do believe that a good craftsman has to have the best possible tools in order to create the best possible craft.

If you enjoyed the content and wish to get updates on what the craftsmen are up to, subscribe to our Twitter feed.


Categories: 1

0 Replies to “Unchecked Assignment Intellij Vs Eclipse”

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *