#40 Fix AClass#asString and RContext#resolve

Закриті
4 роки тому відкрито ranides · 1 коментарів
ranides відкоментовано 4 роки тому

At this moment we have a problem: RContext#resolve can go into stackoverflow:

    at net.ranides.assira.reflection.impl.RContext.resolve0(RContext.java:74)
    at net.ranides.assira.reflection.impl.RContext.resolve(RContext.java:62)
    at net.ranides.assira.reflection.impl.RContext.resolve0(RContext.java:74)
    at net.ranides.assira.reflection.impl.RContext.resolve(RContext.java:62)
    at net.ranides.assira.reflection.impl.RContext.resolve0(RContext.java:74)
    at net.ranides.assira.reflection.impl.RContext.resolve(RContext.java:62)
    at net.ranides.assira.reflection.impl.RContext.resolve0(RContext.java:74)
At this moment we have a problem: RContext#resolve can go into stackoverflow: ``` at net.ranides.assira.reflection.impl.RContext.resolve0(RContext.java:74) at net.ranides.assira.reflection.impl.RContext.resolve(RContext.java:62) at net.ranides.assira.reflection.impl.RContext.resolve0(RContext.java:74) at net.ranides.assira.reflection.impl.RContext.resolve(RContext.java:62) at net.ranides.assira.reflection.impl.RContext.resolve0(RContext.java:74) at net.ranides.assira.reflection.impl.RContext.resolve(RContext.java:62) at net.ranides.assira.reflection.impl.RContext.resolve0(RContext.java:74) ```
ranides відкоментовано 4 роки тому
Власник

It is hard to say, what is cause of the problem, but it can be reproduced in AClassTest#testRecursiveString

At this moment we inserted workaround inside AClass#toString, but it causes that nested types can't be converted to correct string.

If we declare parameterized type Something<T> and then declare nested type Something<Something<Something<T>>>, we have infinite recursion.

Somewhere under the hood, toString converts parameters to strings. To do so, it has to create parameters list first. Parameter list is created lazily, and every parameter creates result using context:typeinfo.

typeinfo calls resolveTV

IContext somewhere

It is hard to say, what is cause of the problem, but it can be reproduced in AClassTest#testRecursiveString At this moment we inserted workaround inside AClass#toString, but it causes that nested types can't be converted to correct string. If we declare parameterized type `Something<T>` and then declare nested type `Something<Something<Something<T>>>`, we have infinite recursion. Somewhere under the hood, toString converts parameters to strings. To do so, it has to create parameters list first. Parameter list is created lazily, and every parameter creates result using `context:typeinfo`. typeinfo calls resolveTV IContext somewhere
ranides згадано цю проблему в коміті 4 роки тому
Підпишіться щоб приєднатися до обговорення.
Етап відсутній
Немає відповідального
1 учасників
Завантажується...
Скасувати
Зберегти
Тут ще немає жодного вмісту.