Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kamon-core_2.13 (2.5.11) has problems with the eclipse compiler #133

Open
mebigfatguy opened this issue Nov 8, 2022 · 1 comment
Open

Comments

@mebigfatguy
Copy link

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.

@mebigfatguy
Copy link
Author

@mebigfatguy 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant