Why is the number of local variables used in a Java bytecode method not the most economical?

There are several reasons. First off, it’s not necessary for performance. The JVM already optimizes things at runtime, so there’s no point in adding redundant complexity to the compiler. However, another major reason noone has mentioned here is debugging. Making the bytecode as close to the original source as possible makes it a lot easier … Read more

Massive memory hemorrhage that causes heap size to go from about 64mb, to 1.5gb in roughly 8 seconds. Issue with garbage collector?

Try specifying a garbage collector manually. Concurrent Mark Sweep is a good general purpose one that provides a good balance between low-pause and reasonable throughput. If you are on Java 7 or later Java 6, G1 collector is probably better since it is able to also prevent memory fragmentation. You can check the Java SE … Read more

Why reading a volatile and writing to a field member is not scalable in Java?

This is what I think is happening (keep in mind I’m not familiar with HotSpot): 0xf36c9fd0: mov 0x6c(%ecx),%ebp ; vfoo 0xf36c9fd3: test %ebp,%ebp ; vfoo is null? 0xf36c9fd5: je 0xf36c9ff7 ; throw NullPointerException (I guess) 0xf36c9fd7: movl $0x1,0x8(%ebp) ; vfoo.x = 1 0xf36c9fde: mov 0x68(%ecx),%ebp ; sz 0xf36c9fe1: inc %ebx ; i++ 0xf36c9fe2: test %edi,0xf7725000 … Read more

What is JVM -server parameter?

It just selects the “Server Hotspot VM”. See documentation (Solaris/Linux) for java. According to Wikipedia: Sun’s JRE features 2 virtual machines, one called Client and the other Server. The Client version is tuned for quick loading. It makes use of interpretation, compiling only often-run methods. The Server version loads more slowly, putting more effort into … Read more

How to emit and execute Java bytecode at runtime?

Here is a working “hello world” made with ObjectWeb ASM (a library which I recommend): package hello; import java.lang.reflect.Method; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; public class HelloWorldASM implements Opcodes { public static byte[] compile(String name) { ClassWriter cw = new ClassWriter(0); MethodVisitor mv; cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER, “hello/HelloWorld”, null, “java/lang/Object”, null); cw.visitSource(“HelloWorld.java”, … Read more

How to find out what algorithm [ encryption ] are supported by my JVM?

The following will list all the providers and the algorithms supporter. What version of Java are you using? Unless you’re on an old version JCE should be included as standard. import java.security.Provider; import java.security.Security; public class SecurityListings { public static void main(String[] args) { for (Provider provider : Security.getProviders()) { System.out.println(“Provider: ” + provider.getName()); for … Read more

Is Clojure object-oriented at its heart? (Polymorphism in seqs)

Idiomatic Clojure favors defining independent functions that operate on a very small set of core data structures; this unbundling of methods and data is a strong statement against object orientation and in favour of a functional style. Rich Hickey (creator of Clojure) has repeatedly stated the importance of this; for example here: “Clojure eschews the … Read more

Differences between Apache Deft, Webbit and Vert.x [closed]

Disclosure – I’m the vert.x guy 🙂 Vert.x is a fully fledged platform for building polyglot, scalable, asynchronous web-enabled applications. It is heavily inspired from node.js but goes further than node.js and provides a distributed event bus which reaches from the server right into client side JavaScript thus creating a super simple model for so-called … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)