RSS feed [root] /weblog /java




login:

password:

title search:




 


Thu Apr 06 06:33:22 GMT 2023

java



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

Sat Nov 12 18:37:44 GMT 2011 From /weblog/java/concurrency

Join


Example of Join - http://cnapagoda.blogspot.com/2010/01/thread-join-method.html

(google search) (amazon search)


Sat Nov 12 02:22:50 GMT 2011 From /weblog/java/features

tools


Trouble shooting guide, introduct few tools help to check issues - http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf

(google search) (amazon search)


Sat Oct 29 18:36:47 GMT 2011 From /weblog/java/hacks

cracking java


"hi there".equals("cheers !") == true
This is because in the JDK 1.3 SUN is caching the hash code so if it once is calculated, it doesn't get recalculated, so if the value field changes, the hashcode stays the same.

http://www.artima.com/forums/flat.jsp?forum=106&thread=4864

How to Modifying an Application without Modifying Its Source Code, with {-Xbootclasspath/p:} - http://www.ddj.com[..]M4OQSNDLPCKH0CJUNN2JVN?_requestid=186396

Override string! - http://www.javacodegeeks.com/2011/10/weird-funny-java.html

(google search) (amazon search)


Sat Oct 29 18:36:23 GMT 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)


Mon Oct 03 16:14:14 GMT 2011 From /weblog/java/libraries

ehcache


Cache by size - http://scaleaholic.blogspot.com[..]easy-java-performance-tuning-manage.html

(google search) (amazon search)


Sun Sep 25 01:35:12 GMT 2011 From /weblog/java/concurrency

yield


Yield is not that reliable- http://www.azulsystems.com[..]-pair-of-somebody-elses-concurrency-bugs

(google search) (amazon search)


Sun Sep 18 16:41:52 GMT 2011 From /weblog/java/features

realtime


Develop with real-time Java, Create applications with predictable response times - http://www.ibm.com[..]/training/kp/j-kp-rtj/index.html?ca=drs-

(google search) (amazon search)


Sun Aug 28 11:58:48 GMT 2011 From /weblog/java/concurrency

monitoring


Sample code of try-sync


import sun.misc.*;

import java.lang.reflect.*;

public class MonitorUtils {
private static Unsafe unsafe = getUnsafe();

public static boolean trySynchronize(Object monitor) {
return unsafe.tryMonitorEnter(monitor);
}

public static void unsynchronize(Object monitor) {
unsafe.monitorExit(monitor);
}

private static Unsafe getUnsafe() {
try {
for (Field field : Unsafe.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers())) {
if (field.getType() == Unsafe.class) {
field.setAccessible(true);
return (Unsafe) field.get(null);
}
}
}
throw new IllegalStateException("Unsafe field not found");
} catch (Exception e) {
throw new IllegalStateException(
"Could not initialize unsafe", e);
}
}
}


http://www.javaspecialists.eu/archive/Issue194.html

(google search) (amazon search)


Tue Aug 23 16:55:53 GMT 2011 From /weblog/java/libraries

Code Inspection


Comparison of difference static code analysis - http://weblogs.java.net[..]rar/archive/2006/11/talking_about_s.html

and http://www.javacodegeeks.com[..]-tools-source-code-optimization-and.html

(google search) (amazon search)


Mon Aug 15 15:40:53 GMT 2011 From /weblog/java/performance

usage


Offline parsing heap dump, good for analysis huge heap dump at server with GTK - http://www.eclipse.org[..]index.php?t=rview&goto=703990#msg_703990

Nice explanation of GC - http://redstack.wordpress.com[..]sualising-garbage-collection-in-the-jvm/

Get call back for memory allocation, should be very useful - http://blogs.lessthandot.com[..]s/applying-kanban-to-it-processes-part-2

Detailed discussion of analysis memory consumption in Java - http://kohlerm.blogspot.com[..]mory-consumption-of-netbeans-versus.html

it probably one of the nicest feature of java 5 - dump VM for you to analyst http://blogs.sun.com[..]apdumponoutofmemoryerror_option_in_5_0u7

This article present a simple, and possible not accurate method to track object creation and finalization. May be not that useful in general but sometime is convenience - http://www.devx.com/tips/Tip/30833?trk=DXRSS_JAVA

checking memory consumption at object level - http://www.jroller.org[..]im?entry=again_about_determining_size_of

Sun contain a nice library for we to investigate heap stat - http://elliotth.blogspot.com[..]om/2005/01/java-equivalent-of-heap1.html

Use java.util.Observable to Monitor Object State changes - http://www.devx.com/tips/Tip/22592?trk=DXRSS_JAVA

(google search) (amazon search)


Sun Jun 26 16:27:08 GMT 2011 From /weblog/java/concurrency

hint


A nice list of hints about concurrency in java - http://www.weiqigao.com[..]c_burke_java_concurrency_by_example.html

Testing about java parallel processing - http://embarcaderos.net[..]ng-and-multi-core-utilization-with-java/

Some concurrency basic information - http://blog.andrewhubbs.com/?p=107

Tutorial of concurrency package - http://tutorials.jenkov.com/java-util-concurrent/index.html

Using Latch with Executor - http://binkley.blogspot.com[..]06/new-shimmer-for-java-concurrency.html

(google search) (amazon search)


Sat May 14 18:01:11 GMT 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)


Thu May 05 00:35:19 GMT 2011 From /weblog/java/features

java7


A summary - http://tech.puredanger.com/java7 http://www.developer.com[..]d-to-Make-Developers-More-Productive.htm

concurrency improvement - http://www.infoq.com/news/2007/07/concurrency-java-se-7

Finally it is confirmed - http://www.petefreitag.com/item/778.cfm

You can do this in Java7, look pretty nice
try{
try-code
}
catch (SQLException | IOException) {
catch-code
}

http://extreme-java.blogspot.com[..]7-multi-catch-blocks-for-exceptions.html

(google search) (amazon search)


Sat Apr 23 17:44:47 GMT 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)


Sun Apr 10 01:54:33 GMT 2011 From /weblog/java/performance

dynamic compilation


Introduce the idea of using dynamic compilation to replace reflection using Janino - http://today.java.net/lpt/a/351 , but actually reflection isn't that slow - http://buzdin.blogspot.com[..]1/01/is-java-reflection-really-slow.html

How to use eclipse compiler as API - http://dev.eclipse.org[..]atch%20compile/batchCompile.html?rev=1.2

Support of annotation - http://jroller.com/page/eu?entry=compiler_for_jsr_308

Some cases that block method inlining - http://www.azulsystems.com[..]f/2011-04-04-fixing-the-inlining-problem

(google search) (amazon search)


Fri Mar 25 17:44:46 GMT 2011 From /weblog/java/eclipse

hadoop


https://grid.sara.nl[..]Hadoop/MapReduce_Development_Environment

(google search) (amazon search)


Tue Feb 15 17:16:05 GMT 2011 From /weblog/java/concurrency

AnonymousInnerClass


Here is an tricky concurrency concern in Java when using Anonymous Inner Class with ExecutorService, if you use collection from outside class, that collection actually a global variable in the Inner Class, and need to take care the issues happened in concurrency access.

For this class:

public static void main(String[] args) throws InterruptedException {
ExecutorService es = Executors.newFixedThreadPool(80);
final List list = new ArrayList();
for (int i = 0; i < 100000; i++)
es.execute(new Runnable() {
@Override
public void run() {
list.add(new String());
}
});
es.shutdown();
while (true) {
boolean terminated = es.awaitTermination(5, TimeUnit.SECONDS);
if (terminated) {
break;
}
}
for (String string : list) {
if (string == null)
System.out.println("Have null");
}
}

actually same as

private static final class RunnableImpl implements Runnable {
private final List mList;
private RunnableImpl(List list) {
mList = list;
}

@Override
public void run() {
mList.add(new String());
}
}
public static void main(String[] args) throws InterruptedException {
ExecutorService es = Executors.newFixedThreadPool(80);
final List list = new ArrayList();
for (int i = 0; i < 100000; i++)
es.execute(new RunnableImpl(list));
/** @formatter:on */
es.shutdown();
while (true) {
boolean terminated = es.awaitTermination(5, TimeUnit.SECONDS);
if (terminated) {
break;
}
}
for (String string : list) {
if (string == null)
System.out.println("Have null");
}
}


(google search) (amazon search)


Mon Feb 07 17:38:39 GMT 2011 From /weblog/java

misc


Sample to write custom indexer for lucent: http://www.onjava.com/lpt/a/6428

Overview of Antlr, Martin Fowler think it is better than SableCC - http://martinfowler.com/bliki/HelloAntlr.html

JMS performance test - http://www.c2b2.co.uk[..]t/ipoint?SelectedPage=69&110ArticleID=17

Six JDK Classes You Think You Know

1) java.lang.Double.MIN_VALUE, it is not negative number
2) java.lang.Thread.setDefaultUncaughtExceptionHandler and java.lang.Runtime.addShutdownHook can have racing
3) java.util.Properties.load
4) java.lang.String.getBytes
5) Use update row, java.sql.ResultSet.updateRow

http://jnb.ociweb.com/jnb/jnbDec2010.html

(google search) (amazon search)


Thu Jan 27 14:41:09 GMT 2011 From /weblog/java/discussion

factorial


A lot of difference implementation of factorial - http://chaosinmotion.com/blog/?p=622

(google search) (amazon search)


Tue Dec 14 16:30:18 GMT 2010 From /weblog/java/concurrency

antipattern


Why we need volatile in MT access - http://blogs.sun.com[..]age/sundararajan?entry=is_this_mt_safe_i

Sync. and set array - http://www.nabble.com[..]attern%2C-way-to-common-td16061045.html: No such file or directory

Java Concurrency Gotchas - ttp://www.slideshare.net[..]xmiller/java-concurrency-gotchas-3666977

(google search) (amazon search)


Thu Jun 03 18:21:24 GMT 2010 From /weblog/java/concurrency

profiler


But look like very useful: http://jroller.com/page/davinci?entry=simple_thread_profiling

Profile the contention of lock - http://www.infoq.com/articles/jucprofiler

(google search) (amazon search)


Thu Dec 31 09:29:28 GMT 2009 From /weblog/java/eclipse

shortcut


Ctrl + Shift + O : Organize imports

Ctrl + Shift + T : Open Type

Ctrl + Shift + F4 : Close all Opened Editors

Ctrl + O : Open declarations

Ctrl + E : Open Editor

Ctrl + / : Line Comment

Alt + Shift + R : Rename

Alt + Shift + L : extract to Local Variable

Alt + Shift + M : extract to Method

F3 : Open Declaration

CTRL-3: Quick Access

CHTL-H: Search & Replace

ALT-SHIFT-X: Run As ......

ALT-SHIFT-D: Debug As ......

ALT-SHIFT-Q: Open View ......

CTRL-TAB / SHIFT-CTRL-TAB: cycle open editors

Alt+Shift+Up - select whole string , if press multiple time, can select whole method. If select more than want, Alt+Shift+Down to reverse - http://eclipseone.wordpress.com[..]hods-in-eclipse-with-a-single-keystroke/



http://sureshkrishna.wordpress.com[..].com/2007/09/15/top-10-eclipse-shotcuts/

HoverToViewSource , but not working for me... - http://www.vasanth.in/2007/11/09/EclipseTipHoverToViewSource.aspx

(google search) (amazon search)


Thu Dec 03 07:41:18 GMT 2009 From /weblog/java/features

instrument


Use java.lang.instrument.Instrumentation; for profiling - http://java.dzone.com/articles/java-profiling-under-covers

(google search) (amazon search)


Thu Dec 03 07:23:22 GMT 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)


Sun Jul 26 17:08:14 GMT 2009 From /weblog/java/hacks

exception


How to get line number of specific stacktrace
private static void log(String prefix,
String message) {

StackTraceElement ste =
new Exception().getStackTrace()[2];

System.out.println("[" + prefix + "] " +
ste.getClassName() + "." +
ste.getMethodName() + "(" +
ste.getLineNumber() + "): " +
message);
}

http://jroller.com[..]0602#abusing_java_for_debugging_purposes

Annotation of using stacktrace - http://www.theserverside.com[..]m/news/thread.tss?thread_id=55238#312195

(google search) (amazon search)