RSS feed [root] /fundamental /weblog /java




login:

password:

title search:




 


Tue Feb 07 23:18:45 HKT 2017

fundamental



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

Wed Mar 22 10:27:28 HKT 2017 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/

http://javarevisited.blogspot.sg[..]ollection-interview-question-answer.html

How CMS work - https://blogs.oracle.com[..]thecollector/entry/hey_joe_phases_of_cms

Compare between difference VM - http://www.optaplanner.org[..]IsTheFastestGarbageCollectorInJava8.html

GC handbook - https://plumbr.eu/java-garbage-collection-handbook

Check what GC you are using - http://marxsoftware.blogspot.hk[..]16/04/determining-garbage-collector.html

About G1 Java Garbage Collector - http://dobbscodetalk.com[..]G1-Java-Garbage-Collector.html&Itemid=29

Tools to visualize GC - http://gceasy.io/

Visualizing difference algorithm - https://spin.atomicobject.com[..]sualizing-garbage-collection-algorithms/

(google search) (amazon search)


Tue Feb 28 17:10:49 HKT 2017 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

one more related blog - http://www.egimaben.com[..]garbage-collector-and-reference-objects/

(google search) (amazon search)


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

time


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

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

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. - http://keyholesoftware.wordpress.com[..]1/joda-time-the-future-of-java-datetime/

http://blog.joda.org[..]va-time-jsr-310-enhancements-java-9.html

(google search) (amazon search)


Thu Dec 22 15:47:37 HKT 2016 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

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. - http://codingjunkie.net/guava-bloomfilter/

Comment of various collections library - http://plumbr.eu/blog/selecting-your-collections-library

List of FAQ of Java collections - http://www.journaldev.com[..]lections-interview-questions-and-answers

Java Collections – Performance (Time Complexity) - http://infotechgems.blogspot.com.br[..]1/java-collections-performance-time.html

Performance improvement for HashMap for Java8 - http://www.nurkiewicz.com[..]hashmap-performance-improvements-in.html

Introduction to GS collection - http://www.infoq.com[..]s/gs-collections-examples-tutorial-part1 http://www.infoq.com[..]s/gs-collections-examples-tutorial-part2

removeEldestEntry, interesting function of linkedhashmap - http://www.ageofjava.com[..]/prevent-your-caches-from-exploding.html

(google search) (amazon search)


Thu Feb 05 11:16:50 HKT 2015 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

How to work correctly with double - http://vanillajava.blogspot.com.au[..]au/2014/07/compounding-double-error.html

Check the border cases - http://vanillajava.blogspot.com.au[..]consistent-operation-widen-rules-in.html http://vanillajava.blogspot.com.au[..]ava-conversion-puzzler-not-suitable.html

(google search) (amazon search)


Sun Dec 14 09:38:06 HKT 2014 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

http://blog.pengyifan.com/java-io-in-nutshell-22-case-studies/

(google search) (amazon search)


Sun Dec 14 09:37:13 HKT 2014 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

http://blog.joda.org[..]nverting-from-joda-time-to-javatime.html

(google search) (amazon search)


Wed May 14 15:17:27 HKT 2014 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

An example showing that memory leak caused by finalize() - http://vanillajava.blogspot.com.au[..].com.au/2012/12/object-resurrection.html


Beware the Finalizer queue, and java.lang.ref.Finalizer object - https://plumbr.eu/blog/debugging-to-understand-finalizer

(google search) (amazon search)


Tue Apr 22 13:08:26 HKT 2014 From /weblog/java/fundamental

type


Nice instanceof replacement - http://nurkiewicz.blogspot.com.au[..]anceof-operator-and-visitor-pattern.html https://github.com/nurkiewicz/typeof

http://interviewquestionjava.blogspot.hk[..]01/java-data-types-conversion-chart.html

How to use reflection to get the size of Primitive - http://marxsoftware.blogspot.com.au[..]rogrammatic-access-java-types-sizes.html

(google search) (amazon search)


Tue Dec 10 12:06:03 HKT 2013 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 http://www.javaadvent.com/2013/12/mastering-java-bytecode.html

(google search) (amazon search)


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

instanceof


Nice instanceof replacement - http://nurkiewicz.blogspot.com.au[..]anceof-operator-and-visitor-pattern.html https://github.com/nurkiewicz/typeof

(google search) (amazon search)


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

memory


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

Algorithm of determine suitable thread pool size - http://www.javacodegeeks.com[..]reading-stories-about-robust-thread.html

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

Chinese introduction of memory model - http://www.infoq.com/cn/articles/java-memory-model-1

Difference between PermGem and MetaSpace - http://javaeesupportpatterns.blogspot.com.au[..]02/java-8-from-permgen-to-metaspace.html

(google search) (amazon search)


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

process


Execute and manage an external process from within Java - http://developer4life.blogspot.com.au[..]cuting-command-line-executable-from.html

(google search) (amazon search)


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

string


Substring no longer just change offset - http://www.javaadvent.com[..]hanges-to-stringsubstring-in-java-7.html

(google search) (amazon search)


Mon Nov 19 23:17:47 HKT 2012 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

Consistent of equals and compareTo - http://blog.joda.org[..]/pitfalls-of-consistent-with-equals.html

(google search) (amazon search)


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

threaddump


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

(google search) (amazon search)


Sun Oct 30 02:36:23 HKT 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)


Sun May 15 02:01:11 HKT 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)


Sun Apr 24 01:44:47 HKT 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)


Thu Dec 03 15:23:22 HKT 2009 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)


Tue Mar 04 01:30:36 HKT 2008 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)


Mon Jan 07 15:03:59 HKT 2008 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)


Tue Sep 11 00:20:10 HKT 2007 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 Jun 22 18:10:12 HKT 2007 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)


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

Integer


Interesting aspect of Integer.valueOf()

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

(google search) (amazon search)