English 中文(简体)
为什么编纂这部法典会造成汇编者大量外流?
原标题:Why does compiling this code cause a compiler stack overflow?
interface Pong<T> {}
class Ping<T> implements Pong<Pong<? super Ping<Ping<T>>>> {
    static void Ping() {
        Pong<? super Ping<Long>> Ping = new Ping<Long>();
    }
}

编辑这一错误:

The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
    at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579)
    at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)
    at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3260)
    at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2592)
    at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579)
    at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)
    ...

Code/bor

最佳回答

很显然,这是 Java汇编者的ug。 编造者坠机,特别是在规模如此小的方案上。

<could 甚至成为 Java语言规格中的一个漏洞;即,作者们所考虑的通用术语中一个模糊的边缘案例。

But (IMO) this is nothing more than a curiosity, unless you can come up with an example that isn t so obviously contrived to break the compiler. I mean, this example code isn t exactly meaningful ...


有些人深入了解了 Java汇编者的执行情况,这可能说明为什么造成大量外流。 但是,除非此人也将固定.子,否则这几乎无关紧要。 除非有人能够举出一个引起同一问题的有意义的例子,否则我就看看看在解决这个问题方面有什么价值。

问题回答

由于编辑不能决定<代码>Long 是Pong,即<代码><><<>> >条/代码>、<代码>>、<0的<代码>,或者该代码是<>Ping的>条码/代码>,其中延伸了“代码>的代码>。

我有一席之地,在现实法典中存在类似的问题。 在那里,他有一个具有2个参数的抽象基类,有2个子类,将其固定为具体类型。 基本上,这可以界定抽象类别中的完整逻辑,而不必重复两种分类别中所用的混杂法。

基本来说,该法典就是这样一条:

public abstract class AImpl<X extends A<Y>, Y extends A<X>> {
    public X foo(Y o) {
        return o.doStuff();
    }

    public Y bar(X o) {
        return o.doStuff();
    }
}

class VImpl extends AImpl<V, E> {}
class EImpl extends AImpl<E, V> {}

interface A<T> {
    T doStuff();
}

interface V extends A<E> {}
interface E extends A<V> {}

该法典实际上是编纂的。 在现实中,不仅有2个子类,而且有更深的类型等级,例如,3个维姆普和埃厄姆普的变量,每个变量都有许多专横的子类。 确实,有3个类型参数,如上所示,限制更为复杂。

当只有两种维姆普和埃斯特姆普的变量时,它仍然汇编了罚款。 在第三种变数增加后,他就认为汇编者的流入量过多。 尽管如此,Eclipse汇编者仍然能够编纂该守则,因此看来它只是javac做一些回馈,应当做得更好。

不幸的是,我们无法将完整的法典基础降低到适合简讯报告的一些最低实例。

我在8_u25, updating to JDK 8u_65上看到了同样的情况。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签