RSS feed [root] /weblog /fundamental /java




login:

password:

title search:




 


Fri Dec 30 19:39:55 AEDT 2011

fundamental



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

Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

Array


You can ignore the last comma in arrays - http://hanuska.blogspot.com/2007/02/trailing-comma-in-arrays.html

When you try to case an Array to other Type, you will get funny exception like
Exception in thread "main" java.lang.ClassCastException: [B

Which, showing that if you call new byte[0].getClass() , you will get "[B".

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

Assemble


The tool that allow you write JVM instruction using assemble like command

http://jasclipse.sourceforge.net/

An article about assemble Java - http://www.theserverside.com[..]s/content/GuideJavaBytecode/article.html

Overview of bytecode - http://arhipov.blogspot.com[..]/2011/01/java-bytecode-fundamentals.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

Initialization


In short, only call private methods from a constructor.

http://penberg.blogspot.com[..]005/05/calling-abstract-method-from.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

Integer


Interesting aspect of Integer.valueOf()

http://tech.puredanger.com/2007/02/01/valueof/

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

Number



double aDouble = 12345678912345678912345.0;
BigDecimal dd = new BigDecimal(aDouble);
System.out.println(dd); // print: 12345678912345679593472

String aString = "12345678912345678912345.0";
BigDecimal bd = new BigDecimal(aString);
System.out.println(bd); // print: 12345678912345678912345.0

Java Hangs When Converting 2.2250738585072012e-308 - http://www.exploringbinary.com[..]when-converting-2-2250738585072012e-308/ http://bugs.openjdk.java.net/show_bug.cgi?id=100119

Compare performance between double and float - http://www.heatonresearch.com[..]-between-java%E2%80%99s-float-and-double

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

bean


A blog that cover some basic concept of javabean - http://weblogs.java.net[..]air/archive/2007/01/properties_in_j.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

classloader


Add custom classloaders to compilation classpath: "javac -J-Djava.system.class.loader=my.custom.ClassLoaderImpl theSource.java"

http://forums.java.net[..]read.jspa?messageID=87728&tstart=0#87728

Possible NULL from static fields... which is documented behaviours - http://qaix.com[..]2-puzzling-class-field-hellip-read.shtml

Comparing Class.getResourceAsStream() and bundle.getEntry(), point out some issues of using Class.getResourceAsStream() - http://www.eclipsezone.com/eclipse/forums/t101557.rhtml

Basic of classloader - http://www.journaldev.com[..]rstanding-and-extending-java-classloader http://java.sun.com[..]chnicalArticles/Networking/classloaders/

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

classpath


Two nice basic tutorial about classpath - http://www-128.ibm.com[..]rary/j-classpath-unix/index.html?ca=drs- http://www-128.ibm.com[..]y/j-classpath-windows/index.html?ca=drs-

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

clone


Some problems of cloning, include using copy constructor / clone() method - http://www.agiledeveloper.com/articles/cloning072002.htm

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

collections


Detailed decision of arraylist and linkedlist, consist of a lot benchmark results, take a look if interested: http://javachaos.crazyredpanda.com/?p=99

One bug from java HashMap explaining it can be difficult to achieve fail-fast - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6625725 http://java.dzone.com/articles/do-your-iterators-always-fail

Performance difference of difference collection - http://java-persistence-performance.blogspot.com[..]0/12/what-is-faster-jvm-performance.html http://leolewis.website.org[..]/2011/07/14/java-collection-performance/

A treelist implementation - http://binkley.blogspot.com/2007_02_01_archive.html

Implement LRU cache using LinkedHashMap - http://vanillajava.blogspot.com[..]11/06/java-secret-lru-cache-in-java.html

Problem of using soft-reference for automate cache clean up - http://comments.gmane.org[..]gmane.comp.java.jsr.166-concurrency/7982

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

date


One fact of System.nanoTime() ,
I think System.nanoTime()'s contract right now is that it *always*
increases by a fixed amount. In other words, it's monotonic. So NTP
updates, or user's changing system time can never cause any change to
System.nanoTime().

https://jsr-310.dev.java.net/servlets/ReadMsg?list=dev&msgNo=1282

A more detailed explanation of nanoTime() and currentMilliSecond() - http://blogs.sun.com/dholmes/entry/inside_the_hotspot_vm_clocks

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

enum


An article show how java treat enum internally - http://www.javaspecialists.eu/archive/Issue141.html

Look like it is "replace switch with polymorphism - http://javaforyou.wordpress.com[..]working-with-java-enumerated-types-enums

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

equals


Mutable cause issue - http://www.artima.com/lejava/articles/equality.html

Very detail discussion about implementing equals - http://www.angelikalanger.com[..]avaSolutions/SecretsOfEquals/Equals.html http://www.angelikalanger.com[..]aSolutions/SecretsOfEquals/Equals-2.html

Example of implement and TEST equals - http://blog.springfuse.com[..]ng-various-equals-and-hashcode_3597.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

fields


http://mindprod.com/jgloss/transient.html
http://mindprod.com/jgloss/volatile.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

finalization


http://java.sun.com[..]r/technicalArticles/javase/finalization/

Pitfall and solution of implementing finalize(), if you really need it http://www.hpl.hp.com[..]ns_Boehm/misc_slides/java_finalizers.pdf

Optimization-robust finalization - http://www.open-std.org[..]C1/SC22/WG21/docs/papers/2007/n2261.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

garbage


Some overview articles - http://javarevisited.blogspot.com[..]/2011/04/garbage-collection-in-java.html http://jeremymanson.blogspot.com[..]10/01/garbage-collection-references.html http://www.oracle.com[..]work/java/javase/gc-tuning-6-140523.html

Interview with Azul, about the pauseless GC - http://www.infoq.com/interviews/gil-tene-azul-zing

A story of how to tune GC - http://kirk.blog-city.com/why_do_i_have_this_long_gc_pause.htm

NewRatio ( XX:MaxNewSize ) is important, but usually ignored - http://blogs.oracle.com[..]ector/entry/the_second_most_important_gc

Java memory configuration and monitoring - http://blog.codecentric.de[..]ry-configuration-and-monitoring-3rd-act/

How Garbage Collection differs in the three big JVMs - http://blog.dynatrace.com[..]ollection-differs-in-the-three-big-jvms/

Garbage Collection Bootcamp 1.0 - http://www.lucidimagination.com[..]1/03/27/garbage-collection-bootcamp-1-0/

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

i18n


A very good tutorial of how to config and develop i18n web application
http://www.javaworld.com/javaworld/jw-05-2004/jw-0524-i18n_p.html

and a shorter one
http://www.arachna.com[..]/spidaman/20050215#a_java_i18n_checklist

and a tip
http://java.oreilly.com/lpt/a/1847

An introduction of a useful API for localized currency handling DecimalFormatSymbols
http://blog.marcnuri.com[..]mbols-DecimalFormat-DecimalFormatSymbols

Benchmark of various charset detector - http://fredeaker.blogspot.com[..]007/01/character-encoding-detection.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

java.io.File


createTempFile() will not delete after JDK quit... which I also suppose it will

List of issue about File api, which I totally agree. http://hoskinator.blogspot.com/2006/06/using-file-class.html

delete() will delete the file immediately even using some 3rd undelete utility cannot recover , I think the implementation should allow recovery chance - http://www.ryanlowe.ca[..]es/000574_java_delete_to_recycle_bin.php

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

java.lang.ref


Overview of weak, soft and Phantom References
Second, PhantomReferences avoid a fundamental problem with finalization: finalize() methods can "resurrect" objects by creating new strong references to them. So what, you say? Well, the problem is that an object which overrides finalize() must now be determined to be garbage in at least two separate garbage collection cycles in order to be collected. When the first cycle determines that it is garbage, it becomes eligible for finalization. Because of the (slim, but unfortunately real) possibility that the object was "resurrected" during finalization, the garbage collector has to run again before the object can actually be removed. And because finalization might not have happened in a timely fashion, an arbitrary number of garbage collection cycles might have happened while the object was waiting for finalization. This can mean serious delays in actually cleaning up garbage objects, and is why you can get OutOfMemoryErrors even when most of the heap is garbage.

With PhantomReference, this situation is impossible -- when a PhantomReference is enqueued, there is absolutely no way to get a pointer to the now-dead object (which is good, because it isn't in memory any longer). Because PhantomReference cannot be used to resurrect an object, the object can be instantly cleaned up during the first garbage collection cycle in which it is found to be phantomly reachable. You can then dispose whatever resources you need to at your convenience.

Arguably, the finalize() method should never have been provided in the first place. PhantomReferences are definitely safer and more efficient to use, and eliminating finalize() would have made parts of the VM considerably simpler. But, they're also more work to implement, so I confess to still using finalize() most of the time. The good news is that at least you have a choice.

http://weblogs.java.net[..]las/archive/2006/05/understanding_w.html

The other valuable reference about object life cycle - http://java.sun.com[..]ormance/1st_edition/html/JPAppGC.fm.html

Incorrect use of reference can cause GC issue - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4405807

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

serialization


Here is a mailing list message that tell why we need to serialize logger, sometime there are more need to have for sometime, but we need to do it very careful: http://mail-archives.apache.org[..]06691254D6185151@sheex267.he.conet.de%3E

A link that discuss various aspect of binary or xml (i.e. plain text) serialization, worth to keep as reference
http://www-03.ibm.com[..]f?entry=java_serialization_binary_or_xml

Basic question about serialization - http://www.opensubscriber.com[..]ed-java@discuss.develop.com/1641413.html , a long article explaining that http://www.eaze.org/patrick/java/objectserialization.jsp

Why we have to put serialziation id in serializable class... - https://issues.apache.org/jira/browse/DBUTILS-36

Show cast of test if all object in session can be serialized - http://www.theserverside.com/news/thread.tss?thread_id=38398

Interview questions - http://javarevisited.blogspot.com[..]top-10-java-serialization-interview.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

static


Loading and unloading static fields, unlocd the class - http://www.javacodegeeks.com[..]0/java-secret-loading-and-unloading.html

(google search) (amazon search)


Fri Dec 30 19:39:55 AEDT 2011 From /weblog/java/fundamental

time


Java timezone ID reference - http://david.uebelacker.ch[..]etrive-locale-and-timezone-from-request/ http://tutorials.jenkov.com[..]m/java-date-time/java-util-timezone.html

(google search) (amazon search)