Package org.jnode.vm.classmgr

Examples of org.jnode.vm.classmgr.VmMethod


     */
    public boolean visit(Object object) {
        final int color = VmMagic.getObjectColor(object);
        if (color == GC_YELLOW) {
            final VmClassType type = VmMagic.getObjectType(object);
            final VmMethod fm = type.getFinalizeMethod();
            if (fm != null) {
                try {
                    helper.invokeFinalizer(fm, object);
                } catch (Throwable ex) {
                    // Ignore error in finalize
View Full Code Here


    private static VmByteCode loadByteCode(String className)
        throws MalformedURLException, ClassNotFoundException {
        VmSystemClassLoader vmc = new VmSystemClassLoader(new File(".").toURL(), new VmX86Architecture32());
        VmType type = vmc.loadClass(className, true);
        VmMethod arithMethod = null;
        int nMethods = type.getNoDeclaredMethods();
        for (int i = 0; i < nMethods; i += 1) {
            VmMethod method = type.getDeclaredMethod(i);
            if ("const1".equals(method.getName())) {
                arithMethod = method;
                break;
            }
        }
        VmByteCode code = arithMethod.getBytecode();
View Full Code Here

        VmType old_type = VmType.fromClass(oldClass);
        VmClassLoader loader = VmType.fromClass(oldClass).getLoader();
        ProtectionDomain pd = oldClass.getProtectionDomain();
        VmType new_type = ClassDecoder.defineClass(name, ByteBuffer.wrap(classData), false, loader, pd);
        for(int i = 0; i < old_type.getNoDeclaredMethods(); i++){
            VmMethod old_method = old_type.getDeclaredMethod(i);
            if (!old_method.isNative()) {
                VmMethod new_method = new_type.getDeclaredMethod(old_method.getName(), old_method.getSignature());
                if(new_method == null) continue;

                old_method.setBytecode(new_method.getBytecode());
                old_method.resetOptLevel();
                old_method.recompile();
                System.out.println("Redefined method: " + old_method.getFullName());
            }
        }
View Full Code Here

    private static <T> Method[] getDeclaredMethods0(Class<T> instance, boolean publicOnly) {
        final VmType<T> vmClass = getLinkedVmClass(instance);
        final int cnt = vmClass.getNoDeclaredMethods();
        int max = 0;
        for (int i = 0; i < cnt; i++) {
            VmMethod method = vmClass.getDeclaredMethod(i);
            if (!method.isConstructor() &&
                    (!publicOnly || method.isPublic())) {
                max++;
            }
        }
        final Method[] list = new Method[max];
        max = 0;
        for (int i = 0; i < cnt; i++) {
            VmMethod vmMethod = vmClass.getDeclaredMethod(i);
            if (!vmMethod.isConstructor() &&
                    (!publicOnly || vmMethod.isPublic())) {
                list[max++] = (Method) vmMethod.asMember();
            }
        }
        return list;
    }
View Full Code Here

            }
        }
        Constructor<?>[] list = new Constructor[max];
        max = 0;
        for (int i = 0; i < cnt; i++) {
            VmMethod vmMethod = vmClass.getDeclaredMethod(i);
            if (vmMethod.isConstructor()) {
                list[max++] = (Constructor<?>) vmMethod.asMember();
            }
        }
        return list;
    }
View Full Code Here

     * @see sun.reflect.NativeMethodAccessorImpl#invoke0(java.lang.reflect.Method, java.lang.Object, java.lang.Object[])
     */
    private static Object invoke0(Method arg1, Object arg2, Object[] arg3) throws IllegalArgumentException,
        InvocationTargetException {
        VmType<?> vmt = VmType.fromClass((Class<?>) arg1.getDeclaringClass());
        VmMethod vmm = vmt.getDeclaredMethod(arg1.getSlot());
        return VmReflection.invoke(vmm, arg2, arg3);
    }
View Full Code Here

     */
    private static Object newInstance0(Constructor<?> arg1, Object[] arg2) throws InstantiationException,
               IllegalArgumentException,
        InvocationTargetException{
        VmType<?> vmt = VmType.fromClass(arg1.getDeclaringClass());
        VmMethod vmm = vmt.getDeclaredMethod(arg1.getSlot());
        try {
            return VmReflection.newInstance(vmm, arg2);
        } catch (IllegalAccessException iae)  { //todo| this should not happen, fix VmReflection.newInstance() to not
                                                //todo| throw this exception
            throw new InstantiationException("Unexpected IllegalAccessException");
View Full Code Here

    /**
     * @see java.io.ObjectStreamClass#hasStaticInitializer(java.lang.Class)
     */
    private static boolean hasStaticInitializer(Class<?> clazz) {
        VmType<?> vmt = VmType.fromClass(clazz);
        VmMethod met = vmt.getDeclaredMethod("<clinit>", "()V");
        return met != null && met.isStatic();
    }
View Full Code Here

    private static StackTraceElement getStackTraceElement(Throwable instance, int index) {
        final VmStackFrame frame = (VmStackFrame) ((Object[]) ObjectReference.fromObject(instance).toAddress().add(BACKTRACE_OFFSET).
                loadObjectReference().toObject())[index];
        final String location = frame.getLocationInfo();
        final int lineNumber = "?".equals(location) ? -1 : Integer.parseInt(location);
        final VmMethod method = frame.getMethod();
        final VmType<?> vmClass = (method == null) ? null : method.getDeclaringClass();
        final String fname = (vmClass == null) ? null : vmClass.getSourceFile();
        final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName();
        final String mname = (method == null) ? "<unknown method>" : method.getName();
        return new StackTraceElement(cname, mname, fname, method == null || method.isNative() ? -2 : lineNumber);
    }
View Full Code Here

        final StackTraceElement[] trace = new StackTraceElement[length];
        for(int i = length; i-- > 0; ){
            final VmStackFrame frame = vm_trace[i];
            final String location = frame.getLocationInfo();
            final int lineNumber = "?".equals(location) ? -1 : Integer.parseInt(location);
            final VmMethod method = frame.getMethod();
            final VmType<?> vmClass = (method == null) ? null : method.getDeclaringClass();
            final String fname = (vmClass == null) ? null : vmClass.getSourceFile();
            final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName();
            final String mname = (method == null) ? "<unknown method>" : method.getName();
            trace[i] = new StackTraceElement(cname, mname, fname, method == null || method.isNative() ? -2 : lineNumber);
        }
        return trace;
    }
View Full Code Here

TOP

Related Classes of org.jnode.vm.classmgr.VmMethod

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.