jvm

Call javascript function from kotlin JVM based project

為{幸葍}努か 提交于 2021-02-08 07:58:27
问题 Is is possible to call javascript functions from kotlin JVM based project? Like for example I got class: class JS{ fun callJS( ){ // somehow call js function } } 回答1: You can use a ScriptEngineManager with JavaScript as the engine. You use ScriptEngineManager.getEngineByName to get the engine itself, but that doesn't allow calling methods from Java. In order to do this, you need an Invocable. This is done by first eval uating the script (either as a Reader or String) and then casting it as an

Disable ClassDump to a running JVM process by using sa-jli

情到浓时终转凉″ 提交于 2021-02-08 06:47:52
问题 I'm trying to protect my classes in a running JVM by setting -XX:+DisableAttachMechanism. However, I found that the process prevents tools like jconsole to attach, but still I can use following command the dump all the loaded classes in that JVM: java -Dsun.jvm.hotspot.tools.jcore.PackageNameFilter.pkgList=com.xxxx -classpath ".:./bin:$JAVA_HOME/lib/sa-jdi.jar" sun.jvm.hotspot.tools.jcore.ClassDump 1234 Is there any way to stop this behavior by setting some options in the running JVM? Or

memory swap to disk in Java JVM

試著忘記壹切 提交于 2021-02-08 05:37:17
问题 I am using 64-bit Linux and Java JVM. I want to confirm if the memory used by JVM is smaller than physical memory size of the machine, there will be no disk memory swap by OS? 回答1: No, that's not necessarily true. Physical memory is shared by all processes, as well as by a bunch of other kernel things (e.g. the disk cache). So the amount of virtual memory used by your application is not the only consideration. 回答2: You can start your java application with the jvm argument -Xmx512m wich will

What assumptions could a garbage collector for a pure, functional, eagerly-evaluated language safely make?

笑着哭i 提交于 2021-02-08 04:47:31
问题 Clarifying the question a bit: Garbage collectors such as those used by the JVM involve a lot of complexity as a result of the nature of the languages they support. What simplifications would be afforded to a garbage collector purpose-built for a pure, functional, eagerly-evaluated programming language compared to say, the JVM garbage collector? 回答1: I'm barely an expert in functional languages design but when thinking about your question, immediately the following topics come to my mind:

How does the Garbage Collector update the references pushed to the operand stack?

Deadly 提交于 2021-02-08 03:36:11
问题 The JVM can easily update the references of local variables, static references, class instances or object array instances when moving an object in heap. But how can it update the references pushed to the operand stack? 回答1: There is no fundamental difference between a local variable and an entry in the operand stack. Both live in the same stack frame. Neither is formally declared and both need the JVM to perform inference to recognize their actual use. The following code public static void

How does the Garbage Collector update the references pushed to the operand stack?

余生长醉 提交于 2021-02-08 03:35:28
问题 The JVM can easily update the references of local variables, static references, class instances or object array instances when moving an object in heap. But how can it update the references pushed to the operand stack? 回答1: There is no fundamental difference between a local variable and an entry in the operand stack. Both live in the same stack frame. Neither is formally declared and both need the JVM to perform inference to recognize their actual use. The following code public static void

using java's -XX:OnError option

旧街凉风 提交于 2021-02-08 03:24:41
问题 I wrote the following code: public class JavaErrorTest { public static void main(String[] args) { if (1 < 2) { throw new OutOfMemoryError(); } } } Then I invoke it like: $ java -XX:OnError="echo %p" JavaErrorTest And in my console, I get the following: Exception in thread "main" java.lang.OutOfMemoryError at JavaErrorTest.main(JavaErrorTest.java:5) Somehow, I suspect that the -XX:OnError JVM option is not being picked up. I'm invoking java using cygwin, using jdk 1.6.0_30, running under

fetching running bytecode from a JVM

喜夏-厌秋 提交于 2021-02-08 03:10:32
问题 I am trying to find out if it is possible to get the bytecode of a function after it was loaded to the JVM. I know I can get the code from the .class file using ClassLoder and I can manipulate it using Instrumentation, but this is not the issue here. Suppose I have a compiled Java program called Test.class and I run, its bytecode will be loaded the JVM, from this point can I get the bytecode? EDIT: Following the answers I want to point again, my intention is to inspect code which is running

fetching running bytecode from a JVM

天涯浪子 提交于 2021-02-08 03:07:47
问题 I am trying to find out if it is possible to get the bytecode of a function after it was loaded to the JVM. I know I can get the code from the .class file using ClassLoder and I can manipulate it using Instrumentation, but this is not the issue here. Suppose I have a compiled Java program called Test.class and I run, its bytecode will be loaded the JVM, from this point can I get the bytecode? EDIT: Following the answers I want to point again, my intention is to inspect code which is running

fetching running bytecode from a JVM

安稳与你 提交于 2021-02-08 03:05:19
问题 I am trying to find out if it is possible to get the bytecode of a function after it was loaded to the JVM. I know I can get the code from the .class file using ClassLoder and I can manipulate it using Instrumentation, but this is not the issue here. Suppose I have a compiled Java program called Test.class and I run, its bytecode will be loaded the JVM, from this point can I get the bytecode? EDIT: Following the answers I want to point again, my intention is to inspect code which is running