bytecode

Flash app depends on Flex. Are there any SWF bytecode size optimizers?

痞子三分冷 提交于 2019-12-23 16:03:50
问题 Hello world application that uses Flex, compiled with optimize=true has size 178K. How to reduce application size? We do not like to use RSL, we don't like to avoid Flex. Largest part of resulting SWF is unused bytecode. Are there any tools to optimize bytecode — drop unused methods, classes, give methods shorter names and so on? I know some such tools for Java bytecode. Any there any for SWF? 回答1: The size is the cost of the Flex API. You don't get to pick and choose which parts are compiled

Library that allows easy printing of bytecode instructions *including* parameters

有些话、适合烂在心里 提交于 2019-12-23 15:22:46
问题 I am looking for a library that will easily allow me to see a method's given bytecode. Example: ALOAD 0 INVOKEVIRTUAL ns/c.m ()I IRETURN I've tried both: ASM : I could actually get it to print instructions plus parameters, but I'm having difficulties wrapping my head around its whole visitors paradigm, that is to say, the best I did was to pretty print a whole class. BCEL : Could get it to print the instructions, but no parameters. JavaAssist : Could get it to print the instructions, but no

Why does python VM have co_names instead of just using co_consts?

妖精的绣舞 提交于 2019-12-23 10:55:14
问题 A code object generated by Python compiler contains a tuple of constants used in the instructions (named co_consts ) and also a tuple containing names (named co_names ). Why having two distinct lists? Wouldn't be simpler to just use co_consts for names too? 回答1: Consider the following function. def f(x): x += n return x * 4 Here x is a local name, its value can change. 4 is a constant. Its value will never change. However, it's still an object and it's better to cache them rather than create

how is java annotation represented in java bytecode

大憨熊 提交于 2019-12-23 08:46:30
问题 I tried to decompile a .class file that contains JUnit tests. I read the byte code, but I did not see any clue of the @Test annotation(it's used in the java source code). As metadata, how are annotations represented in bytecode? 回答1: Annotations appear just before the byte code of the thing it is associated with. If you are not seeing the annotations it could be an old de-compiler (most of them are) 来源: https://stackoverflow.com/questions/12368137/how-is-java-annotation-represented-in-java

Are Bytecode and Assembly Language the same thing?

点点圈 提交于 2019-12-23 08:25:51
问题 The question might seem odd, but I am still trying to grasp the concepts of virtual machines. I have read several answers, but I still don't get if Java bytecode (and MSIL as well) is the same as assembly language. As far as I understand both bytecode and assembly gets compiled to machine code, so speaking in terms of abstraction they are at the same level, i.e. one step above machine code. So is bytecode just an assembly language, i.e. a human readable form of machine code. If yes, then why

Bytecode manipulation patterns

大憨熊 提交于 2019-12-23 08:08:13
问题 What legitimate uses are there for bytecode manipulation and how people implement those bytecode manipulation based solutions in practice? Update: I should have made it more clear that this question really is about what patterns and techniques people use to make their code fly with the help of bytecode manipulation. Something like aspect oriented programming that was already mentioned or building proxy objects on the fly and similar techniques. 回答1: Bytecode manipulation lets you implement

ByteBuddy fails when trying to redefine sun.reflect.GeneratedMethodAccessor1

家住魔仙堡 提交于 2019-12-23 01:46:51
问题 Driven by curiosity, I tried to export the bytecode of GeneratedMethodAccessor1 (generated by the JVM when using reflection). I try to get the bytecode of the class the following way: public class MethodExtractor { public static void main(String[] args) throws Exception { ExampleClass example = new ExampleClass(); Method exampleMethod = ExampleClass.class .getDeclaredMethod("exampleMethod"); exampleMethod.setAccessible(true); int rndSum = 0; for (int i = 0; i < 20; i++) { rndSum += (Integer)

ByteBuddy fails when trying to redefine sun.reflect.GeneratedMethodAccessor1

笑着哭i 提交于 2019-12-23 01:46:09
问题 Driven by curiosity, I tried to export the bytecode of GeneratedMethodAccessor1 (generated by the JVM when using reflection). I try to get the bytecode of the class the following way: public class MethodExtractor { public static void main(String[] args) throws Exception { ExampleClass example = new ExampleClass(); Method exampleMethod = ExampleClass.class .getDeclaredMethod("exampleMethod"); exampleMethod.setAccessible(true); int rndSum = 0; for (int i = 0; i < 20; i++) { rndSum += (Integer)

Java Bytecode: Customized setter/getter with byte buddy

孤人 提交于 2019-12-22 08:30:17
问题 I am trying to create a "custom" setter method for a field with byte buddy. Buddy's own mechanism allows for standard setter/getter methods to be implemented very easily, however, I am looking for an elegant way to extend the setter with some additional logic. To simplify the example, let's assume we have a class A, which has a method setChanged(String). Goal is to make a sub-class of A, add a field with corresponding access methods. The catch is, that I want to call setChanged("fieldName")

Bytecode changes over time in undocumented manner

旧街凉风 提交于 2019-12-22 07:20:11
问题 Today I was exploring classes of huge applications (like jboss server with apps) with javaagent and instrumentation on my openjdk 7. I called retransform on all classes every 10 seconds, so their bytecode got in my ClassFileTransformer implementation. My implementation simply keeps track of how bytecode of classes changes over time. First of all, I was surprised, that order of fields and methods, method access modifiers, contents of constant pool and other such things vary from one check to