RSS feed [root] /fundamental /weblog /java



title search:


Tue Feb 07 23:18:45 HKT 2017


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

Wed Mar 22 10:27:28 HKT 2017 From /weblog/java/fundamental


Some overview articles -[..]/2011/04/garbage-collection-in-java.html[..]10/01/garbage-collection-references.html[..]work/java/javase/gc-tuning-6-140523.html

Interview with Azul, about the pauseless GC -

A story of how to tune GC -

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

Java memory configuration and monitoring -[..]ry-configuration-and-monitoring-3rd-act/

How Garbage Collection differs in the three big JVMs -[..]ollection-differs-in-the-three-big-jvms/

Garbage Collection Bootcamp 1.0 -[..]1/03/27/garbage-collection-bootcamp-1-0/[..]ollection-interview-question-answer.html

How CMS work -[..]thecollector/entry/hey_joe_phases_of_cms

Compare between difference VM -[..]IsTheFastestGarbageCollectorInJava8.html

GC handbook -

Check what GC you are using -[..]16/04/determining-garbage-collector.html

About G1 Java Garbage Collector -[..]G1-Java-Garbage-Collector.html&Itemid=29

Tools to visualize GC -

Visualizing difference algorithm -[..]sualizing-garbage-collection-algorithms/

(google search) (amazon search)

Tue Feb 28 17:10:49 HKT 2017 From /weblog/java/fundamental


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.[..]las/archive/2006/05/understanding_w.html

The other valuable reference about object life cycle -[..]ormance/1st_edition/html/

Incorrect use of reference can cause GC issue -

one more related blog -[..]garbage-collector-and-reference-objects/

(google search) (amazon search)

Tue Feb 07 23:18:45 HKT 2017 From /weblog/java/fundamental


How difference platform implement nanoTime() -[..]12/02/what-is-behind-systemnanotime.html[..]62/is-system-nanotime-completely-useless

Java timezone ID reference -[..]etrive-locale-and-timezone-from-request/[..]m/java-date-time/java-util-timezone.html

setTimeZone affects calls to set(), but doesn’t change the existing Calendar time? So if we wanted to change the time zone we are working with, we have to adjust all the time fields too…but a SimpleDateFormatter still would show it as the current time zone. -[..]1/joda-time-the-future-of-java-datetime/[..]va-time-jsr-310-enhancements-java-9.html

(google search) (amazon search)

Thu Dec 22 15:47:37 HKT 2016 From /weblog/java/fundamental


Detailed decision of arraylist and linkedlist, consist of a lot benchmark results, take a look if interested:

One bug from java HashMap explaining it can be difficult to achieve fail-fast -

Performance difference of difference collection -[..]0/12/what-is-faster-jvm-performance.html[..]/2011/07/14/java-collection-performance/

A treelist implementation -

Implement LRU cache using LinkedHashMap -[..]11/06/java-secret-lru-cache-in-java.html

Problem of using soft-reference for automate cache clean up -[..]

if it claims that an element is contained in it, this might be in error, but if it claims that an element is not contained in it, then this is definitely true. -

Comment of various collections library -

List of FAQ of Java collections -[..]lections-interview-questions-and-answers

Java Collections – Performance (Time Complexity) -[..]1/java-collections-performance-time.html

Performance improvement for HashMap for Java8 -[..]hashmap-performance-improvements-in.html

Introduction to GS collection -[..]s/gs-collections-examples-tutorial-part1[..]s/gs-collections-examples-tutorial-part2

removeEldestEntry, interesting function of linkedhashmap -[..]/prevent-your-caches-from-exploding.html

(google search) (amazon search)

Thu Feb 05 11:16:50 HKT 2015 From /weblog/java/fundamental


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 -[..]when-converting-2-2250738585072012e-308/

Compare performance between double and float -[..]-between-java%E2%80%99s-float-and-double

How to work correctly with double -[..]au/2014/07/compounding-double-error.html

Check the border cases -[..]consistent-operation-widen-rules-in.html[..]ava-conversion-puzzler-not-suitable.html

(google search) (amazon search)

Sun Dec 14 09:38:06 HKT 2014 From /weblog/java/fundamental

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

List of issue about File api, which I totally agree.

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

(google search) (amazon search)

Sun Dec 14 09:37:13 HKT 2014 From /weblog/java/fundamental


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

A more detailed explanation of nanoTime() and currentMilliSecond() -[..]nverting-from-joda-time-to-javatime.html

(google search) (amazon search)

Wed May 14 15:17:27 HKT 2014 From /weblog/java/fundamental


Pitfall and solution of implementing finalize(), if you really need it[..]ns_Boehm/misc_slides/java_finalizers.pdf

Optimization-robust finalization -[..]C1/SC22/WG21/docs/papers/2007/n2261.html

An example showing that memory leak caused by finalize() -[..]

Beware the Finalizer queue, and java.lang.ref.Finalizer object -

(google search) (amazon search)

Tue Apr 22 13:08:26 HKT 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)

Tue Dec 10 12:06:03 HKT 2013 From /weblog/java/fundamental


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

An article about assemble Java -[..]s/content/GuideJavaBytecode/article.html

Overview of bytecode -[..]/2011/01/java-bytecode-fundamentals.html

(google search) (amazon search)

Wed Oct 23 00:11:36 HKT 2013 From /weblog/java/fundamental


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

(google search) (amazon search)

Wed Feb 06 08:01:16 HKT 2013 From /weblog/java/fundamental


From java code to java heap, detail of how java use memory -[..]rks/java/library/j-codetoheap/index.html

Algorithm of determine suitable thread pool size -[..]reading-stories-about-robust-thread.html

Detail of how to analysis how much memory you need -[..]m/2012/12/how-much-memory-do-i-need.html

Chinese introduction of memory model -

Difference between PermGem and MetaSpace -[..]02/java-8-from-permgen-to-metaspace.html

(google search) (amazon search)

Mon Jan 21 07:56:32 HKT 2013 From /weblog/java/fundamental


Execute and manage an external process from within Java -[..]cuting-command-line-executable-from.html

(google search) (amazon search)

Sun Jan 20 01:58:05 HKT 2013 From /weblog/java/fundamental


Substring no longer just change offset -[..]hanges-to-stringsubstring-in-java-7.html

(google search) (amazon search)

Mon Nov 19 23:17:47 HKT 2012 From /weblog/java/fundamental


Mutable cause issue -

Very detail discussion about implementing equals -[..]avaSolutions/SecretsOfEquals/Equals.html[..]aSolutions/SecretsOfEquals/Equals-2.html

Example of implement and TEST equals -[..]ng-various-equals-and-hashcode_3597.html

Consistent of equals and compareTo -[..]/pitfalls-of-consistent-with-equals.html

(google search) (amazon search)

Thu Mar 01 22:38:45 HKT 2012 From /weblog/java/fundamental


The process of how to solve problem using thread dump is nice -[..]atform/how-to-analyze-java-thread-dumps/

(google search) (amazon search)

Sun Oct 30 02:36:23 HKT 2011 From /weblog/java/fundamental


Loading and unloading static fields, unlocd the class -[..]0/java-secret-loading-and-unloading.html

(google search) (amazon search)

Sun May 15 02:01:11 HKT 2011 From /weblog/java/fundamental


Add custom classloaders to compilation classpath: "javac -J-Djava.system.class.loader=my.custom.ClassLoaderImpl"[..]read.jspa?messageID=87728&tstart=0#87728

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

Comparing Class.getResourceAsStream() and bundle.getEntry(), point out some issues of using Class.getResourceAsStream() -

Basic of classloader -[..]rstanding-and-extending-java-classloader[..]chnicalArticles/Networking/classloaders/

(google search) (amazon search)

Sun Apr 24 01:44:47 HKT 2011 From /weblog/java/fundamental


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:[..]

A link that discuss various aspect of binary or xml (i.e. plain text) serialization, worth to keep as reference[..]f?entry=java_serialization_binary_or_xml

Basic question about serialization -[..] , a long article explaining that

Why we have to put serialziation id in serializable class... -

Show cast of test if all object in session can be serialized -

Interview questions -[..]top-10-java-serialization-interview.html

(google search) (amazon search)

Thu Dec 03 15:23:22 HKT 2009 From /weblog/java/fundamental


An article show how java treat enum internally -

Look like it is "replace switch with polymorphism -[..]working-with-java-enumerated-types-enums

(google search) (amazon search)

Tue Mar 04 01:30:36 HKT 2008 From /weblog/java/fundamental


A very good tutorial of how to config and develop i18n web application

and a shorter one[..]/spidaman/20050215#a_java_i18n_checklist

and a tip

An introduction of a useful API for localized currency handling DecimalFormatSymbols[..]mbols-DecimalFormat-DecimalFormatSymbols

Benchmark of various charset detector -[..]007/01/character-encoding-detection.html

(google search) (amazon search)

Mon Jan 07 15:03:59 HKT 2008 From /weblog/java/fundamental


Some problems of cloning, include using copy constructor / clone() method -

(google search) (amazon search)

Tue Sep 11 00:20:10 HKT 2007 From /weblog/java/fundamental


Two nice basic tutorial about classpath -[..]rary/j-classpath-unix/index.html?ca=drs-[..]y/j-classpath-windows/index.html?ca=drs-

(google search) (amazon search)

Fri Jun 22 18:10:12 HKT 2007 From /weblog/java/fundamental


You can ignore the last comma in arrays -

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)

Tue Feb 06 17:28:38 HKT 2007 From /weblog/java/fundamental


Interesting aspect of Integer.valueOf()

(google search) (amazon search)