小编Pas*_*eli的帖子

局部变量之前的GOTO

以下代码是否构成未定义的行为,因为我在变量声明之前跳转并通过指针使用它?如果是这样,标准之间是否存在差异?

int main() {
  int *p = 0;
label1: 
  if (p) {
    printf("%d\n", *p);
    return 0;
  }
  int i = 999;
  p = &i;
  goto label1;
  return -1;
}
Run Code Online (Sandbox Code Playgroud)

c goto declaration undefined-behavior

24
推荐指数
3
解决办法
1473
查看次数

使用Maven包含JAXB

在我的1.6.0_16 JDK上工作,我使用Apache CXF 2.5.2从WSDL生成我的存根类,它使用最新的jaxb-api 2.2.我知道可以使用jaxb-api 2.1,但为了避免兼容性问题,我宁愿让它使用当前版本.由于我的JDK具有jaxb 2.1,因此构建失败并显示以下消息:

error at @XmlElementRef(name = "protocol", namespace = "urn:ch.beo.emc", type = JAXBElement.class, required = false)
Run Code Online (Sandbox Code Playgroud)

因此,我尝试使用以下依赖项使maven包含最新的jaxb api和impl.

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.5</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.5</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

虽然这两个jar已经添加到Eclipse中的Maven Dependencies中,但错误消息在Eclipse和Maven构建中仍然存在.

如何在我的Maven构建中包含这些jar并让它们在Eclipse和目标系统中使用?


PS:请在这里找到完整的POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ch.beo</groupId>
    <artifactId>emc.front</artifactId>
    <version>3.1.3-SNAPSHOT</version>
    <repositories>
        <repository>
            <id>jboss</id>
            <name>JBoss</name>
            <url>http://repository.jboss.org/maven2/</url>
        </repository>
        <repository>
            <id>freehep</id>
            <name>Freehep</name>
            <url>http://java.freehep.org/maven2</url>
        </repository>
        <repository>
            <id>JCurl</id>
            <url>http://jcurl.berlios.de/m2/repo</url>
        </repository>
        <repository>
            <id>JavaNet</id>
            <url>http://download.java.net/maven/2/</url>
        </repository>
        <repository>
            <id>djmaven2</id>
            <url>http://www.fdvs.com.ar/djmaven2</url>
            <name>DynamicJasper public Repository</name>
        </repository>
    </repositories>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <defaultGoal>compile</defaultGoal>
        <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory> …
Run Code Online (Sandbox Code Playgroud)

java jaxb dependency-management maven

12
推荐指数
3
解决办法
7万
查看次数

Xerces DOM解析器非常慢?

目前,我正在尝试使用JTidy清理HTML文件,将其转换为XHTML并将结果提供给DOM解析器.以下代码是这些努力的结果:

public class HeaderBasedNewsProvider implements INewsProvider {

    /* ... */

    public Collection<INewsEntry> getNewsEntries() throws NewsUnavailableException {
            Document document;
        try {
            document = getCleanedDocument();
        } catch (Exception e) {
            throw new NewsUnavailableException(e);
        }
        System.err.println(document.getDocumentElement().getTextContent());
        return null;
    }

    private final Document getCleanedDocument() throws IOException, SAXException, ParserConfigurationException {
        InputStream input = inputStreamProvider.getInputStream();
        Tidy tidy = new Tidy();
        tidy.setXHTML(true);
        ByteArrayOutputStream tidyOutputStream = new ByteArrayOutputStream();
        tidy.parse(input, tidyOutputStream);
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(false);
        InputStream domInputStream = new ByteArrayInputStream(tidyOutputStream.toByteArray());
        System.err.println(factory.getClass());
        return factory.newDocumentBuilder().parse(domInputStream);
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,我的系统上的DOM解析器实现(com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl)似乎非常慢.即使对于如下所示的单行文档,解析也需要2-3分钟:

<!DOCTYPE html …
Run Code Online (Sandbox Code Playgroud)

java performance dom xerces

3
推荐指数
1
解决办法
2482
查看次数

DynamicJasper和亚洲人物角色

由DynamicJasper生成的我的PDF现在看起来完全符合预期,我只面临一个问题:在生成的PDF中根本不显示亚洲字符.任何其他角色都可以.我可以在调试器中验证字符串是否正确放置在JRDataSource中,而Jasper确实在报告中为它们生成了行,但文本本身完全缺失.

将DynamicJasper与亚洲文本元素一起使用时,是否还需要考虑其他一些编码设置?

感谢您的任何建议和最好的问候

jasper-reports asianfonts dynamic-jasper

2
推荐指数
1
解决办法
2159
查看次数

GCC:限制长双倍宽度

有没有一种方法/开关在使用GCC编译时将长双精度的大小限制为64位?

c++ gcc long-double

2
推荐指数
1
解决办法
114
查看次数