小编use*_*796的帖子

使用完全限定类型时,类型注释抛出“找不到符号”

package com.company;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.List;

public class Main {

    @Target(ElementType.TYPE_USE)
    @Retention(RetentionPolicy.RUNTIME)
    public @interface A {}

    public static void main(String[] args) {
    }

    private List<@A Integer> integers1;

    private List<@A java.lang.Integer> integers2;
}
Run Code Online (Sandbox Code Playgroud)

我收到 private List<@A java.lang.Integer> integers2; 错误:

错误:(20, 21) java: 找不到符号符号:类 java
位置:类 com.company.Main

是程序中的bug吗?

java types annotations

5
推荐指数
1
解决办法
1648
查看次数

javafx 2 webview自定义url处理程序,不工作相对url

我有简单的应用程序代码:

webView.getEngine().load("classpath:data/index.html");
Run Code Online (Sandbox Code Playgroud)

自定义URLStreamHandler:

public class Handler extends URLStreamHandler {
    private final ClassLoader classLoader;

    public Handler() {
        this.classLoader = getClass().getClassLoader();
    }

    public Handler(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    @Override
    protected URLConnection openConnection(URL u) throws IOException {
        URL resourceUrl = classLoader.getResource(u.getPath());
        if(resourceUrl == null)
            throw new IOException("Resource not found: " + u);

        return resourceUrl.openConnection();
    }
}
Run Code Online (Sandbox Code Playgroud)

安装人:

URL.setURLStreamHandlerFactory(protocol -> {
    if(protocol.equals("classpath")) {
        return new Handler();
    } else {
        return null;
    }
});
Run Code Online (Sandbox Code Playgroud)

它加载data/index.html:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
</head>
<body>
<div>Hello, …
Run Code Online (Sandbox Code Playgroud)

java webview javafx-8

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

标签 统计

java ×2

annotations ×1

javafx-8 ×1

types ×1

webview ×1