jdk.nashorn.internal.tools.nasgen.MemberInfo.Kind Java Examples

The following examples show how to use jdk.nashorn.internal.tools.nasgen.MemberInfo.Kind. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassGenerator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #2
Source File: ClassGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #3
Source File: ClassGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #4
Source File: ClassGenerator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #5
Source File: ClassGenerator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #6
Source File: ClassGenerator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #7
Source File: ClassGenerator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #8
Source File: ClassGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #9
Source File: ClassGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #10
Source File: ClassGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #11
Source File: ClassGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #12
Source File: ClassGenerator.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #13
Source File: ClassGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #14
Source File: ClassGenerator.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #15
Source File: ClassGenerator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #16
Source File: ClassGenerator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #17
Source File: ClassGenerator.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #18
Source File: ClassGenerator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #19
Source File: ClassGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static void addGetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = GETTER_PREFIX + memInfo.getJavaName();
    final String desc = getterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.getStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.getField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnValue();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #20
Source File: ClassGenerator.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
static void addSetter(final ClassVisitor cv, final String owner, final MemberInfo memInfo) {
    final int access = ACC_PUBLIC;
    final String name = SETTER_PREFIX + memInfo.getJavaName();
    final String desc = setterDesc(memInfo);
    final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
    final MethodGenerator mi = new MethodGenerator(mv, access, name, desc);
    mi.visitCode();
    if (memInfo.isStatic() && memInfo.getKind() == Kind.PROPERTY) {
        mi.loadLocal(1);
        mi.putStatic(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    } else {
        mi.loadLocal(0);
        mi.loadLocal(1);
        mi.putField(owner, memInfo.getJavaName(), memInfo.getJavaDesc());
    }
    mi.returnVoid();
    mi.computeMaxs();
    mi.visitEnd();
}
 
Example #21
Source File: ScriptClassInstrumentor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName,
        final String fieldDesc, final String signature, final Object value) {
    final MemberInfo memInfo = scriptClassInfo.find(fieldName, fieldDesc, fieldAccess);
    if (memInfo != null && memInfo.getKind() == Kind.PROPERTY &&
            memInfo.getWhere() != Where.INSTANCE && !memInfo.isStaticFinal()) {
        // non-instance @Property fields - these have to go elsewhere unless 'static final'
        return null;
    }

    final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc,
            signature, value);
    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
            if (ScriptClassInfo.annotations.containsKey(desc)) {
                // ignore script field annotations
                return null;
            }

            return fv.visitAnnotation(desc, visible);
        }

        @Override
        public void visitAttribute(final Attribute attr) {
            fv.visitAttribute(attr);
        }

        @Override
        public void visitEnd() {
            fv.visitEnd();
        }
    };
}
 
Example #22
Source File: ScriptClassInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
MemberInfo getConstructor() {
    for (final MemberInfo memInfo : members) {
        if (memInfo.getKind() == Kind.CONSTRUCTOR) {
            return memInfo;
        }
    }
    return null;
}
 
Example #23
Source File: ScriptClassInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
List<MemberInfo> findSpecializations(final String methodName) {
    final List<MemberInfo> res = new LinkedList<>();
    for (final MemberInfo memInfo : members) {
        if (memInfo.getName().equals(methodName) &&
            memInfo.getKind() == Kind.SPECIALIZED_FUNCTION) {
            res.add(memInfo);
        }
    }
    return res;
}
 
Example #24
Source File: ScriptClassInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
List<MemberInfo> getSpecializedConstructors() {
    final List<MemberInfo> res = new LinkedList<>();
    for (final MemberInfo memInfo : members) {
        if (memInfo.getKind() == Kind.SPECIALIZED_CONSTRUCTOR) {
            res.add(memInfo);
        }
    }
    return res;
}
 
Example #25
Source File: ScriptClassInstrumentor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName,
        final String fieldDesc, final String signature, final Object value) {
    final MemberInfo memInfo = scriptClassInfo.find(fieldName, fieldDesc, fieldAccess);
    if (memInfo != null && memInfo.getKind() == Kind.PROPERTY &&
            memInfo.getWhere() != Where.INSTANCE && !memInfo.isStaticFinal()) {
        // non-instance @Property fields - these have to go elsewhere unless 'static final'
        return null;
    }

    final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc,
            signature, value);
    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
            if (ScriptClassInfo.annotations.containsKey(desc)) {
                // ignore script field annotations
                return null;
            }

            return fv.visitAnnotation(desc, visible);
        }

        @Override
        public void visitAttribute(final Attribute attr) {
            fv.visitAttribute(attr);
        }

        @Override
        public void visitEnd() {
            fv.visitEnd();
        }
    };
}
 
Example #26
Source File: ScriptClassInstrumentor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName,
        final String fieldDesc, final String signature, final Object value) {
    final MemberInfo memInfo = scriptClassInfo.find(fieldName, fieldDesc, fieldAccess);
    if (memInfo != null && memInfo.getKind() == Kind.PROPERTY &&
            memInfo.getWhere() != Where.INSTANCE && !memInfo.isStaticFinal()) {
        // non-instance @Property fields - these have to go elsewhere unless 'static final'
        return null;
    }

    final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc,
            signature, value);
    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
            if (ScriptClassInfo.annotations.containsKey(desc)) {
                // ignore script field annotations
                return null;
            }

            return fv.visitAnnotation(desc, visible);
        }

        @Override
        public void visitAttribute(final Attribute attr) {
            fv.visitAttribute(attr);
        }

        @Override
        public void visitEnd() {
            fv.visitEnd();
        }
    };
}
 
Example #27
Source File: ScriptClassInfo.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
List<MemberInfo> getSpecializedConstructors() {
    final List<MemberInfo> res = new LinkedList<>();
    for (final MemberInfo memInfo : members) {
        if (memInfo.getKind() == Kind.SPECIALIZED_CONSTRUCTOR) {
            res.add(memInfo);
        }
    }
    return res;
}
 
Example #28
Source File: ScriptClassInstrumentor.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public FieldVisitor visitField(final int fieldAccess, final String fieldName,
        final String fieldDesc, final String signature, final Object value) {
    final MemberInfo memInfo = scriptClassInfo.find(fieldName, fieldDesc, fieldAccess);
    if (memInfo != null && memInfo.getKind() == Kind.PROPERTY &&
            memInfo.getWhere() != Where.INSTANCE && !memInfo.isStaticFinal()) {
        // non-instance @Property fields - these have to go elsewhere unless 'static final'
        return null;
    }

    final FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc,
            signature, value);
    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
            if (ScriptClassInfo.annotations.containsKey(desc)) {
                // ignore script field annotations
                return null;
            }

            return fv.visitAnnotation(desc, visible);
        }

        @Override
        public void visitAttribute(final Attribute attr) {
            fv.visitAttribute(attr);
        }

        @Override
        public void visitEnd() {
            fv.visitEnd();
        }
    };
}
 
Example #29
Source File: ScriptClassInfo.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
MemberInfo getConstructor() {
    for (final MemberInfo memInfo : members) {
        if (memInfo.getKind() == Kind.CONSTRUCTOR) {
            return memInfo;
        }
    }
    return null;
}
 
Example #30
Source File: ScriptClassInfo.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
List<MemberInfo> findSpecializations(final String methodName) {
    final List<MemberInfo> res = new LinkedList<>();
    for (final MemberInfo memInfo : members) {
        if (memInfo.getName().equals(methodName) &&
            memInfo.getKind() == Kind.SPECIALIZED_FUNCTION) {
            res.add(memInfo);
        }
    }
    return Collections.unmodifiableList(res);
}