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


Java TypeAnnotation.Position方法代码示例

本文整理汇总了Java中com.sun.tools.classfile.TypeAnnotation.Position方法的典型用法代码示例。如果您正苦于以下问题:Java TypeAnnotation.Position方法的具体用法?Java TypeAnnotation.Position怎么用?Java TypeAnnotation.Position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.classfile.TypeAnnotation的用法示例。


在下文中一共展示了TypeAnnotation.Position方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compare

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
public static boolean compare(Map<String, TypeAnnotation.Position> expectedAnnos,
        List<TypeAnnotation> actualAnnos, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    if (actualAnnos.size() != expectedAnnos.size()) {
        throw new ComparisionException("Wrong number of annotations",
                expectedAnnos,
                actualAnnos);
    }

    for (Map.Entry<String, TypeAnnotation.Position> e : expectedAnnos.entrySet()) {
        String aName = e.getKey();
        TypeAnnotation.Position expected = e.getValue();
        TypeAnnotation actual = findAnnotation(aName, actualAnnos, cf);
        if (actual == null)
            throw new ComparisionException("Expected annotation not found: " + aName);

        if (!areEquals(expected, actual.position)) {
            throw new ComparisionException("Unexpected position for annotation : " + aName +
                    "\n  Expected: " + expected.toString() +
                    "\n  Found: " + actual.position.toString());
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ReferenceInfoUtil.java

示例2: expectedOf

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
private Map<String, TypeAnnotation.Position> expectedOf(Method m) {
    TADescription ta = m.getAnnotation(TADescription.class);
    TADescriptions tas = m.getAnnotation(TADescriptions.class);

    if (ta == null && tas == null)
        return null;

    Map<String, TypeAnnotation.Position> result =
        new HashMap<>();

    if (ta != null)
        result.putAll(expectedOf(ta));

    if (tas != null) {
        for (TADescription a : tas.value()) {
            result.putAll(expectedOf(a));
        }
    }

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

示例3: areEquals

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
public static boolean areEquals(TypeAnnotation.Position p1, TypeAnnotation.Position p2) {
    if (p1 == p2)
        return true;
    if (p1 == null || p2 == null)
        return false;

    return ((p1.type == p2.type)
            && (p1.location.equals(p2.location))
            && areEquals(p1.offset, p2.offset)
            && areEquals(p1.lvarOffset, p2.lvarOffset)
            && areEquals(p1.lvarLength, p2.lvarLength)
            && areEquals(p1.lvarIndex, p2.lvarIndex)
            && areEquals(p1.bound_index, p2.bound_index)
            && areEquals(p1.parameter_index, p2.parameter_index)
            && areEquals(p1.type_index, p2.type_index)
            && areEquals(p1.exception_index, p2.exception_index));
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:18,代码来源:ReferenceInfoUtil.java

示例4: compare

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
public static boolean compare(Map<String, TypeAnnotation.Position> expectedAnnos,
        List<TypeAnnotation> actualAnnos, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    if (actualAnnos.size() != expectedAnnos.size()) {
        throw new ComparisionException("Wrong number of annotations",
                expectedAnnos,
                actualAnnos);
    }

    for (Map.Entry<String, TypeAnnotation.Position> e : expectedAnnos.entrySet()) {
        String aName = e.getKey();
        TypeAnnotation.Position expected = e.getValue();
        TypeAnnotation actual = findAnnotation(aName, actualAnnos, cf);
        if (actual == null)
            throw new ComparisionException("Expected annotation not found: " + aName);

        // TODO: you currently get an exception if the test case does not use all necessary
        // annotation attributes, e.g. forgetting the offset for a local variable.
        // It would be nicer to give an understandable warning instead.
        if (!areEquals(expected, actual.position)) {
            throw new ComparisionException("Unexpected position for annotation : " + aName +
                    "\n  Expected: " + expected.toString() +
                    "\n  Found: " + actual.position.toString());
        }
    }
    return true;
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:27,代码来源:ReferenceInfoUtil.java

示例5: expectedOf

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
private Map<String, TypeAnnotation.Position> expectedOf(Method m) {
    TADescription ta = m.getAnnotation(TADescription.class);
    TADescriptions tas = m.getAnnotation(TADescriptions.class);

    if (ta == null && tas == null)
        return null;

    Map<String, TypeAnnotation.Position> result =
        new HashMap<String, TypeAnnotation.Position>();

    if (ta != null)
        result.putAll(expectedOf(ta));

    if (tas != null) {
        for (TADescription a : tas.value()) {
            result.putAll(expectedOf(a));
        }
    }

    return result;
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:22,代码来源:Driver.java

示例6: compare

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
public static boolean compare(List<Pair<String, TypeAnnotation.Position>> expectedAnnos,
        List<TypeAnnotation> actualAnnos, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    if (actualAnnos.size() != expectedAnnos.size()) {
        throw new ComparisionException("Wrong number of annotations",
                expectedAnnos,
                actualAnnos);
    }

    for (Pair<String, TypeAnnotation.Position> e : expectedAnnos) {
        String aName = e.first;
        TypeAnnotation.Position expected = e.second;
        TypeAnnotation actual = findAnnotation(aName, expected, actualAnnos, cf);
        if (actual == null) {
            throw new ComparisionException("Expected annotation not found: " + aName + " position: " + expected,
                expectedAnnos,
                actualAnnos);
        }
    }
    return true;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:21,代码来源:ReferenceInfoUtil.java

示例7: expectedOf

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
private List<Pair<String, TypeAnnotation.Position>> expectedOf(Method m) {
    TADescription ta = m.getAnnotation(TADescription.class);
    TADescriptions tas = m.getAnnotation(TADescriptions.class);

    if (ta == null && tas == null)
        return null;

    List<Pair<String, TypeAnnotation.Position>> result =
            new ArrayList<>();

    if (ta != null)
        result.add(expectedOf(ta));

    if (tas != null) {
        for (TADescription a : tas.value()) {
            result.add(expectedOf(a));
        }
    }

    return result;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:22,代码来源:Driver.java

示例8: areEquals

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
public static boolean areEquals(TypeAnnotation.Position p1, TypeAnnotation.Position p2) {
    return p1 == p2 || !(p1 == null || p2 == null) &&
            p1.type == p2.type &&
            (p1.location.equals(p2.location)) &&
            areEquals(p1.offset, p2.offset) &&
            areEquals(p1.lvarOffset, p2.lvarOffset) &&
            areEquals(p1.lvarLength, p2.lvarLength) &&
            areEquals(p1.lvarIndex, p2.lvarIndex) &&
            areEquals(p1.bound_index, p2.bound_index) &&
            areEquals(p1.parameter_index, p2.parameter_index) &&
            areEquals(p1.type_index, p2.type_index) &&
            areEquals(p1.exception_index, p2.exception_index);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ReferenceInfoUtil.java

示例9: runDriver

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
protected void runDriver(Object object) throws Exception {
    int passed = 0, failed = 0;
    Class<?> clazz = object.getClass();
    out.println("Tests for " + clazz.getName());

    // Find methods
    for (Method method : clazz.getMethods()) {
        Map<String, TypeAnnotation.Position> expected = expectedOf(method);
        if (expected == null)
            continue;
        if (method.getReturnType() != String.class)
            throw new IllegalArgumentException("Test method needs to return a string: " + method);
        String testClass = testClassOf(method);

        for (String[] extraParams : extraParamsCombinations) {
            try {
                String compact = (String)method.invoke(object);
                String fullFile = wrap(compact);
                ClassFile cf = compileAndReturn(fullFile, testClass, extraParams);
                List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
                ReferenceInfoUtil.compare(expected, actual, cf);
                out.println("PASSED:  " + method.getName());
                ++passed;
            } catch (Throwable e) {
                out.println("FAILED:  " + method.getName());
                out.println("    " + e.toString());
                ++failed;
            }
        }
    }

    out.println();
    int total = passed + failed;
    out.println(total + " total tests: " + passed + " PASSED, " + failed + " FAILED");

    out.flush();

    if (failed != 0)
        throw new RuntimeException(failed + " tests failed");
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:41,代码来源:Driver.java

示例10: runDriver

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
protected void runDriver(Object object) throws Exception {
    int passed = 0, failed = 0;
    Class<?> clazz = object.getClass();
    out.println("Tests for " + clazz.getName());

    // Find methods
    for (Method method : clazz.getMethods()) {
        Map<String, TypeAnnotation.Position> expected = expectedOf(method);
        if (expected == null)
            continue;
        if (method.getReturnType() != String.class)
            throw new IllegalArgumentException("Test method needs to return a string: " + method);
        String testClass = testClassOf(method);

        try {
            String compact = (String)method.invoke(object);
            String fullFile = wrap(compact);
            ClassFile cf = compileAndReturn(fullFile, testClass);
            List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
            ReferenceInfoUtil.compare(expected, actual, cf);
            out.println("PASSED:  " + method.getName());
            ++passed;
        } catch (Throwable e) {
            out.println("FAILED:  " + method.getName());
            out.println("    " + e.toString());
            ++failed;
        }
    }

    out.println();
    int total = passed + failed;
    out.println(total + " total tests: " + passed + " PASSED, " + failed + " FAILED");

    out.flush();

    if (failed != 0)
        throw new RuntimeException(failed + " tests failed");
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:39,代码来源:Driver.java

示例11: findAnnotation

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
private static TypeAnnotation findAnnotation(String name, TypeAnnotation.Position expected, List<TypeAnnotation> annotations, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
    String properName = "L" + name + ";";
    for (TypeAnnotation anno : annotations) {
        String actualName = cf.constant_pool.getUTF8Value(anno.annotation.type_index);
        if (properName.equals(actualName) &&
            areEquals(expected, anno.position))
            return anno;
    }
    return null;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:11,代码来源:ReferenceInfoUtil.java

示例12: runDriver

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
protected void runDriver(Object object) throws Exception {
    int passed = 0, failed = 0;
    Class<?> clazz = object.getClass();
    out.println("Tests for " + clazz.getName());

    // Find methods
    for (Method method : clazz.getMethods()) {
        List<Pair<String, TypeAnnotation.Position>> expected = expectedOf(method);
        if (expected == null)
            continue;
        if (method.getReturnType() != String.class)
            throw new IllegalArgumentException("Test method needs to return a string: " + method);
        String testClass = testClassOf(method);

        try {
            String compact = (String)method.invoke(object);
            String fullFile = wrap(compact);
            ClassFile cf = compileAndReturn(fullFile, testClass);
            List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
            ReferenceInfoUtil.compare(expected, actual, cf);
            out.println("PASSED:  " + method.getName());
            ++passed;
        } catch (Throwable e) {
            out.println("FAILED:  " + method.getName());
            out.println("    " + e.toString());
            ++failed;
        }
    }

    out.println();
    int total = passed + failed;
    out.println(total + " total tests: " + passed + " PASSED, " + failed + " FAILED");

    out.flush();

    if (failed != 0)
        throw new RuntimeException(failed + " tests failed");
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:39,代码来源:Driver.java

示例13: ComparisionException

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
public ComparisionException(String message, Map<String, TypeAnnotation.Position> expected, List<TypeAnnotation> found) {
    super(message);
    this.expected = expected;
    this.found = found;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:ReferenceInfoUtil.java

示例14: ComparisionException

import com.sun.tools.classfile.TypeAnnotation; //导入方法依赖的package包/类
public ComparisionException(String message, List<Pair<String, TypeAnnotation.Position>> expected, List<TypeAnnotation> found) {
    super(message);
    this.expected = expected;
    this.found = found;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:6,代码来源:ReferenceInfoUtil.java


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