FAQ Database Discussion Community


How to export .jar with icon and native extension under Eclipse

java,eclipse,jvm
I have developed a Java application with Eclipse. I have also exported in the .jar format. It works great, but there are some issues; The icon is the one of the JVM and can't be modified If the PC where the application runs, it will not have the Java SDK,...

Can Java GC items iterated past?

java,garbage-collection,jvm
Let's say I have the following Java method: private static void testLoop() throws Exception { List<Integer> list = new ArrayList<>(); for (int i = 0 ; i < 100000 ; i++) list.add(i); for (Integer a : list) { Thread.sleep(10000); // Simulate lots of work. } } Question: Will the JVM...

Android studio 1.1 - change JRE used for running studio

java,android,android-studio,jvm
I have Android Studio 1.1 on a Windows 8.1 machine. There are several JDKs installed on my machine (1.6, 1.7, 1.8) and Android studio uses 1.8 (I can see that in the about popup). I want to change the JVM used for running Android Studio to 1.7, since I have...

Heap size issue on migrating from Solr 5.0.0 to Solr 5.1.0

solr,jvm
I have a Solr 5.0.0 in production with a custom heap size like this SOLR_JAVA_MEM="-Xms2g -Xmx2g" When I tried to migrate to Solr 5.1.0 with the same configuration and start the server it returned a OutOfMemoryError. Looking to the Solr API I saw that the heap size was set to...

Missing @Override in Java Libraries

java,inheritance,annotations,jvm
It is considered to be a good practice to use @Override annotation on methods which are being overriden in subclass. But why is same not applied to the classes that come with Java Library. For e.g. String Class. It overrides methods of Object class but does not use @Override annotation...

configuring _JAVA_OPTIONS for remote debug, I always get ERROR: JDWP

java,clojure,jvm
Good day, I'm trying debug my code, It's a clojure code using vertx lein...generally I use export JAVA_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n" and this works perfect, but I don't know why these JAVA_OPTS are ignored when I use a lein vertx project, basically the remote debugger doesn't start searching here in...

What's the purpose of including java.lang.Object in an interface's Constant Pool?

java,interface,jvm,bytecode,jvm-hotspot
Compiling the following interface: package test; public interface MyInterface { public void foo(); } and checking the compiled code using javap -v -s test.MyInterface shows the following (-s prints member signatures): Compiled from "MyInterface.java" public interface test.MyInterface SourceFile: "MyInterface.java" minor version: 0 major version: 51 flags: ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT Constant...

in java, is non-initialized object guarantee to be null?

java,jvm
public class T146 { //LRU Cache private HashMap<Integer, DoubleLinkedListNode> map = new HashMap<Integer, DoubleLinkedListNode>(); private DoubleLinkedListNode head; private DoubleLinkedListNode end; private int capacity; private int len; public LRUCache(int capacity) { this.capacity = capacity; len = 0; } } For this data structure. if I initilized a instance of T146. Without...

Can't open eclipse with Windows 7 (doesn't see jdk jde)

java,eclipse,jvm,jde
I'm trying to open eclipse for the first time, but otherwise I have this same problem as [Eclipse cannot find javaw.exe. The bit depth isn't resolving the issue. I have JDE & JDK 8 update 45 installed, and I've downloaded latest 64-bit version of Eclipse. The information given on command...

How does a servlet handle more bytes than available RAM?

java,performance,servlets,jvm
Lets say that I have a servlet running that accepts files of any size from a client application(s). The file being sent is loaded into a DataHandler and is transmitted by web-services; as such is received and put back into a DataHandler. What happens if the file being sent exceeds...

Multiple scala versions in the same project

scala,jvm
Apologies if this is a duplicate, I didn't hit on the magic keyword while searching. I have a project where I pull in various dependencies. One of them (jooq) depends on scala 2.10, whereas my application depends on scala 2.11.x. Although everything "works", I would like to understand better what...

how to attach debuggger to already running jvm with eclipse

eclipse,debugging,jvm
If I run a Spring project in Eclipse, I can either hit run or debug. Is it possible to start debugging the application while it is already running without restarting it? I know for sure that Intellij Ide can do it with android JVM.

Adding invokestatic to java/lang/Object. via JVM TI agent causes JVM to crash with segfault

java,jvm,instrumentation,.class-file,jvmti
I am trying to track allocations of all objects in JVM. In the several documents about allocation profilers it was mentioned that the easiest way to do so is this: add invokestatic Tracker.trackAllocation()V instruction to java/lang/Object.<init> (normally it consists of a single return instruction, we add invokestatic before it, so...

JVMTI - Get object for field in class

java,oracle,jvm,jni,jvmti
I'm having a problem with JVMTI. I would like to access each static field of a class and tag it. I can get the signature of each field, I can find out if it is static, but I haven't found a method yet to get a jobject for the fields...

A useful metric for determining when the JVM is about to get into memory/GC trouble

java,scala,garbage-collection,jvm
I have a scala data processing application that 95% of the time can handle the data thrown at it in memory. The remaining 5% if left unchecked doesn't usually hit OutOfMemoryError, but just gets into a cycle of major GCs that spikes the CPU, prevents background threads from executing and,...

Java thread start time

java,multithreading,time,jvm
Is it possible to retrieve the start time of a given java thread within the JVM? I have a thread dump and am looking at some problematic threads which I would like to correlate to a specific operations in the application log using time....

why the RES memory is changed for same code when different JVM XMX be setted

java,memory,jvm
I use the datastax driver to create NIO connections with Cassandra without do any other thing but just keep connection. What's more, when I set the XMX to 1G, the RES(from top -p [java pid]) will occupied about 400M memory, but when I set the XMX to 512M, the RES...

Why is Java faster if it repeats the same code?

java,optimization,jvm,jvm-hotspot
Given the following code: public class Test{ static int[] big = new int [10000]; public static void main(String[] args){ long time; for (int i = 0; i < 16; i++){ time = System.nanoTime(); getTimes(); System.out.println(System.nanoTime() - time); } } public static void getTimes(){ int d; for (int i = 0;...

In Scala, why unchecked warning is not issued for type arguments?

scala,jvm,type-erasure
I understand generally what type erasure is and why we would encounter unchecked warnings. However, I don't understand why only one unchecked warning is issued in the following case: class A[K] { def receive: PartialFunction[Any, Unit] = { case ds: List[Double] => // unchecked warning println("* List[Double]") case kx: Vector[K]...

JVM is functioning very differently with same flags

java,garbage-collection,jvm,g1gc
I created test application (with Sheduler inside that runs every 20ms, there are reads/writes to DB) and deployed it on Glassfish server on two different PC. Both have same (copy from one PC to another) Glassfish (both have also latest JAVA version) server with following flags: -XX:+DisableExplicitGC, XX:MaxGCPauseMillis=200, -Xmx512m, -Xms512m,...

JVM: Invalid index 1 in LocalVariableTable

java,jvm,java-bytecode-asm
I am trying to compile the following code using a custom compiler: public static void main([String] args) { long i = 2L i *= 2L System out println i } The result of the compilation is, when using javap, this Bytecode: public static void main(java.lang.String[]); descriptor: ([Ljava/lang/String;)V flags: ACC_PUBLIC, ACC_STATIC...

Does jar differentiate between program arguments and jvm arguments

java,jvm,command-line-arguments
I am trying to execute a jar file. It needs both program arguments and the jvm arguments. Do we need to do something different while passing the command line parameters in order for it to be able to differentiate them, or it will be handled automatically? Currently I am using...

Does ehcache reserve (allocate) heap memory set with maxBytesLocalHeap?

memory-management,jvm,ehcache
I use ehache 2.8. I am not sure I understand the documentation correctly regarding reservation of the memory for the cache. Is the memory set in ehcache.xml like this: <ehcache maxBytesLocalHeap="256M"> (...) </ehcache> ..actually being allocated at start and this cache will use exactly 256MB of heap or does this...

Effect of setting -XX:+PerfDisableSharedMem JVM flag to false

java,garbage-collection,jvm
I was referred to this GC pause issue; it suggests setting -XX:+PerfDisableSharedMem JVM flag to false. My question is what happens when we set this flag to false,

Why does waiting too long to promote an object from the young generation result in less efficiency?

java,performance,garbage-collection,jvm
Why does waiting too long to promote an object from the young generation lead to inefficiency? One explanation I have seen said that if you wait too long to promote the young generation, it will become less sparse (i.e. the size of the live set will become larger, viewed as...

Handling of `final` by the JVM

java,jvm,final
In a comment to this question, I'm claiming that final in some cases must be honored by the JVM. The safe publication of final variables has been already asked and so was the handling of static final members. But what about enforcing classes and methods being final and forbidding overwriting...

What is the difference between -Xss and -XX:ThreadStackSize?

java,multithreading,oracle,jvm,jvm-hotspot
I just want to control the stack size for all of my threads in a Java (groovy) application. For the Hotspot Oracle VM, I know that there are two parameters doing that (-Xss and XX:ThreadStackSize). Which is the preferred one? Is there any difference between them? Regarding Open JDK 7...

Releasing self-blocking references in Java [duplicate]

java,garbage-collection,jvm
This question already has an answer here: How does Java Garbage Collection work with Circular References? 8 answers This is a rather common case: class Team contains a list of all its Member instances while a Member refers to its Team. The Java code looks something like this: public...

Can Java class files use reserved keywords as names?

java,reflection,jvm,.class-file
I'm aware that Java-the-compilable-programming-language is not one and the same as Java-the-bytecode-format-for-JVM-execution. There are examples of things that are valid in the .class format but not in the .java source code, such as constructor-less classes and synthetic methods. If we hand-craft a .class file with a reserved Java language keyword...

Check class hierarchy at compile on an annotation processor

java,annotations,jvm,annotation-processing
I'm writing an annotation processor to perform the following check at compile time: There's an interface E There's an annotation @Apply which is used to annotate methods. Methods annotated with @Apply should be called apply and take only one parameter of a class implementing E I've gotten so far as...

JVM ClassUnloadingWithConcurrentMark flag

java,garbage-collection,jvm,g1gc
I have a question about ClassUnloadingWithConcurrentMark flag since I didn't find any useful help anywhere. If we use G1GC is set to true by default (-XX:+ClassUnloadingWithConcurrentMark). If I use -XX:-ClassUnloadingWithConcurrentMark flag to turn off class unloading after G1 concurrent mark where is class unloading executed then (which phase)? I read...

Scenario's where a Java thread running in infinite loop for a long run be terminated by JVM

java,tomcat,jvm,java-threads
I have a Runnable thread which loops through an infinite loop. Per iteration it sleeps upto next task time and then does some task. This task is very critical hence makes the thread running it also very critical. I am not really a java thread expert so I was wondering...

Intellij IDEA long processing for grails app with warning “too much output to process”

grails,intellij-idea,jvm
I new to Intellij for Grails app while run the app it execute lot of thing with the warning "Too much output to process" & takes comparatively more time to start the server. Below is the log screen (AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) at...

Insufficient memory for Java Runtime Environment to continue in Tomcat

java,tomcat,jvm,jvm-crash
I'm a tomcat/ tech newbie, so i'm sorry if I make any mistakes in the problem description. I'm trying to run a dashboarding application, DOMO on our test server. We have been using tomcat to run the application since a decade, and everything usually works fine. Recently, when I tried...

Why jar Manifest file shouldn't contain lines with more than 72 bytes

java,jvm,manifest
I can't find the answer to this on the web. Line length in the jar manifest length shouldn't exceed 72 bytes, why this restriction on the line length? Is it a performance improvement? Or an old problem that the JVM faced when it was first released in 1996?...

Difference between running Eclipse on java.dll and javaw.exe (or java.exe)

eclipse,windows,jvm
What is the difference between using java.dll and javaw.exe as the JVM for Eclipse to run on? DISCLAIMER I have posted this question along with the answer because I find this information useful and want to share this with others....

JVM shutdown hook quits unexpectedly

java,hadoop,jvm
I'm doing JVM profiling for Hadoop tasks using Java agent, as in https://github.com/etsy/statsd-jvm-profiler. The profiler registers shutdown hooks, which save the profiles to HDFS. But currently the hooks are terminated before they can finish. I'm sure they are executed because I can see some outputs from the hooks.

How is JNI_CreateJavaVM invoked when running a java app from the command line

java,jvm
I am trying to understand the point of entry into JVM. After doing my research I have learnt that JNI_CreateJavaVM (at least in HotSpot JVM) is the method that is called to launch the JVM. My question now is who calls the JNI_CreateJavaVM method ? I tried looking at the...

Java 8 , JCE Unlimited Strength Policy and SSL Handshake over TLS

java,ssl,jvm,centos,java-8
With Java 8, server which only supports TLSv1, it fails to make secure socket connection from cent OS Version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) Source import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader;...

Why does the JVM have the iconst_2 - iconst_5 opcodes?

java,jvm,opcodes
While reading the JVM specification (as one does), I was very surprised when I came across the 7 iconst_<i> opcodes. After all, there is only one byte to play with. I very rarely write the literals for 2, 3, 4 or 5 in my code. I can understand why -1,...

GridGain: How to run multiple nodes in the same JVM?

java,hadoop,jvm,gridgain
I'm trying to understand how one can run Hadoop applications using Gridgain in a single JVM context, using the in-memory accelerator. I've seen some hints of how this can be done programmatically as in here. However after trying to run this example in eclipse this error came up: Exception in...

Java call stack inspection and manipulation

java,jvm,stack-trace
My question is: is it possible (in ANY way) to analyze and modify call stack (both content of frames and stack content) in runtime? I'm looking for any possibility - low-level, unsafe or internal API, possibility to write C extension, etc. Only constraint: it should be usable in standard runtime,...

Maximum number of parameters in Java method declaration

java,jvm
What is the maximum number of parameters that a method in Java can have and why? I am using Java 1.8 on a 64-bit Windows system. All the answers on StackOverflow about this say that the technical limit is 255 parameters without specifying why. To be precise, 255 for static...

What does “taking operands immediately following the opcode” mean?

java,jvm,stack
I am reading the book Inside the Java 2 Virtual Machine and I can't understand what this means: The Java Virtual Machine is stack-based rather than register-based because its instructions take their operands from the operand stack rather than from registers. Instructions can also take operands from other places, such...

Variable 'final' modifier lost in Bytecode?

java,jvm,final
Analyzing the bytecode of this simple class, I have come to the conclusion that the compiler doesn't retain any information about a local variable being final. This seems weird though, since I believe the HotSpot compiler could actually use this information to do optimizations. Code: public static void main(String[] args)...

How does Java link lib/rt.jar to your app at runtime?

java,linker,jvm,classloader
The Java standard/system libraries (java.*, javax.*, etc.) are stored in lib/rt.jar inside each JRE distribution. Say I have an application that I have compiled and jarred into myapp.jar. This JAR only contains my app's class files, and merely references system classes like System, File, Runtime, Thread, String, Boolean, etc. So...

Java Bytecode invokeinterface instruction

java,jvm
Looking at this Java Bytecode (from the Eclipse ClassFile viewer), I noticed something strange with the invokeinterface instruction: It has a nargs (number of arguments) 'attribute' that occupies 2 bytes: 35 aload_2 [map] 36 ldc <String "a"> [15] 38 invokeinterface java.util.Map.get(java.lang.Object) : java.lang.Object [33] [nargs: 2] 43 checkcast java.lang.String [35]...

How is the inlined methods mapped to assembly in Hotspot?

jvm
In this file are listed JIT compiler intrinsics vmSymbols.hpp. How are the inlined methods mapped to the corresponding CPU instructions in Hotspot ? Note: I am looking for a specific inlined method _getObjectVolatile corresponding assembly code. Thank you...

Android Unit Testing not working for Android library project

android,android-studio,gradle,jvm,android-testing
We are trying to introduce the new Android Unit Testing Support to our project. For library project, it fails to find the src/main/java classes when running with gradlew. Running the test from Android Studio works as expected. Running the test with gradle in an app project works as expected. Running...

how to run SVN (Collabnet Edge 4.0.12) explicitly with JRE 1.7, when 1.8 is installed?

svn,jvm
I am running Collab.net SVN Edge 4.0.12 on a computer with Win 7 Pro x64 SP1. Recently I have updated the Java runtime to 1.8. After that I have found that I cannot access the web interface (http://localhost::3343/csvn/) any longer. I get the error HTTP ERROR: 503 Problem accessing /csvn/....

com.ibm.jsse2.util no trusted certificate found

java,jvm,lotus-domino,agents
I created a java agent that needs to connect to an API internaly. The protocol used is HTTPS. When the agent tries to connect to the API it throws the following error: com.ibm.jsse2.util: no trusted certificate found. This all is running on a Domino 9.0.1fp3 server. The SSL certificate is...

Does jni::ExceptionDescribe implicitily clear the exception trace of the JNI environment object?

java,c++,exception-handling,jvm,jni
I tried to implement some kind of exception handling At first i called jni::ExceptionDescribe() after that i used the implementation of How to obtain a description of a Java exception in C++ when using JNI? which i just named for simplicity printStackTrace()and which completely works fine . My problem is...

Force JVM to cache variables for threads

jvm,volatile,jvm-arguments,memory-barriers
Is there a way to tell the JVM to cache variables for threads as long as possible and never update them unless memory barriers or volatile variables are used? (for testing)

How are these Java byte offsets calculated?

java,jvm,bytecode
I have the following Java code: public int sign(int a) { if(a<0) return -1; else if (a>0) return 1; else return 0; } which when compiled generated the following bytecode: public int sign(int); Code: 0: iload_1 1: ifge 6 4: iconst_m1 5: ireturn 6: iload_1 7: ifle 12 10: iconst_1...

Does Java JVM use pthread?

java,linux,osx,jvm,pthreads
Does JVM on Mac OS X use pthread to create threads? What about on Linux distributions, is it now default way to create threads for JVM on all distributions?...

If I compile java with javac do I need JVM?

java,jvm,javac
I recently learned about how Java uses the JVM to make itself platform independent and I often write code and compile it with the javac command in terminal (Mac OS X). So my question is whether javac compiles it for JVM or if it is compiled directly to machine code?...

JVM Embedded into C, does not appear under running programs

java,jvm,jni
I have a C program (working in Solaris SPARC), which is creating a JVM and calling a Java application via JNI. The JVM is created and the java program works as expected, but I don't see the java process with ps -ef | grep java command. Any idea about what...

Why JVM is designed in a way that it does not allow force Garbage Collection? [closed]

java,garbage-collection,jvm
As far as I know, we can't force for Garbage Collection in JAVA. The best we can do is to send a request by calling System.gc() or Runtime.gc(). Doing so will send request of Garbage collection to JVM but it’s not guaranteed that garbage collection will happen. So my question...

Is JVM ARGS '-Xms1024m -Xmx2048m' still useful in Java 8?

java,jvm,java-8,jvm-arguments
I have a Java 7 application using JVM ARGS: -Xms1024m -Xmx2048m, and it runs pretty well. After I upgrade to Java 8, it runs in error state with Exception: Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded at org.hibernate.engine.StatefulPersistenceContext.addEntry(StatefulPersistenceContext.java:466) at org.hibernate.engine.TwoPhaseLoad.postHydrate(TwoPhaseLoad.java:80) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1439) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1332) at...

Java ASM Generate Catch Block

java,jvm,java-bytecode-asm,verifyerror
I am trying to compile a Try/Catch block using the ASM framework from my compiler (meaning that the try block, the handler blocks and the variables are dynamic). This is what my code currently looks like: org.objectweb.asm.Label tryStart = new org.objectweb.asm.Label(); org.objectweb.asm.Label tryEnd = new org.objectweb.asm.Label(); org.objectweb.asm.Label endLabel = new...

My jar runs on Ubuntu but not Windows

java,ubuntu,jvm,cross-platform
I have created a Java project in NetBeans and the automatically built distribution file (.jar) runs absolutely fine on my Ubuntu 15.04 AMD64 machine. I wanted to make sure it runs on windows before I distribute it, but having tested on a windows 7 32 bit machine I found it...

What is the method data in the JVM specification and what is it for?

java,jvm
I'm reading the jvm specification, It states that the 'Method Area' stores per-class structures such as the run-time constant pool, field and method data, and the code for methods and constructors. I know what the run-time constant pool is. I guess the field and method data is the code for...

Linkage Error in Tomcat when 2 webapp instances load lucene classes

java,tomcat,lucene,jvm,java.lang.linkageerror
I'm running a tomcat 8 container with 2 different webapps, 1 prod and 1 sandbox. All the classes/libs and compilation is the same with just some minor differences in the config parameters. I'm using lucene core 4.10.4 (via hibernate search). Both apps startup just fine, now after startup if I...

java.lang.StringBuffer java.lang.OutOfMemoryError: Java heap space

java,groovy,jvm
I am getting below error while reading data from database. please provide your thought about the cause. note - I have increased maximum heap size. Exception in thread "Thread-4" Exception in thread "Thread-2" java.lang.OutOfMemoryError: Java heap space at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:45) at java.lang.StringBuffer.<init>(StringBuffer.java:79) at com.ddtek.pool.ConnectionPool.enforceMinimum(Unknown Source) at com.ddtek.pool.ConnectionPool.doMaintenance(Unknown Source) at...

Interpreting JVM method call instructions

java,jvm,instructions
I understand that the instruction below means a method call has taken place: invokestatic:indexbyte1=00 indexbyte2=02 My understanding is that to find the index in the Constant Pool of the method being called, the bit shift operation is performed: 00 << 8 + 02 This equals to zero, which is not...

Home much memory does the JVM need to allocate a character array?

java,arrays,jvm,out-of-memory
Consider to following 1 line program: public static void main(String[] args) throws Exception { // 134217728 * 2 bytes / 1024 / 1024 = 256M char[] array = new char[134217728]; } How much memory does the JVM need to allocate this 256M character array? Turns out the answer is -Xmx384m....

Is class data sharing (CDS) impacted by installing a JRE via copying a directory?

java,jvm,installer
When a JRE is installed via an Oracle JRE installer, the installer creates a shared archive that enables class data sharing (CDS), reducing startup time and memory footprint of JRE processes. Questions If our installer instead installs a JRE by copying a JRE directory, do we lose class data sharing?...

Failed to create JVM in android studio

android,android-studio,jvm
I set the JAVA_HOME and PATH in environment variables but now android studio is giving to me a new error. here is error: Failed to create JVM:error code -6. JVM path:C:\Program Files\java\jdk1.9.0 if you already have a 64-bit JDKinstalled, define a JAVA_HOME variable in ...

CONSTANT_MethodHandle_info and CONSTANT_MethodType_info

java,jvm
In what situation can Java 7 compiler generate CONSTANT_MethodHandle_info and CONSTANT_MethodType_info constant pool entries?. Is it possible? Or they are completly used only with invokedynamic instruction and therefore never generated by Java 7 compliant compiler?

Visualize memory areas JVM [closed]

java,jvm
Is there any tool sort of thing, from where we can see, for a given java source code, where variables, references, objects, static fields resides in JVM.

Number of threads to limit CPU usage

java,multithreading,performance,jvm,cpu-usage
My application is a thread-per-request web server with a thread pool of M threads. All processing of a single request runs in the same thread. Suppose I am running the application in a computer with N cores. I would like to configure M to limit the CPU usage: e.g. up...

What do 'start' and 'length' attribute in LocalVariableTable mean

java,jvm,bytecode,java-bytecode-asm,bytecode-manipulation
So here is the example: LocalVariableTable: Start Length Slot Name Signature 0 133 0 this Lcom/my/class/Test; 2 131 1 a I 4 129 2 b I 7 126 3 i I 10 123 4 i2 I 16 117 5 o1 Ljava/lang/Integer; 31 102 6 o2 Ljava/lang/Integer; What does start and...

Identify Java jdwp Debugger Assigned (Ephemeral) Port

java,jvm,jvm-hotspot
I am using the following JVM parameters to start-up a JVM with the hostpot debugger. -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=0 Note that I am assigning port zero, so that the JVM asks the OS for an ephemeral port. This is critical for my use-case, to make sure the JVM will not fail to...

How can I make android studio very fast?

java,android,osx,android-studio,jvm
I have added the file /Users/Jim/Library/Preferences/AndroidStudio/studio.vmoptions With the following: -Xms2048m -Xmx4096m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=96m -XX:+UseCompressedOops I am not seeing a dramatic performance difference from the default. How do I know if these options are being used? Also are the rest of the options (premises and reservedcodechache) reasonable or too low?...

My Clojure code doesn't produce any output on HackerRank, but it does everywhere else

clojure,jvm
Currently I'm solving this problem "https://www.hackerrank.com/challenges/fp-sum-of-odd-elements" Here's my code (fn func[lst] ((fn sumOdd[sum, index] (if (< index (.size lst)) (do (if (= (mod (get lst index) 2) 1) (do (sumOdd (+ sum (get lst index)) (+ index 1)) ) (do (sumOdd (+ sum 0) (+ index 1)) ) ) )...

Will Java notice when a loop won't change anything, or should I use break statement?

java,jvm
I would like to determine whether some element of String-List has some other String as a substring. My approach was something like //... boolean found = false; for (String elem : myList) { if (elem.contains(someString)) { found = true; break; // <-- necessary? } } if (found) { // do...

How does NDK work in Android - What is the order that NDK, JNI etc are used?

java,android,android-ndk,jvm,jni
How are: Java, NDK, JNI, JVM, C/C++ code etc. related to each other in an android project? I want to know what happens e.g. Java code runs NDK method, NDK uses JNI library or whatever happens. Also what is the difference between NDK and JNI Sorry if this question is...

JVM Constant Pool Entries

java,jvm
Looking at the output of running javap on some classes, I have come across the following oddity: The Constant Pool of some classes contains entries such as #33 = Utf8 Code #34 = Utf8 LocalVariableTable #35 = Utf8 StackMapTable #36 = Utf8 MethodParameters Why do these constants appear in the...

InnerClasses attribute

java,class,jvm
The InnerClasses attribute description says that If a class has members that are classes or interfaces, its constant_pool table (and hence its InnerClasses attribute) must refer to each such member, even if that member is not otherwise mentioned by the class. These rules imply that a nested class or interface...

Unrecognized option: -security in Tomcat

java,tomcat,jvm,tomcat6
I'm trying to enable SecurityManager in Tomcat 6.0.43 using this doc: https://tomcat.apache.org/tomcat-6.0-doc/security-manager-howto.html When I start Tomcat with "-security" option, I get the following error in catalina.out: Unrecognized option: -security Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. I tried to use...

How to disable intrinsics usage for the JIT compiler?

java,jvm,jit
I am doing some performance tests on the JVM, and I would like to measure the impact of intrinsics usage. I would like to disable the JIT use of intrinsics for some methods without going into the interpreted mode. Is there a way to do that ? Thank you...

How to run unit tests for Android is not on the device or emulator?

java,android,unit-testing,jvm,continuous-integration
In android studio in the new sub-project has, as I understand this integration tests that run on the device or emulator, checks the functionality of the application depends on the SDK android. But I do have methods do not depend on android. Their testing, I would like to spend on...

Do Java Atomics only require atomicity with respect to the VM

java,multithreading,jvm,atomic,native-code
I was looking at the Java source code for the AtomicInteger class (found here) to see which atomic primitives are required to implement a JVM. I noticed they use the undocumented Unsafe API to implement their atomic integer operations and that the only two primitives they use seem to be...

increasing JVM memory and neo4j on win8.1

java,neo4j,jvm,jvm-arguments
I am running neo4j 2.1.7 on a windows 8.1 pro laptop. I have 16G of RAM, but I keep running out of heap memory. I have a large-ish database of maybe 250K nodes, but nothing close to what I am planning to run. I have set -Xmx to 1024m in...

Why does lambda translation need generation of a static method?

java,lambda,jvm,java-8,bytecode
Lambda translation is a two step process, One: desugaring the lambda into a static method in same class. public class Main { public static void main(String[] args) { Runnable r = () -> System.out.println("Hello"); System.out.println(Arrays.asList(Main.class.getDeclaredMethods())); } } [private static void Main.lambda$main$0(), public static void Main.main(java.lang.String[])] Two: generation of a class...

object reference and garbage collection

java,jvm
when the code has below relationship, will B and C will be garbage collected if disconnect A from B? and why?thanks class A{ B b; A(B b); } class B{ C c; B(C c); } class C{ C(); } class TestTarget{ public void test{ c = new C; b =...

What is a de-reflection optimization in HotSpot JIT and how does it implemented?

java,optimization,jvm,jit,jvm-hotspot
Watching Towards a Universal VM presentation, I studied this slide, which lists all the optimisations that HotSpot JIT does: In the language-specific techniques section there is a de-reflection. I tried to find some information about it accross the Internet, but failed. I understood that this optimization eliminates reflection costs in...

Why does the Java Compiler copy finally Blocks

java,jvm,javac,try-catch-finally,try-finally
When trying to compile the following code with a simple try/finally block, it produces the output below (viewed in the ASM Bytecode Viewer): Code: try { System.out.println("Attempting to divide by zero..."); System.out.println(1 / 0); } finally { System.out.println("Finally..."); } Bytecode: TRYCATCHBLOCK L0 L1 L1 L0 LINENUMBER 10 L0 GETSTATIC java/lang/System.out...

Starting tomcat with custom jvm without having to change JAVA_HOME and PATH on linux

java,linux,tomcat,jvm
I'm working with a server that needs to use several JVMs and the one I would like to use with my tomcat 7.0.28 is Oracle Server JRE 7. My Tomcat should not use the global JVM and I cannot change the environment variables either. I have checked what the internet...

Exposing whether an application is undergoing GC via UDP

java,garbage-collection,jvm
The motivation behind this question is to see whether we can make a theoretical load balancer more efficient for edge-cases by first applying its regular strategy of nominating a particular node to route an HTTP request to (say, via a round robin strategy) and then "peeking" into the internal state...

How to truly turn off Tiered Compilation?

java,jboss,jvm
My local Java environment is still on java version "1.6.0_35" Java(TM) SE Runtime Environment (build 1.6.0_35-b10) Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode) When I configure Jboss, I tried to turn off Tiered Compiler as Oracle suggested here, now there is the jvm parameters (with -XX:-TieredCompilation): VM Arguments:...

Kamon JVM and OS Metrics in docker-grafana-graphite

java,scala,jvm,akka,akka-monitoring
Im trying to monitor my scala akka app in the docker-grafana-graphite using kamon. I can see the actors stats in the Kamon Dashboard but I can't see any data in the System dashboard (JVM & OS) Here is my build.sbt file: import com.typesafe.sbt.SbtAspectj._ name := """kinneret""" scalaVersion := "2.11.6" resolvers...

Why in JVM Integer is stored as byte and short?

java,jvm
Here is one snippet of code public class Classifier { public static void main(String[] args) { Integer x = -127;//this uses bipush Integer y = 127;//this use bipush Integer z= -129;//this use sipush Integer p=32767;//maximum range of short still sipush Integer a = 128; // use sipush Integer b =...

Deploying JRE via JNI: jvm.dll not designed to run on Windows or […]

java,c++,jvm,jni
So I'm creating a Win32 application that packages the Java Runtime Environment (JRE) as a resource. The application extracts the resource to the disk and unzips it. Now, I would like to use this JRE in order to run a Java program using the invocation API. As soon as I...

-XX:+PrintTenuringDistribution doesn't print size per age

java,garbage-collection,jvm
I wrote simple program which infinitely addes objects into collection and I wanted to see standard output for PrintTenuringDistribution option: public static void main(String[] args) { while (true) { persons.add(new Person("jorik", "kornev")); } } As a program output I'm getting: Desired survivor size 5242880 bytes, new threshold 7 (max 15)...

Difference between prefix and postfix ++ operators in Java [closed]

java,jvm,operators,bytecode
There are a few questions regarding this (like Java: Prefix/postfix of increment/decrement operators?) but I'm not asking about the general difference between postfix and prefix ++ operators (I know that part), but about the fundamental difference between them at the Java specification level. Specifically, is there any difference between prefix...

Optimal JVM settings for Cassandra

cassandra,jvm,database-tuning,cassandra-2.1
I have a 4 node cluster with 16 core CPU and 100 GB RAM on each box (2 nodes on each rack). As of now, all are running with default JVM settings of Cassandra (v2.1.4). With this setting, each node uses 13GB RAM and 30% CPU. It is a write...

How can the offset for a JVM jump instruction be 32768?

java,c,casting,jvm,specifications
While writing an answer to a question about JVM byte code offsets, I noticed something in the behavior of javac and the resulting class files that I can not explain: When compiling a class like this class FarJump { public static void main(String args[]) { call(0, 1); } public static...

Launch java server vm by default

java,jvm
I have both Client VM and Server VM on my machine. $ java -client -version Java HotSpot(TM) Client VM $ java -server -version Java HotSpot(TM) Server VM By default Client VM is used: $ java -version Java HotSpot(TM) Client VM I'm trying to launch some java applications (like glassfish, teamcity,...

Long, Double and 64 bits of memory [duplicate]

java,multithreading,jvm
This question already has an answer here: What JVM synchronization practices can I ignore assuming I know I will run on x64 cpus? 5 answers Long and double require 64bits of memory. This causes these types to require two address spaces. On 64bit jvm's is this still the case...