当前位置: 首页>>代码示例>>Java>>正文


Java Version类代码示例

本文整理汇总了Java中com.sun.tools.javac.jvm.ClassFile.Version的典型用法代码示例。如果您正苦于以下问题:Java Version类的具体用法?Java Version怎么用?Java Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Version类属于com.sun.tools.javac.jvm.ClassFile包,在下文中一共展示了Version类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NBClassReader

import com.sun.tools.javac.jvm.ClassFile.Version; //导入依赖的package包/类
public NBClassReader(Context context) {
    super(context);

    names = Names.instance(context);
    nbNames = NBNames.instance(context);

    NBAttributeReader[] readers = {
        new NBAttributeReader(nbNames._org_netbeans_EnclosingMethod, Version.V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
            public void read(Symbol sym, int attrLen) {
                int newbp = bp + attrLen;
                readEnclosingMethodAttr(sym);
                bp = newbp;
            }
        },
    };

    for (NBAttributeReader r: readers)
        attributeReaders.put(r.getName(), r);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:NBClassReader.java

示例2: readClassBuffer

import com.sun.tools.javac.jvm.ClassFile.Version; //导入依赖的package包/类
/** Read a class definition from the bytes in buf.
 */
private void readClassBuffer(ClassSymbol c) throws IOException {
    int magic = nextInt();
    if (magic != JAVA_MAGIC)
        throw badClassFile("illegal.start.of.class.file");

    minorVersion = nextChar();
    majorVersion = nextChar();
    int maxMajor = 53; // Version.MAX().major;  //******* TEMPORARY *******
    int maxMinor = Version.MAX().minor;
    if (majorVersion > maxMajor ||
        majorVersion * 1000 + minorVersion <
        Version.MIN().major * 1000 + Version.MIN().minor) {
        if (majorVersion == (maxMajor + 1))
            log.warning(Warnings.BigMajorVersion(currentClassFile,
                                                 majorVersion,
                                                 maxMajor));
        else
            throw badClassFile("wrong.version",
                               Integer.toString(majorVersion),
                               Integer.toString(minorVersion),
                               Integer.toString(maxMajor),
                               Integer.toString(maxMinor));
    }

    indexPool();
    if (signatureBuffer.length < bp) {
        int ns = Integer.highestOneBit(bp) << 1;
        signatureBuffer = new byte[ns];
    }
    readClass(c);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ClassReader.java

示例3: readClassBuffer

import com.sun.tools.javac.jvm.ClassFile.Version; //导入依赖的package包/类
/** Read a class definition from the bytes in buf.
 */
private void readClassBuffer(ClassSymbol c) throws IOException {
    int magic = nextInt();
    if (magic != JAVA_MAGIC)
        throw badClassFile("illegal.start.of.class.file");

    minorVersion = nextChar();
    majorVersion = nextChar();
    int maxMajor = Version.MAX().major;
    int maxMinor = Version.MAX().minor;
    if (majorVersion > maxMajor ||
        majorVersion * 1000 + minorVersion <
        Version.MIN().major * 1000 + Version.MIN().minor) {
        if (majorVersion == (maxMajor + 1))
            log.warning("big.major.version",
                        currentClassFile,
                        majorVersion,
                        maxMajor);
        else
            throw badClassFile("wrong.version",
                               Integer.toString(majorVersion),
                               Integer.toString(minorVersion),
                               Integer.toString(maxMajor),
                               Integer.toString(maxMinor));
    }

    indexPool();
    if (signatureBuffer.length < bp) {
        int ns = Integer.highestOneBit(bp) << 1;
        signatureBuffer = new byte[ns];
    }
    readClass(c);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:35,代码来源:ClassReader.java

示例4: NBAttributeReader

import com.sun.tools.javac.jvm.ClassFile.Version; //导入依赖的package包/类
private NBAttributeReader(Name name, Version version, Set<AttributeKind> kinds) {
    super(name, version, kinds);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:NBClassReader.java

示例5: AttributeReader

import com.sun.tools.javac.jvm.ClassFile.Version; //导入依赖的package包/类
protected AttributeReader(Name name, ClassFile.Version version, Set<AttributeKind> kinds) {
    this.name = name;
    this.version = version;
    this.kinds = kinds;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:ClassReader.java

示例6: readMethod

import com.sun.tools.javac.jvm.ClassFile.Version; //导入依赖的package包/类
/** Read a method.
 */
MethodSymbol readMethod() {
    long flags = adjustMethodFlags(nextChar());
    Name name = readName(nextChar());
    Type type = readType(nextChar());
    if (currentOwner.isInterface() &&
            (flags & ABSTRACT) == 0 && !name.equals(names.clinit)) {
        if (majorVersion > Version.V52.major ||
                (majorVersion == Version.V52.major && minorVersion >= Version.V52.minor)) {
            if ((flags & (STATIC | PRIVATE)) == 0) {
                currentOwner.flags_field |= DEFAULT;
                flags |= DEFAULT | ABSTRACT;
            }
        } else {
            //protect against ill-formed classfiles
            throw badClassFile((flags & STATIC) == 0 ? "invalid.default.interface" : "invalid.static.interface",
                               Integer.toString(majorVersion),
                               Integer.toString(minorVersion));
        }
    }
    if (name == names.init && currentOwner.hasOuterInstance()) {
        // Sometimes anonymous classes don't have an outer
        // instance, however, there is no reliable way to tell so
        // we never strip this$n
        // ditto for local classes. Local classes that have an enclosing method set
        // won't pass the "hasOuterInstance" check above, but those that don't have an
        // enclosing method (i.e. from initializers) will pass that check.
        boolean local = !currentOwner.owner.members().includes(currentOwner, LookupKind.NON_RECURSIVE);
        if (!currentOwner.name.isEmpty() && !local)
            type = new MethodType(adjustMethodParams(flags, type.getParameterTypes()),
                                  type.getReturnType(),
                                  type.getThrownTypes(),
                                  syms.methodClass);
    }
    MethodSymbol m = new MethodSymbol(flags, name, type, currentOwner);
    if (types.isSignaturePolymorphic(m)) {
        m.flags_field |= SIGNATURE_POLYMORPHIC;
    }
    if (saveParameterNames)
        initParameterNames(m);
    Symbol prevOwner = currentOwner;
    currentOwner = m;
    try {
        readMemberAttrs(m);
    } finally {
        currentOwner = prevOwner;
    }
    if (saveParameterNames)
        setParameterNames(m, type);

    if ((flags & VARARGS) != 0) {
        final Type last = type.getParameterTypes().last();
        if (last == null || !last.hasTag(ARRAY)) {
            m.flags_field &= ~VARARGS;
            throw badClassFile("malformed.vararg.method", m);
        }
    }

    return m;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:62,代码来源:ClassReader.java

示例7: readClass

import com.sun.tools.javac.jvm.ClassFile.Version; //导入依赖的package包/类
/** Read contents of a given class symbol `c'. Both external and internal
 *  versions of an inner class are read.
 */
void readClass(ClassSymbol c) {
    ClassType ct = (ClassType)c.type;

    // allocate scope for members
    c.members_field = WriteableScope.create(c);

    // prepare type variable table
    typevars = typevars.dup(currentOwner);
    if (ct.getEnclosingType().hasTag(CLASS))
        enterTypevars(c.owner, ct.getEnclosingType());

    // read flags, or skip if this is an inner class
    long f = nextChar();
    long flags = adjustClassFlags(f);
    if ((flags & MODULE) == 0) {
        if (c.owner.kind == PCK) c.flags_field = flags;
        // read own class name and check that it matches
        currentModule = c.packge().modle;
        ClassSymbol self = readClassSymbol(nextChar());
        if (c != self) {
            throw badClassFile("class.file.wrong.class",
                               self.flatname);
        }
    } else {
        if (majorVersion < Version.V53.major) {
            throw badClassFile("anachronistic.module.info",
                    Integer.toString(majorVersion),
                    Integer.toString(minorVersion));
        }
        c.flags_field = flags;
        currentModule = (ModuleSymbol) c.owner;
        int this_class = nextChar();
        // temp, no check on this_class
    }

    // class attributes must be read before class
    // skip ahead to read class attributes
    int startbp = bp;
    nextChar();
    char interfaceCount = nextChar();
    bp += interfaceCount * 2;
    char fieldCount = nextChar();
    for (int i = 0; i < fieldCount; i++) skipMember();
    char methodCount = nextChar();
    for (int i = 0; i < methodCount; i++) skipMember();
    readClassAttrs(c);

    if (readAllOfClassFile) {
        for (int i = 1; i < poolObj.length; i++) readPool(i);
        c.pool = new Pool(poolObj.length, poolObj, types);
    }

    // reset and read rest of classinfo
    bp = startbp;
    int n = nextChar();
    if ((flags & MODULE) != 0 && n > 0) {
        throw badClassFile("module.info.invalid.super.class");
    }
    if (ct.supertype_field == null)
        ct.supertype_field = (n == 0)
            ? Type.noType
            : readClassSymbol(n).erasure(types);
    n = nextChar();
    List<Type> is = List.nil();
    for (int i = 0; i < n; i++) {
        Type _inter = readClassSymbol(nextChar()).erasure(types);
        is = is.prepend(_inter);
    }
    if (ct.interfaces_field == null)
        ct.interfaces_field = is.reverse();

    Assert.check(fieldCount == nextChar());
    for (int i = 0; i < fieldCount; i++) enterMember(c, readField());
    Assert.check(methodCount == nextChar());
    for (int i = 0; i < methodCount; i++) enterMember(c, readMethod());

    typevars = typevars.leave();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:82,代码来源:ClassReader.java

示例8: readMethod

import com.sun.tools.javac.jvm.ClassFile.Version; //导入依赖的package包/类
/** Read a method.
 */
MethodSymbol readMethod() {
    long flags = adjustMethodFlags(nextChar());
    Name name = readName(nextChar());
    Type type = readType(nextChar());
    if (currentOwner.isInterface() &&
            (flags & ABSTRACT) == 0 && !name.equals(names.clinit)) {
        if (majorVersion > Version.V52.major ||
                (majorVersion == Version.V52.major && minorVersion >= Version.V52.minor)) {
            if ((flags & STATIC) == 0) {
                currentOwner.flags_field |= DEFAULT;
                flags |= DEFAULT | ABSTRACT;
            }
        } else {
            //protect against ill-formed classfiles
            throw badClassFile((flags & STATIC) == 0 ? "invalid.default.interface" : "invalid.static.interface",
                               Integer.toString(majorVersion),
                               Integer.toString(minorVersion));
        }
    }
    if (name == names.init && currentOwner.hasOuterInstance()) {
        // Sometimes anonymous classes don't have an outer
        // instance, however, there is no reliable way to tell so
        // we never strip this$n
        if (!currentOwner.name.isEmpty())
            type = new MethodType(adjustMethodParams(flags, type.getParameterTypes()),
                                  type.getReturnType(),
                                  type.getThrownTypes(),
                                  syms.methodClass);
    }
    MethodSymbol m = new MethodSymbol(flags, name, type, currentOwner);
    if (types.isSignaturePolymorphic(m)) {
        m.flags_field |= SIGNATURE_POLYMORPHIC;
    }
    if (saveParameterNames)
        initParameterNames(m);
    Symbol prevOwner = currentOwner;
    currentOwner = m;
    try {
        readMemberAttrs(m);
    } finally {
        currentOwner = prevOwner;
    }
    if (saveParameterNames)
        setParameterNames(m, type);

    if ((flags & VARARGS) != 0) {
        final Type last = type.getParameterTypes().last();
        if (last == null || !last.hasTag(ARRAY)) {
            m.flags_field &= ~VARARGS;
            throw badClassFile("malformed.vararg.method", m);
        }
    }

    return m;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:58,代码来源:ClassReader.java


注:本文中的com.sun.tools.javac.jvm.ClassFile.Version类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。