You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few classes in kamon-core that quite confuse the compiler:
kamon.metric.Metric - a toplevel interface
kamon.metric.Metric$ - a toplevel class
kamon.metric.Metric$Settings - an inner interface of the kamon.metric.Metric
kamon.metric.Metric$Settings$ - an inner class of the kamon.metric.Metric
kamon.metric.Metric$Settings$ForDistributionInstrument - inner class of kamon.metric.Metric$Settings$
kamon.metric.Metric$Settings$ForDistributionInstrument$ - inner class of kamon.metric.Metric$Settings$
According to Java rules, kamon.metric.Metric$Settings$ForDistributionInstrument should be inner class of kamon.metric.Metric$Settings (no trailing $), because the $ is needed as the separator of name segments. Apparently the scala compiler, which produced these .class files, didn't pay attention to such rules. Given that the InnerClasses is the only manifestation of inner classes at the bytecode level, it is possible for a non-Java compiler to produce such .class files.
What's more: kamon.metric.Metric$Settings$ does not have a source name as seen in this bytecode attribute:
InnerClasses:
public static #8= #2 of #7; // =class kamon/metric/Metric$Settings$ of class kamon/metric/Metric
The source name would be the value of #8, i.e., the part before the =. I.e., we regard this type as an anonymous class.
In the Java world this means the type is anonymous, and hence no external reference to this type is possible. The compiler only has provisions for the source variant of anonymous classes, not for their binary counter part, as they are never relevant for compilation.
From this, type.isLocalType() is a sufficient guard for a cast to LocalTypeBinding - for legal .class files, i.e.
Still we find Metric$Settings$ just by looking at public API:
public static interface kamon.metric.Metric$Timer implements Metric<kamon.metric.Timer,kamon.metric.Metric$Settings$ForDistributionInstrument>
type argument kamon.metric.Metric$Settings$ForDistributionInstrument is inner class of kamon.metric.Metric$Settings$
booom
To a java compiler this tells: here is a public interface that depends on an anonymous type. This is nonsense.
The scala compiler will have to make up its mind whether or not kamon.metric.Metric$Settings$ is anonymous.
In JDT we could further protect this one cast, but we have a total of 64 callers of isLocalType(). Each would need to be thoroughly checked, which IMHO is way too much effort just to support non-Java .class files.
The text was updated successfully, but these errors were encountered:
mebigfatguy
changed the title
kamon-core_1.13 (2.5.11) has problems with the eclipse compiler
kamon-core_2.13 (2.5.11) has problems with the eclipse compiler
Nov 11, 2022
There are a few classes in kamon-core that quite confuse the compiler:
kamon.metric.Metric - a toplevel interface
kamon.metric.Metric$ - a toplevel class
kamon.metric.Metric$Settings - an inner interface of the kamon.metric.Metric
kamon.metric.Metric$Settings$ - an inner class of the kamon.metric.Metric
kamon.metric.Metric$Settings$ForDistributionInstrument - inner class of kamon.metric.Metric$Settings$
kamon.metric.Metric$Settings$ForDistributionInstrument$ - inner class of kamon.metric.Metric$Settings$
According to Java rules, kamon.metric.Metric$Settings$ForDistributionInstrument should be inner class of kamon.metric.Metric$Settings (no trailing $), because the $ is needed as the separator of name segments. Apparently the scala compiler, which produced these .class files, didn't pay attention to such rules. Given that the InnerClasses is the only manifestation of inner classes at the bytecode level, it is possible for a non-Java compiler to produce such .class files.
What's more: kamon.metric.Metric$Settings$ does not have a source name as seen in this bytecode attribute:
InnerClasses:
public static #8= #2 of #7; // =class kamon/metric/Metric$Settings$ of class kamon/metric/Metric
The source name would be the value of #8, i.e., the part before the =. I.e., we regard this type as an anonymous class.
In the Java world this means the type is anonymous, and hence no external reference to this type is possible. The compiler only has provisions for the source variant of anonymous classes, not for their binary counter part, as they are never relevant for compilation.
From this, type.isLocalType() is a sufficient guard for a cast to LocalTypeBinding - for legal .class files, i.e.
Still we find Metric$Settings$ just by looking at public API:
public static interface kamon.metric.Metric$Timer implements Metric<kamon.metric.Timer,kamon.metric.Metric$Settings$ForDistributionInstrument>
type argument kamon.metric.Metric$Settings$ForDistributionInstrument is inner class of kamon.metric.Metric$Settings$
booom
To a java compiler this tells: here is a public interface that depends on an anonymous type. This is nonsense.
The scala compiler will have to make up its mind whether or not kamon.metric.Metric$Settings$ is anonymous.
In JDT we could further protect this one cast, but we have a total of 64 callers of isLocalType(). Each would need to be thoroughly checked, which IMHO is way too much effort just to support non-Java .class files.
The text was updated successfully, but these errors were encountered: