Java Code Examples for com.sun.tools.javac.code.Attribute#Constant

The following examples show how to use com.sun.tools.javac.code.Attribute#Constant . 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: ClassWriter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void visitConstant(Attribute.Constant _value) {
    Object value = _value.value;
    switch (_value.type.getTag()) {
    case BYTE:
        databuf.appendByte('B');
        break;
    case CHAR:
        databuf.appendByte('C');
        break;
    case SHORT:
        databuf.appendByte('S');
        break;
    case INT:
        databuf.appendByte('I');
        break;
    case LONG:
        databuf.appendByte('J');
        break;
    case FLOAT:
        databuf.appendByte('F');
        break;
    case DOUBLE:
        databuf.appendByte('D');
        break;
    case BOOLEAN:
        databuf.appendByte('Z');
        break;
    case CLASS:
        Assert.check(value instanceof String);
        databuf.appendByte('s');
        value = names.fromString(value.toString()); // CONSTANT_Utf8
        break;
    default:
        throw new AssertionError(_value.type);
    }
    databuf.appendChar(pool.put(value));
}
 
Example 2
Source File: AnnotationValueImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        sb.append(((Integer)c.value).intValue() != 0);
    } else {
        sb.append(FieldDocImpl.constantValueExpression(c.value));
    }
}
 
Example 3
Source File: AnnotationValueImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        sb.append(((Integer)c.value).intValue() != 0);
    } else {
        sb.append(FieldDocImpl.constantValueExpression(c.value));
    }
}
 
Example 4
Source File: AnnotationValueImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        value = Boolean.valueOf(
                        ((Integer)c.value).intValue() != 0);
    } else {
        value = c.value;
    }
}
 
Example 5
Source File: AnnotationValueImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        value = Boolean.valueOf(
                        ((Integer)c.value).intValue() != 0);
    } else {
        value = c.value;
    }
}
 
Example 6
Source File: ClassReader.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void run() {
    JavaFileObject previousClassFile = currentClassFile;
    try {
        currentClassFile = classFile;
        List<Attribute.Compound> newList = deproxyCompoundList(l);
        for (Attribute.Compound attr : newList) {
            if (attr.type.tsym == syms.deprecatedType.tsym) {
                sym.flags_field |= (DEPRECATED | DEPRECATED_ANNOTATION);
                Attribute forRemoval = attr.member(names.forRemoval);
                if (forRemoval instanceof Attribute.Constant) {
                    Attribute.Constant c = (Attribute.Constant) forRemoval;
                    if (c.type == syms.booleanType && ((Integer) c.value) != 0) {
                        sym.flags_field |= DEPRECATED_REMOVAL;
                    }
                }
            }
        }
        if (sym.annotationsPendingCompletion()) {
            sym.setDeclarationAttributes(newList);
        } else {
            sym.appendAttributes(newList);
        }
    } finally {
        currentClassFile = previousClassFile;
    }
}
 
Example 7
Source File: AnnotationValueImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        value = Boolean.valueOf(
                        ((Integer)c.value).intValue() != 0);
    } else {
        value = c.value;
    }
}
 
Example 8
Source File: AnnotationValueImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        value = Boolean.valueOf(
                        ((Integer)c.value).intValue() != 0);
    } else {
        value = c.value;
    }
}
 
Example 9
Source File: AnnotationValueImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        value = Boolean.valueOf(
                        ((Integer)c.value).intValue() != 0);
    } else {
        value = c.value;
    }
}
 
Example 10
Source File: AnnotationValueImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        value = Boolean.valueOf(
                        ((Integer)c.value).intValue() != 0);
    } else {
        value = c.value;
    }
}
 
Example 11
Source File: AnnotationValueImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        sb.append(((Integer)c.value).intValue() != 0);
    } else {
        sb.append(FieldDocImpl.constantValueExpression(c.value));
    }
}
 
Example 12
Source File: AnnotationValueImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        value = Boolean.valueOf(
                        ((Integer)c.value).intValue() != 0);
    } else {
        value = c.value;
    }
}
 
Example 13
Source File: AnnotationValueImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        sb.append(((Integer)c.value).intValue() != 0);
    } else {
        sb.append(FieldDocImpl.constantValueExpression(c.value));
    }
}
 
Example 14
Source File: AnnotationValueImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    if (c.type.hasTag(BOOLEAN)) {
        // javac represents false and true as integers 0 and 1
        sb.append(((Integer)c.value).intValue() != 0);
    } else {
        sb.append(FieldDocImpl.constantValueExpression(c.value));
    }
}
 
Example 15
Source File: DPrinter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void visitConstant(Attribute.Constant a) {
    printObject("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 16
Source File: DPrinter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void visitConstant(Attribute.Constant a) {
    printObject("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 17
Source File: DPrinter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void visitConstant(Attribute.Constant a) {
    printObject("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}
 
Example 18
Source File: ClassReader.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void visitConstant(Attribute.Constant value) {
    // assert value.type == type;
    result = value;
}
 
Example 19
Source File: AnnotationProxyMaker.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void visitConstant(Attribute.Constant c) {
    value = c.getValue();
}
 
Example 20
Source File: DPrinter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void visitConstant(Attribute.Constant a) {
    printObject("value", a.value, Details.SUMMARY);
    visitAttribute(a);
}