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

Fix handling deeply nested java classes. #423

Merged
merged 1 commit into from
Oct 11, 2017

Conversation

romanowski
Copy link
Contributor

Without fix it reports dependencies to jar/classes produced by same project.

eed3si9n
eed3si9n previously approved these changes Oct 7, 2017
Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

LGTM


def loadEnclosingClass(clazz: Class[_]): Option[String] = {
binaryToSourceName(clazz) match {
case None if loadedClass.getEnclosingClass != null =>
Copy link
Member

Choose a reason for hiding this comment

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

I think you mean clazz.getEnclosingClass != null here.

Copy link
Member

Choose a reason for hiding this comment

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

How was the test case even passing with this error? This would mean that more than one level of nesting would not be handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests passes since if loadedClass is nested class (regardless how deep) it will be always null.

The only problem with this is that in case that for some reason we don't have source mapping for top enclosing class we will get NullPointerException here. But anyway this was stupid mistake.

Copy link
Member

@jvican jvican left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @romanowski. Waiting for your feedback.

import sbt.internal.inc.Analysis
import sbt.io.IO

/**
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove this header? We don't use them anywhere in the project.

case analysis: Analysis =>
analysis.relations.libraryDep._2s
.filter(_.toPath.startsWith(tempDir.toPath)) shouldBe 'empty

Copy link
Member

Choose a reason for hiding this comment

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

Remove empty space?


def loadEnclosingClass(clazz: Class[_]): Option[String] = {
binaryToSourceName(clazz) match {
case None if loadedClass.getEnclosingClass != null =>
Copy link
Member

Choose a reason for hiding this comment

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

How was the test case even passing with this error? This would mean that more than one level of nesting would not be handled.

Without fix it reports dependencies to jar/classes produced by same project.
Copy link
Member

@jvican jvican left a comment

Choose a reason for hiding this comment

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

LGTM @romanowski, thanks for this work.

@jvican
Copy link
Member

jvican commented Oct 11, 2017

I see @dwijnand has approved and @eed3si9n already had a pass through this. Merging then.

@jvican jvican merged commit 3a64b8a into sbt:1.x Oct 11, 2017
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

Successfully merging this pull request may close these issues.

4 participants