Tue May 03 14:08:30 GMT 2022 From /weblog/java/hacks
classloading
Hint to prevent blocking of loadClass by using Thread.getContextClassLoader() - https://blog.fastthread.io[..]3/java-class-loading-performance-impact/
(google search) (amazon search)
download zip of files only Tue May 03 14:08:30 GMT 2022 From /weblog/java/hacks classloadingHint to prevent blocking of loadClass by using Thread.getContextClassLoader() - https://blog.fastthread.io[..]3/java-class-loading-performance-impact/ (google search) (amazon search) Sun Oct 17 11:59:31 GMT 2021 From /weblog/java/hacks corner caseCorner case cheat sheet in Java - https://ge0ffrey.github.io[..]cornerCaseCheatSheet/cheatSheetJava.html (google search) (amazon search) Wed Dec 18 07:53:04 GMT 2013 From /weblog/java/hacks cglibhttp://www.jroller.com[..]/20050506#java_dynamic_proxies_and_cglib http://mydailyjava.blogspot.com.au[..]com.au/2013/11/cglib-missing-manual.html (google search) (amazon search) Thu Dec 05 05:16:04 GMT 2013 From /weblog/java/hacks preprocessorFunny, using gcc preprocessor with java - https://gist.github.com/anonymous/7797380 (google search) (amazon search) Tue Sep 11 14:21:17 GMT 2012 From /weblog/java/hacks IntrinsicsHow JVM optimzate the code by understanding the intentional of programmer - http://bad-concurrency.blogspot.com.au[..]/arithmetic-overflow-and-intrinsics.html (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) Sun Jul 26 17:08:14 GMT 2009 From /weblog/java/hacks exceptionHow 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) Mon Mar 17 17:25:28 GMT 2008 From /weblog/java/hacks killif you do a “kill -3? of the java process id, it dumps a stack trace of every thread, including what locks it’s holding, to stdout. - http://blog.xcski.com[..]ie-says-kill-3-pid-is-my-new-best-friend At windows, it is ctrl-break (google search) (amazon search) Sun May 13 11:12:13 GMT 2007 From /weblog/java/hacks quickstartof various java server - http://www.learntechnology.net/content/main.jsp of various java technology - http://www.javapassion.com/j2ee/index.html (google search) (amazon search) Thu May 03 07:30:15 GMT 2007 From /weblog/java/hacks jarThis should not really matter for deployment case, but for development which keep on restarting may be useful http://ant.apache.org/manual/CoreTasks/jar.html#indexjars Edit JAR in code - http://www.java-tips.org[..]og/java-se/how-to-modify-a-jar-file.html (google search) (amazon search) Fri Apr 27 08:12:43 GMT 2007 From /weblog/java/hacks Throws NULLWe can just throw null; in java, but probably not a good idea for most case http://beanman.wordpress.com[..]hrowing-null-with-different-jvm-options/ (google search) (amazon search) Thu Feb 15 09:34:38 GMT 2007 From /weblog/java/hacks Interesting and useless trickchange intern String: http://cretesoft.com/archive/newsletter.do?issue=014 limitation of string size, parameter list length, ... etc: http://javaspecialists.co.za[..]ive/newsletter.do?issue=059&locale=en_US and http://www.javaspecialists.co.za/archive/newsletter.do?issue=121 Related is Size limitation of Java String - http://www.oreillynet.com/lpt/wlg/6303 generating nullpointerexception from throw NULL: http://fishbowl.pastiche.org/2003/04/30/throwing_null When no nullpointerexception when object is null: http://fishbowl.pastiche.org/2006/01/17/random_java_trivia (google search) (amazon search) Thu Nov 30 15:22:16 GMT 2006 From /weblog/java/hacks j2meoptimizing java class for j2me, look like just break all OO principle... http://blog.javia.org/?p=31 (google search) (amazon search) Sat Nov 11 10:03:05 GMT 2006 From /weblog/java/hacks bitwise operation on booleanbitwise operation on boolean The solution to the puzzle is given in the Java Language Specification, chapter 15.22.2: 15.22.2 Boolean Logical Operators &, ^, and | When both operands of a &, ^, or | operator are of type boolean, then the type of the bitwise operator expression is boolean. For &, the result value is true if both operand values are true; otherwise, the result is false. For ^, the result value is true if the operand values are different; otherwise, the result is false. For |, the result value is false if both operand values are false; otherwise, the result is true. http://beust.com/weblog/archives/000350.html Someone mentioned that there is no boolean, byte and short in byte code level, all just integer http://oddjava.com/?q=node/8 (google search) (amazon search) Tue Nov 07 05:11:24 GMT 2006 From /weblog/java/hacks securityPrevent System.exit() being call - http://jroller.com/page/ethdsy?entry=disabling_system_exit Usually security manager forbid it (google search) (amazon search) Wed Jul 12 08:09:26 GMT 2006 From /weblog/java/hacks Cracking class filesNo sure if that still valid, but look like encrypt class file don't help on protecting class. http://www.javaworld.com[..]ld/javaqa/2003-05/01-qa-0509-jcrypt.html (google search) (amazon search) Mon Jun 26 06:32:59 GMT 2006 From /weblog/java/hacks trick for java 5New look of resultset, WebRowSet, http://www.onjava.com/lpt/a/6633 , but I personally don't think this is something useful Some information how using jmxagent: http://weblogs.java.net[..]nus/archive/2006/06/going_beyond_jd.html Just come across a nice article that discuss about various new features of 1.5 and provide tips on how to use them: http://java.sys-con.com/read/171487_p.htm Create collection quick List Or this: Map put("Java", "Wicked"); put("C++", "Ok"); put("Ruby", "Interesting"); }}; http://www.theserverside.com/blogs/thread.tss?thread_id=37839 (google search) (amazon search) Tue May 16 07:30:58 GMT 2006 From /weblog/java/hacks equals() at proxy generated instanceAt least need to test on the interface level. And more complicate if you don't want to expose the internal structure to interface http://www.javaspecialists.co.za/archive/newsletter.do?issue=126 (google search) (amazon search) Fri Apr 07 05:13:55 GMT 2006 From /weblog/java/hacks java.util.CalendarI don't know this before, and I don't know if this is the behaviour of all Calendar implementation or it is only GregorianCalendar do this...
http://discuss.joelonsoftware.com/default.asp?joel.3.328034 (google search) (amazon search) Wed Dec 14 08:35:14 GMT 2005 From /weblog/java/hacks beware of java inlineUsually java inline constant , this work fine most likely but sometime you will have surprise about this http://www.cretesoft.com/archive/newsletter.do?issue=114 http://jroller.com/page/ee?entry=dependency_checking_of_javac http://jroller.com/page/ee?entry=javac_s_inlining_revisited (google search) (amazon search) Tue Jul 12 04:27:06 GMT 2005 From /weblog/java/hacks find file in classpathThis is kind of useful to have a quick way to find file in classpath, see if some day really deploy to system I work on: http://jroller.com/page/mlconnor/20050708#code_to_find_files_on (google search) (amazon search) |