RSS feed [root] /weblog /java




login:

password:

title search:




 


Sun Dec 14 09:36:42 HKT 2014

java



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

Thu Oct 11 22:28:42 HKT 2018 From /weblog/java/features

java11


https://itnext.io/java-is-still-free-c02aef8c9e04

(google search) (amazon search)


Wed Aug 15 23:55:24 HKT 2018 From /weblog/java/fundamental

hashcode


We can control how the default hashcode return, and and what the difference of default hashcode between java7 and 8 - https://blog.codinghorror.com/complaint-driven-development/

http://sigpwned.com/2018/08/10/string-hashcode-is-plenty-unique/

(google search) (amazon search)


Fri Jul 13 23:54:42 HKT 2018 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

Maybe handy api, Math.toIntExact(Long) - http://marxsoftware.blogspot.com[..]t-conversion-of-long-to-int-in-java.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)


Wed Jul 11 23:07:18 HKT 2018 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

How new version of java help immutable style - https://dzone.com/articles/java-collections-are-evolving

(google search) (amazon search)


Mon Feb 26 23:45:40 HKT 2018 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

http://fahdshariff.blogspot.hk[..]/java-9-enhancements-to-process-api.html

(google search) (amazon search)


Thu Jan 25 23:51:57 HKT 2018 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)


Fri Jan 12 10:21:11 HKT 2018 From /weblog/java/features

reflection


Good : dynamic, generic
Bad: slow, don't work with Obfuscators and most searching and refactoring tools

http://jroller.com/page/ie?entry=time_to_reconsider_reflection

A very nice tool to get parameter name - http://paranamer.codehaus.org/ (e.g.: user of getUser(User user))

How to improve the performance - http://coding-masters.blogspot.com[..]-reflection-as-fast-as-direct-calls.html

The problem of using reflection to modify final field - http://www.azulsystems.com[..]7-writing-to-final-fields-via-reflection

Using reflection for using test - http://www.javaadvent.com[..]f-hacking-enums-and-modifying-final.html

Sharing about using invokedynamic - http://www.infoq.com/presentations/invokedynamic http://www.infoq.com[..]ticles/Invokedynamic-Javas-secret-weapon https://www.infoq.com/articles/Invokedynamic-Javas-secret-weapon

LamdbaMetafactory is pretty fast. (*) - https://www.optaplanner.org[..]8/01/09/JavaReflectionButMuchFaster.html

(google search) (amazon search)


Fri Dec 29 17:51:28 HKT 2017 From /weblog/java/tools

messaging


Compare between pulsar and Kafka - http://furkankamaci.com[..]ar-distributed-pub-sub-messaging-system/

(google search) (amazon search)


Sat Nov 18 16:29:46 HKT 2017 From /weblog/java/performance

memory


Will you get any performance improvement if you manage memory yourself? - http://mentablog.soliveirajr.com[..]ne-is-faster-java-heap-or-native-memory/

More heap, GC will get slower - http://plumbr.eu[..]ing-heap-size-beware-of-the-cobra-effect

Collection of tools to analysis GC activities - http://www.fasterj.com/tools/gcloganalysers.shtml

Another presentation of performance hint for hotspot or memory - http://www.infoq.com/presentations/Extreme-Performance-Java

Show how to enable and analyze the verbose:gc out data - http://javaeesupportpatterns.blogspot.com.au[..]3/01/java-verbose-gc-tutorial-video.html

Discussion and comparison of difference GC at Java 1.7 - http://mechanical-sympathy.blogspot.com.au[..]7/java-garbage-collection-distilled.html . And here is the detail experiment among those difference GC, look like G1 is quite promising - http://java-is-the-new-c.blogspot.com.au[..]ng-and-benchmarking-java-7s-garbage.html

Memory is not allocate to single block, thus even you allocate enough memory in term of size, it may not enough to held individual object - https://plumbr.eu/blog/outofmemoryerror-on-overprovisioned-heap

Introduction to metaspace - http://www.infoq.com/articles/Java-PERMGEN-Removed

http://vanillajava.blogspot.com.au[..]optimising-memory-consumption-first.html

Some comments about System.gc() - http://jeremymanson.blogspot.com[..]om/2015/12/why-i-dont-like-systemgc.html

http://blog.takipi.com[..]ng-your-java-garbage-collection-overhead

Logging stop-the-world pauses in JVM - https://plumbr.eu[..]log/logging-stop-the-world-pauses-in-jvm

Why we should put difference app in same VM - http://mydailyjava.blogspot.hk[..]0/generational-disparity-in-garbage.html

Atlassian GC tuning guide - https://confluence.atlassian.com[..]ollection-gc-tuning-guide-461504616.html

Using jemalloc to get to the bottom of a memory leak - https://gdstechnology.blog.gov.uk[..]c-to-get-to-the-bottom-of-a-memory-leak/

Troubleshooting-Java-Memory-Issues - https://www.infoq.com/articles/Troubleshooting-Java-Memory-Issues

Shenandoah Garbage Collector look good - https://www.javacodegeeks.com[..]emory-usage-right-garbage-collector.html

(google search) (amazon search)


Tue Nov 07 16:01:37 HKT 2017 From /weblog/java/performance

cases


A case showing java is faster than C++ - https://groups.google.com[..]mgroups#!topic/comp.lang.c++/7aNw3PzPvMI

Case show how to improve GC time spend on a java application - http://javaeesupportpatterns.blogspot.com.au[..]11/java-vm-beware-of-younggen-space.html

A case study of solving thread contention - http://blogs.mulesoft.org[..]fighting-thread-contention-in-your-code/

http://www.cubrid.org[..]-of-java-application-performance-tuning/

Notes about measuring map performance - http://vanillajava.blogspot.com.au[..]ronicle-map-and-yahoo-cloud-service.html

High Performance Java - Binary instead of Objects - John Davies - https://vimeo.com/138956045 http://www.infoq.com/presentations/java-low-latency

jemalloc, look like a really nice tool - https://gdstechnology.blog.gov.uk[..]c-to-get-to-the-bottom-of-a-memory-leak/

story of finding why there is so many GC - http://www.infoq.com[..]horough-jvm-thorough-analysis-ygc-part01

GC thread blocked by system call - http://www.infoq.com/cn/articles/GC-Log-Uncovers-Pause https://www.infoq.com/articles/GC-Log-Uncovers-Pause

We always need benchmark - https://arnaudroger.github.io[..]2017/06/15/forward-vs-backward-loop.html

Investigation and solutions of performance issue caused by GC log - https://engineering.linkedin.com[..]c-pauses-caused-by-background-io-traffic

(google search) (amazon search)


Tue Oct 31 10:18:25 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

fews more related blog - http://www.egimaben.com[..]garbage-collector-and-reference-objects/ https://medium.com[..]in-java-and-why-they-matter-c04bfc9dc792

(google search) (amazon search)


Thu Sep 28 16:21:47 HKT 2017 From /weblog/java/concurrency

Contended


preventing false sharing with the @Contended annotation - https://dzone.com[..]false-sharing-is-and-how-jvm-prevents-it

(google search) (amazon search)


Thu Aug 31 10:38:43 HKT 2017 From /weblog/java/tools

jhsdb


The jhsdb tool is described on its Oracle JDK 9 Documentation Early Access page, "You use the jhsdb tool to attach to a Java process or to launch a postmortem debugger to analyze the content of a core-dump from a crashed Java Virtual Machine (JVM)." The tool comes with several "modes" and several of these modes correspond in name and function with individual command-line tools available in previous JDK distributions. The jhsdb tool not only provides a single tool that encompasses functionality of multiple other tools, but it also provides a single, consistent approach to applying these different functions. For example, the jhsdb command-line syntax for getting help for each of the "modes" is identical.

http://marxsoftware.blogspot.hk/2017/06/jhsdb-jdk9.html
https://docs.oracle.com[..]UID-0345CAEB-71CE-4D71-97FE-AA53A4AB028E

(google search) (amazon search)


Sat Aug 26 14:11:22 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/

safepoints - http://performantcode.com/gc/safepoints/

(google search) (amazon search)



Fri Jun 02 17:55:34 HKT 2017 From /weblog/java/libraries

parsing


Introducing LALR parser in java - http://martinfowler.com/bliki/HelloCup.html

https://tomassetti.me/parsing-in-java/

(google search) (amazon search)


Thu May 18 10:29:03 HKT 2017 From /weblog/java/concurrency

tutorial


Another nice tutorial set of concurrency framework - http://www.javacodegeeks.com/search/label/Concurrency

Java concurrency, Building and testing concurrent applications for the Java platform - http://www.ibm.com[..]/training/kp/j-kp-concurrency/index.html

JVM concurrency: Java and Scala concurrency basics - http://www.ibm.com[..]/java/library/j-jvmc1/index.html?ca=drs-

http://javarevisited.blogspot.com.au[..]reading-interview-questions-answers.html

5 things you didn't know about ... Multithreaded Java programming - https://www.ibm.com/developerworks/library/j-5things15

(google search) (amazon search)


Thu May 18 10:28:15 HKT 2017 From /weblog/java/features

jdbc


5 things you didn't know about ... Java Database Connectivity - https://www.ibm.com/developerworks/library/j-5things10/index.html

(google search) (amazon search)


Wed May 17 10:27:49 HKT 2017 From /weblog/java/tools

monitoring


Java Flight Recorder, a tool to record all detail of how the API work for undo and replay and detail profiling - http://docs.oracle.com/cd/E15289_01/doc.40/e15070/toc.htm

Creating Custom JFR Events - http://hirt.se/blog/?p=444

Java Mission Control - http://blog.eisele.net[..]-mission-control-52-is-finally-here.html http://hirt.se/blog/?p=343 http://hirt.se/blog/?p=364&cpage=1#comment-98 https://www.infoq.com/news/2016/10/Java-Flight-Recorder-Mission

Support of JMX from common java library - http://www.javacodegeeks.com[..]ling-jmx-in-hibernate-ehcache-qurtz.html

sample code show how to get vm info at jmx - http://blogs.sun.com/jmxetc/entry/how_to_retrieve_remote_jvm

An excellent short tutorial of JMX - http://java.sun.com/developer/technicalArticles/J2SE/jmx.html

Monitoring all tomcat 5 JMX information, with free tools and java startup config - http://jroller.com[..]illiams/20050202#monitoring_tomcat_5_5_x

Task manager like jconsole plugin - http://blog.luminis.nl[..]is/entry/top_threads_plugin_for_jconsole

Performance cost of JMX - http://weblogs.java.net[..]nus/archive/2006/07/how_much_does_i.html

Monitoring Local and Remote Applications Using JMX 1.2 and JConsole - http://onjava.com/lpt/a/5226

Collections of tools - http://www.javacodegeeks.com[..]/client-side-server-monitoring-with.html

remote conenction with ssh - http://theholyjava.wordpress.com[..]nitoring-remote-jvm-over-ssh-jmx-or-not/

IBM healthcare API - http://www.ibm.com[..]rary/j-healthcareapi1/index.html?ca=drs- http://www.ibm.com/developerworks/java/jdk/tools/healthcenter/

JVM Statistics with jstat - http://marxsoftware.blogspot.hk[..]k/2017/05/jvm-statistics-with-jstat.html

(google search) (amazon search)


Sat May 06 14:13:47 HKT 2017 From /weblog/java/features

java8


Introduction of Lambdas expression in Java - http://zeroturnaround.com/labs/java-8-the-first-taste-of-lambdas/ , an example show how lambdas help to clean up the duplication - http://www.nurkiewicz.com[..]mplifying-readwritelock-with-java-8.html

Another article about Java8 change, where Lambdas is the highlight - http://www.infoq.com/news/2013/08/everything-about-java-8 http://www.shaunabram.com/java8/

Nice tutorial - http://www.dreamsyssoft.com/java-8-lambda-tutorial/index.php

Huge list of articles - http://www.baeldung.com/java8

Use lambdas to replace for-loop - http://saltnlight5.blogspot.com.au[..]creating-your-own-loop-structure-in.html https://www.ibm.com/developerworks/library/j-java8idioms3

Overview for new Date/Time library - http://www.infoq.com/articles/java.time

http://www.javacodegeeks.com[..]om/2014/05/java-8-features-tutorial.html

Grouping and partitioning with stream - http://fahdshariff.blogspot.com[..]/11/java-8-streams-api-grouping-and.html
In a nutshell, make sure to never override a default method in another interface - http://mydailyjava.blogspot.com.au[..]va-8-default-methods-can-break-your.html

Convert SQL feature to stream - http://blog.jooq.org[..]and-their-equivalents-in-java-8-streams/

(google search) (amazon search)


Sun Mar 26 00:09:52 HKT 2017 From /weblog/java/string

regex


Introduction to a library which support faster regular expression processing: http://weblogs.java.net[..]ite/archive/2006/03/a_faster_java_r.html http://www.javaadvent.com[..]-expression-library-benchmarks-2015.html

Regex helper - https://github.com/VerbalExpressions/JavaVerbalExpressions

java-regular-expressions-cheat-sheet - https://zeroturnaround.com[..]abs/java-regular-expressions-cheat-sheet

(google search) (amazon search)


Fri Mar 10 17:49:16 HKT 2017 From /weblog/java/concurrency

Map


putall can cause ConcurrentModifcationException - http://cr.openjdk.java.net[..]ses/sun/management/Agent.java.sdiff.html

Note on writing CopyOnWrite wrapper - http://flyingspaniel.blogspot.com[..]ot.com/2010/12/copyonwrite-wrappers.html

Sometime this is a bit difficult for Chinese to be a good programmer, recently some colleague and me discuss about the behaviour of this class and look like we have difficult understanding

A: ConcurrentHashMap support for locking as this is thread-safe
B: ConcurrentHashMap is thread safe for read but not for write because there is no lock, we still need to have external lock to keep it thread safe. By the way, I get ConcurrentModificationException from this before.
C: ConcurrentHashMap don't support for locking but they still thread safe for all operations, which is how "This class is fully interoperable with Hashtable in programs that rely on its thread safety but not on its synchronization details." mentioned.

Too good that we can actually take a look at the source code to see what going on nowadays rather than just guessing - http://www.google.com[..]HashMap&sourceid=opera&ie=utf-8&oe=utf-8 By the way, this constructor is useful for a lot of concurrency access but actually not many developer notice about this - http://java.sun.com[..]rrentHashMap.html#ConcurrentHashMap(int, float, int)

Lazy initialization of map values - http://artisans-serverintellect-com.si-eioswww6.com[..]ect-com.si-eioswww6.com/default.asp?W122

HashMap.get() can cause infinite loop - http://lightbody.net[..]5/07/hashmapget_can_cause_an_infini.html

Discussing the effect of initCapacity() of HashMap in Java - http://saloon.javaranch.com[..]ltimatebb.cgi?ubb=get_topic&f=1&t=021171

OpenJDK and HashMap …. Safely Teaching an Old Dog New (Off-Heap!) Tricks - http://www.infoq.com/articles/Open-JDK-and-HashMap-Off-Heap

We can run search in ConcurrenctHashMap - https://dzone.com/articles/concurrenthashmap-in-java8

(google search) (amazon search)


Tue Feb 28 16:39:40 HKT 2017 From /weblog/java/performance

tools


Free online GC log Analyzer - http://gceasy.io/

Free online thread analyzer - http://fastthread.io/

https://dzone.com[..]y-and-cpu-monitoring-tools-and-technique

(google search) (amazon search)


Wed Feb 15 17:35:52 HKT 2017 From /weblog/java/libraries

mapper


Discussion of difference Java base object to object mapper - http://halyph.blogspot.com.au[..]013/10/java-object-to-object-mapper.html

Some information about JOOQ - https://www.infoq.com/news/2017/02/data-geekery-releases-jooq-3-9

(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)