Possible heap pollution via varargs parameter

Heap pollution is a technical term. It refers to references which have a type that is not a supertype of the object they point to. List<A> listOfAs = new ArrayList<>(); List<B> listOfBs = (List<B>)(Object)listOfAs; // points to a list of As This can lead to “unexplainable” ClassCastExceptions. // if the heap never gets polluted, this … Read more

Seeking useful Eclipse Java code templates [closed]

The following code templates will both create a logger and create the right imports, if needed. SLF4J ${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)} private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class); Log4J 2 ${:import(org.apache.logging.log4j.LogManager,org.apache.logging.log4j.Logger)} private static final Logger LOG = LogManager.getLogger(${enclosing_type}.class); Log4J ${:import(org.apache.log4j.Logger)} private static final Logger LOG = Logger.getLogger(${enclosing_type}.class); Source. JUL ${:import(java.util.logging.Logger)} private static final Logger LOG = Logger.getLogger(${enclosing_type}.class.getName());

How to turn off the Eclipse code formatter for certain sections of Java code?

Eclipse 3.6 allows you to turn off formatting by placing a special comment, like // @formatter:off … // @formatter:on The on/off features have to be turned “on” in Eclipse preferences: Java > Code Style > Formatter. Click on Edit, Off/On Tags, enable Enable Off/On tags. It’s also possible to change the magic strings in the … Read more

Is there a way to collapse all code blocks in Eclipse?

There is a hotkey, mapped by default to Ctrl+Shift+NUM_KEYPAD_DIVIDE. You can change it to something else via Window -> Preferences, search for “Keys”, then for “Collapse All”. To open all code blocks the shortcut is Ctrl+Shift+NUM_KEYPAD_MULTIPLY. In the Eclipse extension PyDev, close all code blocks is Ctrl + 9 To open all blocks, is Ctrl … Read more

Update Eclipse with Android development tools v. 23

Google has released ADT v23.0.2. This solved many problems of previous ADT version 23. Step-by-step: Menu Help → Install New Software… For “Work with”, select the Android source https://dl-ssl.google.com/android/eclipse Tick ADT v23.0 for installation, then click “Next” Eclipse will show “Install Remediation Page” since there is conflict with previous version. (If it does not, see … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)