GetNativesForFlavorTest.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:openjdk9 作者:
/**
 * Verifies that the encoded native is added only for DataFlavors
 * that has no mappings and that DataFlavor is properly encoded.
 */
public static void test4() throws ClassNotFoundException {
    final DataFlavor flavor =
            new DataFlavor("unknown/unknown");

    final java.util.List natives = fm.getNativesForFlavor(flavor);

    if (natives.size() == 1) {
        String element = (String) natives.get(0);
        if (SystemFlavorMap.isJavaMIMEType(element)) {
            final DataFlavor decodedFlavor =
                    SystemFlavorMap.decodeDataFlavor(element);
            if (!flavor.equals(decodedFlavor)) {
                System.err.println("DataFlavor is not properly incoded:");
                System.err.println("    encoded flavor: " + flavor);
                System.err.println("    decoded flavor: " + decodedFlavor);
                throw new RuntimeException("getFlavorsForNative() returns:"
                        + natives);
            }
        }
    } else {
        throw new RuntimeException("getFlavorsForNative() returns:"
                + natives);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号