RSS feed [root] /weblog /java



title search:


Wed Jun 23 23:53:07 AEST 2021


(google search) (amazon search)
download zip of files only

Wed Jul 23 11:57:03 AEST 2014 From /weblog/java/string


Better sorting should do 2 things:
1) case insensitive
2) aware of numbers in the file names. So File2 comes after File1 (obviously) but before File10[..]ingcomparator_sorting_strings_for_people


Switch comparison -

(google search) (amazon search)

Wed Jul 16 00:16:21 AEST 2014 From /weblog/java/annotation

A discussion of various use case of annotation

Some good, some bad and some ugly -[..]tPark?entry=annotations_the_good_the_bad[..]/01/aop-aspectj-java-method-logging.html

(google search) (amazon search)

Wed Jun 25 16:26:02 AEST 2014 From /weblog/java/libraries


Allow a Java method to work for a maximum of five seconds and want an exception to be thrown if the timeframe is exceeded. Here is how you can do it with jcabi-aspects and AspectJ -[..]4/06/20/limit-method-execution-time.html

(google search) (amazon search)

Mon Jun 16 19:21:07 AEST 2014 From /weblog/java/network


Some advance usage of javamail and apache james smtp server... but I guess not much ppl will use this server, right? -[..]ment_variable_envelope_return_paths.html

Code sample of using auth required SMTP server -

Properties to prevent infinite timeout for all socket operations, in Java mail -[..]vamail-can-be-evil-and-force-you-to.html

(google search) (amazon search)

Tue Apr 22 15:08:26 AEST 2014 From /weblog/java/fundamental


Nice instanceof replacement -[..]anceof-operator-and-visitor-pattern.html[..]01/java-data-types-conversion-chart.html

How to use reflection to get the size of Primitive -[..]rogrammatic-access-java-types-sizes.html

(google search) (amazon search)

Wed Apr 02 15:01:15 AEDT 2014 From /weblog/java/tools


How to use Eclipse Memory Analyzer -[..]s-for-using-the-eclipse-memory-analyzer/

Tool to check java memory layout, how the object placed in JVM -

(google search) (amazon search)

Wed Mar 26 14:10:08 AEDT 2014 From /weblog/java/concurrency


How weak and soft reference work[..]rence-phantom-strong-reference-java.html

Issue about weakhashmap -

When soft reference clean? -[..]/07/how-hotspot-decides-to-clear_07.html

(google search) (amazon search)

Mon Mar 17 13:27:52 AEDT 2014 From /weblog/java/features


List the pros of using native agent -[..]-for-application-performance-management/

(google search) (amazon search)

Mon Jan 06 19:30:32 AEDT 2014 From /weblog/java/features


As Java still need to support Collection.get(Object) , it is easy to get NPE if you use wrong type accidentally
I met this problem when using wicket, one cool feature of ListMultipleChoice is that if the list I press into the constructor is not List, it will persist the type information.
However, if you use this API carelessly and think the List return from the HTML form is always List . Then you will get strangle null pointer exception when you operate with the list instead of ClassCastException, as java will surpress the ClassCastException from ArrayList.get(i) sliencely and just return null to caller.

A related one but not really related to generics - , look like the behaviours difference of primittive and wrapper class at NULL is very easy to get hard to check bug

Another one, JDK generic try to cast to wrong class internally:

Some cool feature, apply generic in comparable -

Wildcast in generic -[..]-is-bounded-and-unbounded-wildcards.html[..]trized-class-method-Generic-example.html[..]6/advanced-java-generics-retreiving.html

(google search) (amazon search)

Mon Dec 23 21:09:08 AEDT 2013 From /weblog/java/concurrency


Demo how java 1.5 built-in thread pool work:[..]ry=swingworker_throttling_and_monitoring

Sample of thread pool -

Discussion about how to estimate threadpool size -

(google search) (amazon search)

Wed Dec 18 18:53:04 AEDT 2013 From /weblog/java/hacks


(google search) (amazon search)

Tue Dec 10 14:58:22 AEDT 2013 From /weblog/java/features


Java: Moving conditions into Message files -[..]the-java-classes-resourcebundle-and.html

(google search) (amazon search)

Thu Dec 05 16:16:04 AEDT 2013 From /weblog/java/hacks


Funny, using gcc preprocessor with java -

(google search) (amazon search)

Wed Dec 04 22:27:37 AEDT 2013 From /weblog/java/network


Guide of how to start and config jetty dynamic at code - , even change the config after the server started.

Websocket coding sample -[..]java-websockets-jsr-356-on-jetty-91.html

(google search) (amazon search)

Mon Dec 02 14:47:12 AEDT 2013 From /weblog/java/string


A common issue of Windows environment and the workaround -

Strange String issues in JVM languages, don't trust all string operations all the time![..]/posts/strangestringissuesinjvmlanguages

(google search) (amazon search)

Thu Nov 28 12:25:38 AEDT 2013 From /weblog/java/network


Sockets Direct Protocol – Write Once, Run Everywhere …. and Run (Some Places) Blazingly -

(google search) (amazon search)

Fri Nov 22 20:04:49 AEDT 2013 From /weblog/java/string


Discussion of how to do string alignment -[..]va-implementation-of-optimal-string.html

(google search) (amazon search)

Tue Nov 12 15:04:47 AEDT 2013 From /weblog/java/libraries


(google search) (amazon search)

Sun Nov 10 21:51:44 AEDT 2013 From /weblog/java/eclipse


Good decompiler -

fatjar -

Builder generator -

And my old stuff -

(google search) (amazon search)

Thu Nov 07 19:02:21 AEDT 2013 From /weblog/java/concurrency


There is a little bit performance cost for threadlocal variable -[..]ost-of-accessing-thread-local-variables/

Look like a useful but less known API -

Forward up discussion -[..]d_id=41473&asrc=EM_NNL_406677&uid=703565 pointing out some problems of using this technique, include similar effect of GLOBLE , possible memory leak

Another discussion in higher level -[..]04/thread-local-a-convenient-abomination , Key is "An object is an abstraction of function. A thread is an abstraction of schedule" , you can read further conclusion at

Protential issue of using threadlocal, one is memory leak and the other is it is that local -[..]hreading-stories-threadlocal-in-web.html[..]shoot-yourself-in-foot-with-threadlocals

The beauty of the design of threadlocal, how it prevent locking and memory leaking -

(google search) (amazon search)

Wed Oct 23 03:11:36 AEDT 2013 From /weblog/java/fundamental


Nice instanceof replacement -[..]anceof-operator-and-visitor-pattern.html

(google search) (amazon search)

Wed Oct 23 02:20:06 AEDT 2013 From /weblog/java/libraries


(google search) (amazon search)

Wed Oct 23 01:46:35 AEDT 2013 From /weblog/java/features


Type can be changed -

(google search) (amazon search)

Tue Oct 22 20:25:00 AEDT 2013 From /weblog/java/concurrency

Double-Checked Locking

Very detailed explanation:[..]va/memoryModel/DoubleCheckedLocking.html

Some more information, also demo in fact not much difference for most cast:[..]page/cwebster?entry=double_check_locking

Even more discussion -

In Chinese -[..]hecked-locking-with-delay-initialization

(google search) (amazon search)

Mon Sep 23 20:11:40 AEST 2013 From /weblog/java/concurrency


Series of blog showing how to use JMock API to help testing MT code -[..]shhtresohqc&ie=UTF-8&q=JMock+and+Threads

A test for deadlock -[..][..]t/java/util/logging/

Some technique, use of SynchronousExecutorService and Events -[..]ntent/5-tips-unit-testing-threaded-code/

(google search) (amazon search)