Examples of JumpMarker


Examples of org.fakereplace.util.JumpMarker

                                b.add(Opcode.DUP_X2);
                                b.add(Opcode.POP);
                                b.add(Opcode.DUP_X2);
                                b.addInvokestatic(methodReflectionLocation, "fakeCallRequired", "(Ljava/lang/reflect/Method;)Z");
                                b.add(Opcode.IFEQ);
                                JumpMarker performRealCall = JumpUtils.addJumpInstruction(b);
                                // now perform the fake call
                                b.addInvokestatic(methodReflectionLocation, "invoke", REPLACED_METHOD_DESCRIPTOR);
                                b.add(Opcode.GOTO);
                                JumpMarker finish = JumpUtils.addJumpInstruction(b);
                                performRealCall.mark();
                                b.addInvokevirtual(Method.class.getName(), METHOD_NAME, METHOD_DESCRIPTOR);
                                finish.mark();
                                it.writeByte(CodeIterator.NOP, index);
                                it.writeByte(CodeIterator.NOP, index + 1);
                                it.writeByte(CodeIterator.NOP, index + 2);
                                it.insert(b.get());
                            }
View Full Code Here

Examples of org.fakereplace.util.JumpMarker

                                RewriteData data = methodCallLocations.get(val);
                                Bytecode b = new Bytecode(file.getConstPool());
                                prepareForIsFakeFieldCall(b, data);
                                b.addInvokestatic(fieldAccessLocation, "isFakeField", "(Ljava/lang/reflect/Field;)Z");
                                b.add(Opcode.IFEQ);
                                JumpMarker performRealCall = JumpUtils.addJumpInstruction(b);
                                // now perform the fake call
                                b.addInvokestatic(fieldAccessLocation, data.getMethodName(), data.getNewMethodDescriptor());
                                b.add(Opcode.GOTO);
                                JumpMarker finish = JumpUtils.addJumpInstruction(b);
                                performRealCall.mark();
                                b.addInvokevirtual(Field.class.getName(), data.getMethodName(), data.getMethodDescriptor());
                                finish.mark();
                                it.writeByte(CodeIterator.NOP, index);
                                it.writeByte(CodeIterator.NOP, index + 1);
                                it.writeByte(CodeIterator.NOP, index + 2);
                                if (op == CodeIterator.INVOKEINTERFACE) {
                                    // INVOKEINTERFACE has some extra parameters
View Full Code Here

Examples of org.fakereplace.util.JumpMarker

                b.addAload(1);
                b.addAload(0);
                b.addInvokestatic(ClassLookupManager.class.getName(), "getClassData", "(Ljava/lang/String;Ljava/lang/Object;)[B");
                b.add(Opcode.DUP);
                b.add(Opcode.IFNULL);
                JumpMarker jumpEnd = JumpUtils.addJumpInstruction(b);

                //now we need to do the findLoadedClasses thing
                b.addAload(0);
                b.addAload(1);
                b.addInvokevirtual("java.lang.ClassLoader", "findLoadedClass", "(Ljava/lang/String;)Ljava/lang/Class;");
                b.add(Opcode.DUP);
                b.add(Opcode.IFNULL);
                JumpMarker notFound = JumpUtils.addJumpInstruction(b);
                b.add(Opcode.ARETURN);
                notFound.mark();
                b.add(Opcode.POP);
                b.addAstore(3);
                b.addAload(0);
                b.addAload(1);
                b.addAload(3);
                b.addIconst(0);
                b.addAload(3);
                b.add(Opcode.ARRAYLENGTH);
                b.addInvokevirtual("java.lang.ClassLoader", "defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;");
                if (method.getDescriptor().equals("Ljava/lang/String;Z)Ljava/lang/Class;")) {
                    b.addIload(2);
                } else {
                    b.addIconst(0);
                }
                b.add(Opcode.IFEQ);
                final JumpMarker linkJumpEnd = JumpUtils.addJumpInstruction(b);
                b.add(Opcode.DUP);
                b.addAload(0);
                b.add(Opcode.SWAP);
                b.addInvokevirtual("java.lang.ClassLoader", "resolveClass", "(Ljava/lang/Class;)V");
                linkJumpEnd.mark();
                b.add(Opcode.ARETURN);
                jumpEnd.mark();
                b.add(Opcode.POP);

                if (!classFile.getName().startsWith("java.") && !classFile.getName().startsWith("com.sun") && !classFile.getName().startsWith("sun")) {
                    //now we need to check if this is a fakereplace class
                    //and if so always delegate to the appropriate loader
                    b.addAload(1);
                    b.addLdc("org.fakereplace");
                    b.addInvokevirtual(String.class.getName(), "startsWith", "(Ljava/lang/String;)Z");
                    b.add(Opcode.IFEQ);
                    JumpMarker notFakereplace = JumpUtils.addJumpInstruction(b);
                    //so this is a fakereplace class, delegate to the system loader
                    b.addInvokestatic(ClassLoader.class.getName(), "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
                    b.addAload(1);
                    b.addInvokevirtual(ClassLoader.class.getName(), "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
                    b.add(Opcode.ARETURN);
                    notFakereplace.mark();
                }

                iterator.insert(b.get());
                method.getCodeAttribute().computeMaxStack();
            }
View Full Code Here

Examples of org.fakereplace.util.JumpMarker

                                // we need Constructor, params, Constructor
                                b.add(Opcode.SWAP);
                                b.add(Opcode.DUP_X1);
                                b.addInvokestatic(constructorReflectionLocation, "fakeCallRequired", "(Ljava/lang/reflect/Constructor;)Z");
                                b.add(Opcode.IFEQ);
                                JumpMarker performRealCall = JumpUtils.addJumpInstruction(b);
                                // now perform the fake call
                                b.addInvokestatic(constructorReflectionLocation, METHOD_NAME, REPLACED_METHOD_DESCRIPTOR);
                                b.add(Opcode.GOTO);
                                JumpMarker finish = JumpUtils.addJumpInstruction(b);
                                performRealCall.mark();
                                b.addInvokevirtual(Constructor.class.getName(), METHOD_NAME, METHOD_DESCRIPTOR);
                                finish.mark();
                                it.writeByte(CodeIterator.NOP, index);
                                it.writeByte(CodeIterator.NOP, index + 1);
                                it.writeByte(CodeIterator.NOP, index + 2);
                                it.insertEx(b.get());
                            }
View Full Code Here

Examples of org.fakereplace.util.JumpMarker

                                b.add(Opcode.DUP_X2);
                                b.add(Opcode.POP);
                                b.add(Opcode.DUP_X2);
                                b.addInvokestatic(methodReflectionLocation, "fakeCallRequired", "(Ljava/lang/reflect/Method;)Z");
                                b.add(Opcode.IFEQ);
                                JumpMarker performRealCall = JumpUtils.addJumpInstruction(b);
                                // now perform the fake call
                                b.addInvokestatic(methodReflectionLocation, "invoke", REPLACED_METHOD_DESCRIPTOR);
                                b.add(Opcode.GOTO);
                                JumpMarker finish = JumpUtils.addJumpInstruction(b);
                                performRealCall.mark();
                                b.addInvokevirtual(Method.class.getName(), METHOD_NAME, METHOD_DESCRIPTOR);
                                finish.mark();
                                it.writeByte(CodeIterator.NOP, index);
                                it.writeByte(CodeIterator.NOP, index + 1);
                                it.writeByte(CodeIterator.NOP, index + 2);
                                it.insertEx(b.get());
                            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.