Java二进制兼容性问题:sun.font.FontManager类成为接口 [英] Java binary compatibility issue: sun.font.FontManager class became interface

查看:1903
本文介绍了Java二进制兼容性问题:sun.font.FontManager类成为接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Lobo - Java Web Browser 库,它给了我一个例外我确定的一些研究可能是因为该库已经与旧版本的Java进行了比较。

I am using the Lobo - Java Web Browser library, and it gives me an exception which after some research I determined could be due to the library having been complied against an older version of Java.

代码如下:

import java.io.IOException;
import org.lobobrowser.html.UserAgentContext;
import org.lobobrowser.html.parser.DocumentBuilderImpl;
import org.lobobrowser.html.parser.InputSourceImpl;
import org.lobobrowser.html.test.SimpleUserAgentContext;
import org.xml.sax.SAXException;

public class Cobratest
{
    public static void main(String[] args) throws SAXException, IOException
    {
        UserAgentContext uAgent = new SimpleUserAgentContext();
        DocumentBuilderImpl docBuild = new DocumentBuilderImpl(uAgent);
        docBuild.parse(new InputSourceImpl("http://dic.amdz.com/"));
    }
}

并且堆栈跟踪是:

 Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface sun.font.FontManager, but class was expected
    at org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:210)
    at org.lobobrowser.util.gui.FontFactory.createFont_Impl(FontFactory.java:180)
    at org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:127)
    at org.lobobrowser.util.gui.FontFactory.getFont(FontFactory.java:98)
    at org.lobobrowser.html.style.StyleSheetRenderState.<clinit>(StyleSheetRenderState.java:43)
    at org.lobobrowser.html.domimpl.NodeImpl.<clinit>(NodeImpl.java:39)
    at org.lobobrowser.html.parser.DocumentBuilderImpl.createDocument(DocumentBuilderImpl.java:143)
    at org.lobobrowser.html.parser.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:97)

当我检查时 org.lobobrowser.util.gui.FontFactory.createFont 我发现有一个名为 FontManager 的接口,该接口已从以前的Java版本。在这个 FontFactory 类中,他们使用了一个不再可用的接口类。我该如何解决这个问题?

when I examined org.lobobrowser.util.gui.FontFactory.createFont I found out there is an interface called FontManager which changed from the previous version of Java. In this FontFactory class, they used a class of this interface which is no longer available. How can I fix this problem?

界面 FontManager

package sun.font;

import java.awt.Font;
import java.awt.FontFormatException;
import java.io.File;

public interface FontManager {

    public static final int NO_FALLBACK = 0;
    public static final int PHYSICAL_FALLBACK = 1;
    public static final int LOGICAL_FALLBACK = 2;

    public boolean registerFont(Font font);

    public void deRegisterBadFont(Font2D font2d);

    public Font2D findFont2D(String string, int i, int i1);

    public Font2D createFont2D(File file, int i, boolean bln, CreatedFontTracker cft) throws FontFormatException;

    public boolean usingPerAppContextComposites();

    public Font2DHandle getNewComposite(String string, int i, Font2DHandle fdh);

    public void preferLocaleFonts();

    public void preferProportionalFonts();
}

以及库中使用的类不可用:

and the class used in the library which is not available:

   return FontManager.getCompositeFontUIResource(new Font(name, style, size));


推荐答案

我认为'sun.font.FontManager'已删除使用Java7,所以如果你必须使用它(我建议反对它并寻找另一个包)你可以尝试用java6运行它。

I think 'sun.font.FontManager'was removed with Java7, so if you must use it (I'd recommend against it and look for another package instead) you could try running it with java6.

这篇关于Java二进制兼容性问题:sun.font.FontManager类成为接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆