bytecode

Encrypted class files with decryption handled by a native library

喜你入骨 提交于 2019-12-04 21:16:53
The article "Cracking Java byte-code encryption" ( javaworld.com/javaworld/javaqa/2003-05/01-qa-0509-jcrypt.html ) explains why class file encryption using a custom class loader is pointless, because at some point you always need to call defineClass(), which passes the class file to the JVM as an unencrypted byte array. However I've seen solutions where a slightly different approach is used; the class is decrypted by a native library and handed over to the JVM as a java.lang.Class instance through the findClass() method -- defineClass() is never called. Does that mean that these solutions do

How can I create a 48-bit uint for bit mask

早过忘川 提交于 2019-12-04 20:50:23
I am trying to create a 48-bit integer value. I understand it may be possible to use a char array or struct, but I want to be able to do bit masking/manipulation and I'm not sure how that can be done. Currently the program uses a 16-bit uint and I need to change it to 48. It is a bytecode interpreter and I want to expand the memory addressing to 4GB. I could just use 64-bit, but that would waste a lot of space. Here is a sample of the code: unsigned int program[] = { 0x1064, 0x11C8, 0x2201, 0x0000 }; void decode( ) { instrNum = (program[i] & 0xF000) >> 12; //the instruction reg1 = (program[i]

How switch cases are executed for strings?

有些话、适合烂在心里 提交于 2019-12-04 19:06:34
I have a doubt in switch-case statement. Here is my code : String month = "April"; switch (month.toLowerCase()) { case "january": monthNumber = 1; break; case "february": monthNumber = 2; break; case "march": monthNumber = 3; break; case "april": monthNumber = 4; break; and so on.. I have 3 questions in this context: 1) While comparing month with the case values i.e case "January", case "February" .. What is exactly used from the following by compiler ?? - month.equals("case-value") ? - month == case-value ? 2) And are case-values internally converted to StringBuilder/StringStringBuffer or

Ruby 2.0 Bytecode Export / Import

大兔子大兔子 提交于 2019-12-04 18:17:26
问题 I've been reading about the new ruby 2.0 features, and found that it will support bytecode import / export: Ruby 2.0 is expected to make it simple to save pre-compiled Ruby scripts to bytecode representations and to then run these directly. I've installed ruby-2.0.0-p0, but I didn't find any information on how to export the bytecode (or generally documentation on that matter). Is this feature already implemented, and if so, how do I use it? I'm also wondering about some of the details. Is

Why static/member variable are slower than local variable?

亡梦爱人 提交于 2019-12-04 13:47:46
问题 I've seen this thread: Speed of if compared to conditional Made my own class for checking the speed public class Question { static long startTime; static long elapsedTime; static String mStatic; private String mPublic; public static void main(String[] args) { Question q = new Question(); q.executeGlobal(); q.executeStatic(); q.executeLocal(); } public void executeLocal() { String mLocal; startTime = System.nanoTime(); for (int i = 0; i < 1000000000; i++) { mLocal = ""; } elapsedTime = System

Java bytecode equivalents for ilasm / ildasm

烈酒焚心 提交于 2019-12-04 13:09:59
问题 For CIL / MSIL, I can write the code in a text editor and compile / decompile with ilasm / ildasm. I can use Reflector to see the CIL generated by a .NET class. In the Java world, javap -c shows the disassembled byte code. How do I compile Java bytecode? (i.e. the Java equivalent of ilasm / ildasm). Is there an IDE that supports Java bytecode? Does the IDE support debugging i.e. single stepping / breakpoints etc.? 回答1: Bytecode Outline plugin for Eclipse to play with bytecode you can use ASM

Fail-safe way of round-tripping JVM byte-code to text-representation and back

时间秒杀一切 提交于 2019-12-04 11:41:33
I'm looking for a fail-safe way to round-trip between a JVM class file and a text representation and back again. One strict requirement is that the resulting round-tripped JVM class file is exactly functionally equivalent to the original JVM class file as long as the text representation is left unchanged. Furthermore, the text representation must be human-readable and editable. It should be possible to make small changes to the the text representation (such as changing a text string or a class name, etc.) which are reflected in the resulting class file representation. The simplest solution

How are methods found in AVM2 bytecode?

天涯浪子 提交于 2019-12-04 09:19:25
I've been playing around with ABC bytecode and was hoping someone could clear up a point of confusion for me. I have a simple flash file that places a clip on the stage and has a tiny script to update its position on each frame. The code looks something like: package { import flash.display.MovieClip; import flash.events.Event; public class RedCircle extends MovieClip { public function RedCircle() { this.addEventListener(Event.ENTER_FRAME, moveit); } function moveit(e:Event) { this.x -=1; } } } Which compiles to something like: protected package protected RedCircle { class RedCircle extends

How does scala generated byte code drops the checked exception?

倖福魔咒の 提交于 2019-12-04 09:05:02
If it possible to write byte code for a method that is supposed to throw a checked exception? For instance the following Java class doesn't compile unless the method declares it throws the checked exception: public class CheckedExceptionJava { public Class<?> testChecked(String s) throws ClassNotFoundException { return Class.forName(s); } } While the following Scala equivalent does ( because Scala doesn't have checked exceptions ) : class CheckedException { def testChecked( s : String ) = Class.forName( s ) } Even if the bytecode generated are almost identical: Compiled from

Is the hotspot JVM Bytecode Interpreter a tracing JIT?

感情迁移 提交于 2019-12-04 09:00:25
The question pretty much says it all, I've been looking around for an answer even through the VM spec but I it doesn't explicitly state it. No. There are some other JVMs with tracing JITs, though: HotPath and Maxine , for example. Aside: for those who don't know what a tracing JIT is, the following description comes from this page : Although tracing JITs are a complex technology, the core concept is about optimizing execution of the hot paths in a program. The emphasis is specifically on hot paths that return to the start of a path which sounds very much like a loop. However, the traditional