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

Use decoded names when checking if a classfile is reachable from client code #49

Conversation

dotta
Copy link
Contributor

@dotta dotta commented Sep 20, 2013

Operators are encoded into $<plain-name> during compilation to please the
JVM. Hence, the former implementation of PackageInfo.isAccessible was broken
as it relied on the encoded name of a class, instead of using the decoded one.
This commit fixes the issue.

Fixes #46

review by @gkossakowski, @retronym

…nt code

Operators are encoded into `$<plain-name>` during compilation to please the
JVM. Hence, the former implementation of `PackageInfo.isAccessible` was broken
as it relied on the encoded name of a class, instead of using the decoded one.
This commit fixes the issue.

Fixes lightbend-labs#46
def bytecodeName: String

/** The name as found in the original Scala source. */
final def decodedName: String = NameTransformer.decode(bytecodeName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you get here with a name that doesn't originate from Scala source? Technically you should try to avoid decoding them. We had a bug recently where a Java class named R$attr broke the compiler. Maybe it's not the most important thing for MiMa.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you get here with a name that doesn't originate from Scala source?

Yes

Technically you should try to avoid decoding them. We had a bug recently where a Java class named R$attr broke the compiler. Maybe it's not the most important thing for MiMa.

Bugs are just part of software development, so I'm not really worried about that. The alternative would be to duplicate the logic, as I still want to use the decoded name for error reporting purposes. But the actual main reason for using decoded names, is that PackageInfo.isAccessible relies on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a method to this trait def isScala: Boolean, and predicate the behaviour of decodedName on that?

I think the correct way to find out is to find the enclosing top level class and check if it has the 'ScalaSignature' or ScalaLongSignature annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea, and I think we could do it while parsing a classfile. However, I can't dedicate more time to this at the moment and, overall, I believe the current implementation is not worst than what we had before, since we were already relying on NameTransformer.decode here.

We should definitely file a ticket, and maybe someone else can take it. Sounds ok?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here is the ticket #50

@dotta
Copy link
Contributor Author

dotta commented Sep 23, 2013

Should we merge it? Would be great if you guys could give it a try before I cut a new release.

@dragos
Copy link

dragos commented Sep 23, 2013

LGTM

@retronym
Copy link
Contributor

LGTM. I trust the enclosed test.

dotta added a commit that referenced this pull request Sep 23, 2013
…ng-accessibility-of-class-46

Use decoded names when checking if a classfile is reachable from client code
@dotta dotta merged commit 7c87c2a into lightbend-labs:master Sep 23, 2013
@dotta dotta deleted the issue/use-decoded-names-when-checking-accessibility-of-class-46 branch September 23, 2013 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

traits, classes with special characters are skipped
3 participants