Package alt.jiapi.reflect

Examples of alt.jiapi.reflect.Loader


    /**
     * Creates a context.
     */
    public InstrumentationContext() {
        loader = new Loader();
    }
View Full Code Here


        InstrumentationContext ctx = new InstrumentationContext();
        Instrumentor createMethod =
            new CreateMethodInstrumentor(Modifier.PUBLIC + Modifier.STATIC,
                                         "bar");

        Loader loader = ctx.getLoader();
        JiapiClass sourceClass = loader.loadClass("test.Bar");
        JiapiMethod sourceMethod =
            sourceClass.getDeclaredMethod("bar", new String[0]);

        Instrumentor copyMethod
            = new CopyInstrumentor(sourceMethod.getInstructionList());
View Full Code Here

        this.value = value;

        Runtime.setFieldValue(fieldName, value);

        try {
            Loader l = new Loader();
            JiapiClass jc = l.loadClass("alt.jiapi.Runtime");
//             Class []params = new Class[] { String.class };
//             getFieldValue = Runtime.class.getMethod("getFieldValue", params);
            getFieldValue = jc.getDeclaredMethod("getFieldValue", new String[] {"java.lang.String"});
        }
        catch (Exception e) {
View Full Code Here

        new HelloWorldBuilder();
    }

    public HelloWorldBuilder() throws Exception {
        // Load the target class:
        Loader loader = new Loader();
        JiapiClass clazz = loader.loadClass("samples.reflect.hello1.Test");
        System.out.println(clazz);

        // Add an empty method for a clazz. The method signature must
        // match the method from HelloWorld interface, the only difference
        // is that we want to implement the method now so it can't be abstract.
View Full Code Here

        // to implementation of InstrumentationDescriptor
        id.addExclusionRule("test.MethodCallTest");
        id.addChain(chain);

        ctx.addInstrumentationDescriptor(id);
        Loader loader = ctx.getLoader();
        ClassLoader cl = InstrumentingClassLoader.createClassLoader(ctx);

        this.clazz = cl.loadClass(className);
    }
View Full Code Here

    }

    protected JiapiClass getEventProducer() {
        JiapiClass jc = null;
        try {
            jc = new Loader().loadClass(ep.getClass().getName());
        }
        catch(Exception e) {
            System.out.println("ERROR: " + e);
        }
View Full Code Here

        private Rule rule;
       
        HSInstrumentor(HotSpotAdvice advice, byte[] hotSpots, String resolution) {
            try {
                this.rule = new Rule(resolution);
                Loader l = new Loader();
                log.debug("Loading advice " + advice.getClass().getName());
                JiapiClass clazz = l.loadClass(advice.getClass().getName());

                log.debug("Getting advice() method ");
                this.adviceMethod =
                    clazz.getDeclaredMethod("advice", new String[0]);
                this.hotSpots = hotSpots;
View Full Code Here

            else {
                log.error("Invalid Hook method: " + hookMethod);
            }
        }

        Loader l = new Loader();
        try {
            JiapiClass hClass = l.loadClass(hookClass.getName());
            Class[] hpTypes = hookMethod.getParameterTypes();
            String[] pTypes = new String[hpTypes.length];
           
            for (int i = 0; i < pTypes.length; i++) {
                pTypes[i] = hpTypes[i].getName();
View Full Code Here

        InstructionFactory factory = il.getInstructionFactory();
        String rType = ins.getReturnType();

        if ("int".equals(rType)) {
            try {
                JiapiClass jc = new Loader().loadClass("java.lang.Integer");
                JiapiMethod jm =
                    jc.getDeclaredMethod("intValue", new String[0]);

                il.add(factory.cast("java.lang.Integer"));
                il.add(factory.invoke(jm));
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
        else if ("long".equals(rType)) {
            try {
                JiapiClass jc = new Loader().loadClass("java.lang.Long");
                JiapiMethod jm =
                    jc.getDeclaredMethod("longValue", new String[0]);

                il.add(factory.cast("java.lang.Long"));
                il.add(factory.invoke(jm));
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
        else if ("char".equals(rType)) {
            try {
                JiapiClass jc = new Loader().loadClass("java.lang.Character");
                JiapiMethod jm =
                    jc.getDeclaredMethod("charValue", new String[0]);

                il.add(factory.cast("java.lang.Character"));
                il.add(factory.invoke(jm));
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
        else if ("boolean".equals(rType)) {
            try {
                JiapiClass jc = new Loader().loadClass("java.lang.Boolean");
                JiapiMethod jm =
                    jc.getDeclaredMethod("booleanValue", new String[0]);

                il.add(factory.cast("java.lang.Boolean"));
                il.add(factory.invoke(jm));
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
        else if ("byte".equals(rType)) {
            try {
                JiapiClass jc = new Loader().loadClass("java.lang.Byte");
                JiapiMethod jm =
                    jc.getDeclaredMethod("byteValue", new String[0]);

                il.add(factory.cast("java.lang.Byte"));
                il.add(factory.invoke(jm));
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
        else if ("float".equals(rType)) {
            try {
                JiapiClass jc = new Loader().loadClass("java.lang.Float");
                JiapiMethod jm =
                    jc.getDeclaredMethod("floatValue", new String[0]);

                il.add(factory.cast("java.lang.Float"));
                il.add(factory.invoke(jm));
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
        else if ("double".equals(rType)) {
            try {
                JiapiClass jc = new Loader().loadClass("java.lang.Double");
                JiapiMethod jm =
                    jc.getDeclaredMethod("doubleValue", new String[0]);

                il.add(factory.cast("java.lang.Double"));
                il.add(factory.invoke(jm));
View Full Code Here

    }


    private boolean isPublicField(FieldAccess fa) {
        try {
            JiapiClass jc = new Loader().loadClass(fa.getClassName());
            JiapiField jf = jc.getField(fa.getName());

            return Modifier.isPublic(jf.getModifiers());
        }
        catch(Exception e) {
View Full Code Here

TOP

Related Classes of alt.jiapi.reflect.Loader

Copyright © 2018 www.massapicom. 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.