Wed May 04 00:08:30 AEST 2022
From
/weblog/java/hacks
Hint to prevent blocking of loadClass by using Thread.getContextClassLoader() -
https://blog.fastthread.io[..]3/java-class-loading-performance-impact/
(google search)
(amazon search)
Sun Oct 30 05:36:47 AEDT 2011
From
/weblog/java/hacks
"hi there".equals("cheers !") == true
This is because in the JDK 1.3 SUN is caching the hash code so if it once is calculated, it doesn't get recalculated, so if the value field changes, the hashcode stays the same.
http://www.artima.com/forums/flat.jsp?forum=106&thread=4864 How to Modifying an Application without Modifying Its Source Code, with {-Xbootclasspath/p:} -
http://www.ddj.com[..]M4OQSNDLPCKH0CJUNN2JVN?_requestid=186396 Override string! -
http://www.javacodegeeks.com/2011/10/weird-funny-java.html
(google search)
(amazon search)
Mon Jul 27 03:08:14 AEST 2009
From
/weblog/java/hacks
How to get line number of specific stacktrace
private static void log(String prefix,
String message) {
StackTraceElement ste =
new Exception().getStackTrace()[2];
System.out.println("[" + prefix + "] " +
ste.getClassName() + "." +
ste.getMethodName() + "(" +
ste.getLineNumber() + "): " +
message);
}
http://jroller.com[..]0602#abusing_java_for_debugging_purposes Annotation of using stacktrace -
http://www.theserverside.com[..]m/news/thread.tss?thread_id=55238#312195
(google search)
(amazon search)
Tue Mar 18 04:25:28 AEDT 2008
From
/weblog/java/hacks
if you do a “kill -3? of the java process id, it dumps a stack trace of every thread, including what locks it’s holding, to stdout. -
http://blog.xcski.com[..]ie-says-kill-3-pid-is-my-new-best-friend At windows, it is ctrl-break
(google search)
(amazon search)
Fri Dec 01 02:22:16 AEDT 2006
From
/weblog/java/hacks
optimizing java class for j2me, look like just break all OO principle...
http://blog.javia.org/?p=31
(google search)
(amazon search)
Sat Nov 11 21:03:05 AEDT 2006
From
/weblog/java/hacks
bitwise operation on boolean
The solution to the puzzle is given in the Java Language Specification, chapter 15.22.2:
15.22.2 Boolean Logical Operators &, ^, and |
When both operands of a &, ^, or | operator are of type boolean, then the type of the bitwise operator expression is boolean.
For &, the result value is true if both operand values are true; otherwise, the result is false.
For ^, the result value is true if the operand values are different; otherwise, the result is false.
For |, the result value is false if both operand values are false; otherwise, the result is true.
http://beust.com/weblog/archives/000350.html Someone mentioned that there is no boolean, byte and short in byte code level, all just integer
http://oddjava.com/?q=node/8
(google search)
(amazon search)
Tue Nov 07 16:11:24 AEDT 2006
From
/weblog/java/hacks
Prevent System.exit() being call -
http://jroller.com/page/ethdsy?entry=disabling_system_exit Usually security manager forbid it
(google search)
(amazon search)
Wed Jul 12 18:09:26 AEST 2006
From
/weblog/java/hacks
No sure if that still valid, but look like encrypt class file don't help on protecting class.
http://www.javaworld.com[..]ld/javaqa/2003-05/01-qa-0509-jcrypt.html
(google search)
(amazon search)
Mon Jun 26 16:32:59 AEST 2006
From
/weblog/java/hacks
New look of resultset, WebRowSet,
http://www.onjava.com/lpt/a/6633 , but I personally don't think this is something useful
Some information how using jmxagent:
http://weblogs.java.net[..]nus/archive/2006/06/going_beyond_jd.html Just come across a nice article that discuss about various new features of 1.5 and provide tips on how to use them:
http://java.sys-con.com/read/171487_p.htm Create collection quick
List
programmingLanguages = CollectionUtils.newList("Java", "C++", "Ruby");
Or this:
Map langs = new HashMap(3) {{
put("Java", "Wicked");
put("C++", "Ok");
put("Ruby", "Interesting");
}};
http://www.theserverside.com/blogs/thread.tss?thread_id=37839
(google search)
(amazon search)
Tue May 16 17:30:58 AEST 2006
From
/weblog/java/hacks
At least need to test on the interface level. And more complicate if you don't want to expose the internal structure to interface
http://www.javaspecialists.co.za/archive/newsletter.do?issue=126
(google search)
(amazon search)
Fri Apr 07 15:13:55 AEST 2006
From
/weblog/java/hacks
I don't know this before, and I don't know if this is the behaviour of all Calendar implementation or it is only GregorianCalendar do this...
Every time you call set, Calendar sets a flag internally which indicates that something has changed. For performance reasons, the time is not actually computed until a call to getTime() (and variants).
The problem is that you are setting two conflicting states before computing the time:
thisMonth.set(Calendar.DAY_OF_MONTH, 1);
thisMonth.set(Calendar.DAY_OF_WEEK, 1);
According to the JavaDoc:
"If fields conflict, the calendar will give preference to fields set more recently."
Thus, in the second case, the call to set DAY_OF_MONTH is ignored.
http://discuss.joelonsoftware.com/default.asp?joel.3.328034
(google search)
(amazon search)
Tue Jul 12 14:27:06 AEST 2005
From
/weblog/java/hacks
This is kind of useful to have a quick way to find file in classpath, see if some day really deploy to system I work on:
http://jroller.com/page/mlconnor/20050708#code_to_find_files_on
(google search)
(amazon search)