Java Code Examples for jdk.nashorn.internal.objects.annotations.Where#INSTANCE

The following examples show how to use jdk.nashorn.internal.objects.annotations.Where#INSTANCE . 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: ScriptClassInfo.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
int getInstancePropertyCount() {
    int count = 0;
    for (final MemberInfo memInfo : members) {
        switch (memInfo.getKind()) {
            case SETTER:
            case SPECIALIZED_FUNCTION:
                // SETTER was counted when GETTER was encountered.
                // SPECIALIZED_FUNCTION was counted as FUNCTION already.
                continue;
        }

        if (memInfo.getWhere() == Where.INSTANCE) {
            count++;
        }
    }
    return count;
}
 
Example 2
Source File: ScriptClassInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
int getInstancePropertyCount() {
    int count = 0;
    for (final MemberInfo memInfo : members) {
        switch (memInfo.getKind()) {
            case SETTER:
            case SPECIALIZED_FUNCTION:
                // SETTER was counted when GETTER was encountered.
                // SPECIALIZED_FUNCTION was counted as FUNCTION already.
                continue;
        }

        if (memInfo.getWhere() == Where.INSTANCE) {
            count++;
        }
    }
    return count;
}
 
Example 3
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 4
Source File: ScriptClassInfo.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
int getInstancePropertyCount() {
    int count = 0;
    for (final MemberInfo memInfo : members) {
        if (memInfo.getWhere() == Where.INSTANCE) {
            count++;
        }
    }
    return count;
}
 
Example 5
Source File: ScriptClassInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
int getInstancePropertyCount() {
    int count = 0;
    for (final MemberInfo memInfo : members) {
        if (memInfo.getWhere() == Where.INSTANCE) {
            count++;
        }
    }
    return count;
}
 
Example 6
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 7
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 8
Source File: MemberInfo.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceFunction() {
    return kind == Kind.FUNCTION && where == Where.INSTANCE;
}
 
Example 9
Source File: MemberInfo.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceGetter() {
    return kind == Kind.GETTER && where == Where.INSTANCE;
}
 
Example 10
Source File: MemberInfo.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceFunction() {
    return kind == Kind.FUNCTION && where == Where.INSTANCE;
}
 
Example 11
Source File: MemberInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceProperty() {
    return kind == Kind.PROPERTY && where == Where.INSTANCE;
}
 
Example 12
Source File: MemberInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceGetter() {
    return kind == Kind.GETTER && where == Where.INSTANCE;
}
 
Example 13
Source File: MemberInfo.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceGetter() {
    return kind == Kind.GETTER && where == Where.INSTANCE;
}
 
Example 14
Source File: MemberInfo.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceFunction() {
    return kind == Kind.FUNCTION && where == Where.INSTANCE;
}
 
Example 15
Source File: MemberInfo.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceProperty() {
    return kind == Kind.PROPERTY && where == Where.INSTANCE;
}
 
Example 16
Source File: MemberInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
boolean isInstanceProperty() {
    return kind == Kind.PROPERTY && where == Where.INSTANCE;
}
 
Example 17
Source File: MemberInfo.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check whether this MemberInfo is a getter that resides in the instance
 *
 * @return true if instance setter
 */
boolean isInstanceSetter() {
    return kind == Kind.SETTER && where == Where.INSTANCE;
}
 
Example 18
Source File: MemberInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check whether this MemberInfo is a getter that resides in the instance
 *
 * @return true if instance setter
 */
boolean isInstanceSetter() {
    return kind == Kind.SETTER && where == Where.INSTANCE;
}
 
Example 19
Source File: MemberInfo.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check whether this MemberInfo is a getter that resides in the instance
 *
 * @return true if instance setter
 */
boolean isInstanceSetter() {
    return kind == Kind.SETTER && where == Where.INSTANCE;
}
 
Example 20
Source File: MemberInfo.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check whether this MemberInfo is a getter that resides in the instance
 *
 * @return true if instance setter
 */
boolean isInstanceSetter() {
    return kind == Kind.SETTER && where == Where.INSTANCE;
}