Java Code Examples for jdk.nashorn.internal.objects.annotations.Where#valueOf()

The following examples show how to use jdk.nashorn.internal.objects.annotations.Where#valueOf() . 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: ScriptClassInfoCollector.java    From TencentKona-8 with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not supplied,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
Example 2
Source File: ScriptClassInfoCollector.java    From jdk8u60 with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not suppiled,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
Example 3
Source File: ScriptClassInfoCollector.java    From openjdk-jdk8u with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not supplied,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
Example 4
Source File: ScriptClassInfoCollector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not supplied,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
Example 5
Source File: ScriptClassInfoCollector.java    From hottub with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not supplied,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
Example 6
Source File: ScriptClassInfoCollector.java    From openjdk-8-source with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not suppiled,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
Example 7
Source File: ScriptClassInfoCollector.java    From openjdk-8 with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not suppiled,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
Example 8
Source File: ScriptClassInfoCollector.java    From jdk8u_nashorn with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not supplied,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}
 
Example 9
Source File: ScriptClassInfoCollector.java    From nashorn with GNU General Public License v2.0 4 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 FieldVisitor delegateFV = super.visitField(fieldAccess, fieldName, fieldDesc, signature, value);

    return new FieldVisitor(Opcodes.ASM4, delegateFV) {
        @Override
        public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
            final AnnotationVisitor delegateAV = super.visitAnnotation(descriptor, visible);

            if (ScriptClassInfo.PROPERTY_ANNO_DESC.equals(descriptor)) {
                final MemberInfo memInfo = new MemberInfo();

                memInfo.setKind(Kind.PROPERTY);
                memInfo.setJavaName(fieldName);
                memInfo.setJavaDesc(fieldDesc);
                memInfo.setJavaAccess(fieldAccess);

                if ((fieldAccess & Opcodes.ACC_STATIC) != 0) {
                    memInfo.setValue(value);
                }

                addScriptMember(memInfo);

                return new AnnotationVisitor(Opcodes.ASM4, delegateAV) {
                    // These could be "null" if values are not suppiled,
                    // in which case we have to use the default values.
                    private String  name;
                    private Integer attributes;
                    private String  clazz = "";
                    private Where   where;

                    @Override
                    public void visit(final String annotationName, final Object annotationValue) {
                        switch (annotationName) {
                        case "name":
                            this.name = (String) annotationValue;
                            break;
                        case "attributes":
                            this.attributes = (Integer) annotationValue;
                            break;
                        case "clazz":
                            this.clazz = (annotationValue == null) ? "" : annotationValue.toString();
                            break;
                        default:
                            break;
                        }
                        super.visit(annotationName, annotationValue);
                    }

                    @Override
                    public void visitEnum(final String enumName, final String desc, final String enumValue) {
                        if ("where".equals(enumName) && WHERE_ENUM_DESC.equals(desc)) {
                            this.where = Where.valueOf(enumValue);
                        }
                        super.visitEnum(enumName, desc, enumValue);
                    }

                    @Override
                    public void visitEnd() {
                        super.visitEnd();
                        memInfo.setName(name == null ? fieldName : name);
                        memInfo.setAttributes(attributes == null
                                ? MemberInfo.DEFAULT_ATTRIBUTES : attributes);
                        clazz = clazz.replace('.', '/');
                        memInfo.setInitClass(clazz);
                        memInfo.setWhere(where == null? Where.INSTANCE : where);
                    }
                };
            }

            return delegateAV;
        }
    };
}