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

Compilation of objects in Scala with special access privileges fail to compile #127

Closed
javeleon opened this issue May 20, 2016 · 12 comments
Closed

Comments

@javeleon
Copy link

javeleon commented May 20, 2016

Whenever I try to compile a Java project with inner classes in it using Zinc I get the following stacktrace:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.lang.RuntimeException Failed to find name hashes for com.example.allang.zinc_test.A.Inner
    at scala.sys.package$.error(package.scala:27)
    at sbt.internal.inc.AnalysisCallback.nameHashesForCompanions(Compile.scala:263)
    at sbt.internal.inc.AnalysisCallback.sbt$internal$inc$AnalysisCallback$$analyzeClass(Compile.scala:270)
    at sbt.internal.inc.AnalysisCallback$$anonfun$addProductsAndDeps$1$$anonfun$8.apply(Compile.scala:280)
    at sbt.internal.inc.AnalysisCallback$$anonfun$addProductsAndDeps$1$$anonfun$8.apply(Compile.scala:280)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.mutable.HashSet.foreach(HashSet.scala:78)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
    at scala.collection.mutable.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:46)
    at scala.collection.SetLike$class.map(SetLike.scala:92)
    at scala.collection.mutable.AbstractSet.map(Set.scala:46)
    at sbt.internal.inc.AnalysisCallback$$anonfun$addProductsAndDeps$1.apply(Compile.scala:280)
    at sbt.internal.inc.AnalysisCallback$$anonfun$addProductsAndDeps$1.apply(Compile.scala:276)
    at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:157)
    at scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:157)
    at scala.collection.mutable.HashSet.foreach(HashSet.scala:78)
    at scala.collection.TraversableOnce$class.foldLeft(TraversableOnce.scala:157)
    at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
    at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:151)
    at scala.collection.AbstractTraversable.$div$colon(Traversable.scala:104)
    at sbt.internal.inc.AnalysisCallback.addProductsAndDeps(Compile.scala:276)
    at sbt.internal.inc.AnalysisCallback.get(Compile.scala:235)
    at sbt.internal.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:79)
    at sbt.internal.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:76)
    at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:63)
    at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:37)
    at sbt.internal.inc.Incremental$$anonfun$1.apply(Incremental.scala:73)
    at sbt.internal.inc.Incremental$$anonfun$1.apply(Incremental.scala:71)
    at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:101)
    at sbt.internal.inc.Incremental$.compile(Incremental.scala:71)
    at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:59)
    at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:162)
    at sbt.internal.inc.IncrementalCompilerImpl.incrementalCompile(IncrementalCompilerImpl.scala:107)
    at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:51)
    at com.zt.jrebel.android.java.incremental.ZincExecutor.execute(ZincExecutor.java:117)
    at com.zt.jrebel.android.java.incremental.ZincExecutor.execute(ZincExecutor.java:103)
    at com.zt.jrebel.android.java.incremental.SourcePreCompiler.precompileSources(SourcePreCompiler.java:38)
    at com.zt.jrebel.android.java.incremental.JavaIncrementalCompiler.parseIncremental(JavaIncrementalCompiler.java:173)
    at com.zt.jrebel.android.java.incremental.JavaIncrementalCompiler.compile(JavaIncrementalCompiler.java:75)
    at com.zt.jra.bundled.compilation.JrJavacAction.execute(JrJavacAction.java:77)
    at com.zt.jra.bundled.compilation.JrJavacAction.execute(JrJavacAction.java:26)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
@gkossakowski
Copy link
Contributor

Thanks for the report. Does this class exist in your source code? Is A.Inner nested in an object?

@romanowski
Copy link
Contributor

@javeleon can you confirm that after #158 is merge this is still a problem?

I faced similar issues and PR above fix them.

@jvican
Copy link
Member

jvican commented Feb 3, 2017

Hi @javeleon, could you please confirm this issue is fixed? We'd like to close it asap.

@jvican
Copy link
Member

jvican commented Feb 19, 2017

Closing, if this is still an issue, please reopen. /cc @javeleon

@jvican jvican closed this as completed Feb 19, 2017
@fommil
Copy link

fommil commented Oct 13, 2017

I'm getting this with a scala object inside a a class... the object is private[EnclosingClass] if that matters.

@dwijnand
Copy link
Member

If you have any kind of reproduction (minimised most appreciated) we can reopen (or open a new issue).

@fommil
Copy link

fommil commented Oct 13, 2017

class Foo {
  private[Foo] object Bar
}

oughta do it (I checked)

@dwijnand
Copy link
Member

Wow, that's literally enough.

@dwijnand dwijnand reopened this Oct 13, 2017
@dwijnand dwijnand added the bug label Oct 13, 2017
@dwijnand dwijnand added this to the 1.1.0 milestone Oct 13, 2017
@jvican jvican self-assigned this Oct 13, 2017
@jvican
Copy link
Member

jvican commented Oct 13, 2017

Working for a fix to this now. PR will probably happen today.

@dwijnand dwijnand modified the milestones: 1.1.0, 1.0.3 Oct 13, 2017
@dwijnand
Copy link
Member

dwijnand commented Oct 13, 2017

Cool, moved to the 1.0.3 milestone then.

@jvican jvican changed the title Cannot compile Java Inner classes with Zinc Compilation of objects in Scala with special access privileges fail to compile Oct 13, 2017
jvican added a commit to scalacenter/zinc that referenced this issue Oct 13, 2017
It looks like scalac encodes access rights of objects in their names. To
make sure that we get the right simple names, we need to use
`unexpandedName` instead of `name` which will decipher these access
rights and return their simple names insted (with all the previous `$$`
prefixes stripped out).
jvican added a commit to scalacenter/zinc that referenced this issue Oct 13, 2017
It looks like scalac encodes access rights of objects in their names. To
make sure that we get the right simple names, we need to use
`unexpandedName` instead of `name` which will decipher these access
rights and return their simple names insted (with all the previous `$$`
prefixes stripped out).
jvican added a commit to scalacenter/zinc that referenced this issue Oct 13, 2017
It looks like scalac encodes access rights of objects in their names. To
make sure that we get the right simple names, we need to use
`unexpandedName` instead of `name` which will decipher these access
rights and return their simple names insted (with all the previous `$$`
prefixes stripped out).
jvican added a commit that referenced this issue Oct 16, 2017
dwijnand added a commit to dwijnand/zinc that referenced this issue Oct 24, 2017
* 1.0.x:
  Fix sbt#127: Use `unexpanded` name instead of `name`
  Add pending test case for issue/127
  source-dependencies / patMat-scope workaround
  Fixes undercompilation on inheritance on same source
  Add real reproduction case for sbt#417
  Add trait-trait-212 for Scala 2.12.3
  Fix source-dependencies/sealed
  Import statement no longer needed
  Move mima exclusions to its own file
  Move REPL related xsbti Java to correct module
  make LoggedReporter fields lazy
  sbt.version=1.0.2
  use neo-sbt-scalafmt
  Fix ConsoleInterface binding things properly^2
@eed3si9n
Copy link
Member

Fixed in #431

@jvican
Copy link
Member

jvican commented Oct 27, 2017

This is the second time an issue is not closed after a PR referencing to it with "Fix #bla" is merged.

dwijnand added a commit to dwijnand/zinc that referenced this issue Nov 22, 2017
* 1.0.x: (25 commits)
  Add yourkit acknoledgement in the README
  Add header to cached hashing spec
  Add headers to missing files
  Fix sbt#332: Add sbt-header back to the build
  Update sbt-scalafmt to 1.12
  Make classpath hashing more lightweight
  Fix sbt#442: Name hash of value class should include underlying type
  source-dependencies/value-class-underlying: fix test
  Ignore null in generic lambda tparams
  Improve and make scripted parallel
  Fix sbt#436: Remove annoying log4j scripted exception
  Fix sbt#127: Use `unexpanded` name instead of `name`
  Add pending test case for issue/127
  source-dependencies / patMat-scope workaround
  Fixes undercompilation on inheritance on same source
  Add real reproduction case for sbt#417
  Add trait-trait-212 for Scala 2.12.3
  Fix source-dependencies/sealed
  Import statement no longer needed
  Move mima exclusions to its own file
  ...

 Conflicts:
	internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala
	zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala

The ClassToAPI conflict is due to:
* sbt#393 (a 1.x PR), conflicting with
* sbt#446 (a 1.0.x PR).

The MixedAnalyzingCompiler conflict is due to:
* sbt#427 (a 1.x PR), conflicting with
* sbt#452 (a 1.0.x PR).
dwijnand added a commit to dwijnand/zinc that referenced this issue Nov 23, 2017
* 1.0.x: (28 commits)
  Split compiler bridge tests to another subproject
  Implement compiler bridge for 2.13.0-M2
  Add yourkit acknoledgement in the README
  "sbt '++ 2.13.0-M2!' compile" does not work with sbt 1.0.0
  Add header to cached hashing spec
  Add headers to missing files
  Fix sbt#332: Add sbt-header back to the build
  Update sbt-scalafmt to 1.12
  Make classpath hashing more lightweight
  Fix sbt#442: Name hash of value class should include underlying type
  source-dependencies/value-class-underlying: fix test
  Ignore null in generic lambda tparams
  Improve and make scripted parallel
  Fix sbt#436: Remove annoying log4j scripted exception
  Fix sbt#127: Use `unexpanded` name instead of `name`
  Add pending test case for issue/127
  source-dependencies / patMat-scope workaround
  Fixes undercompilation on inheritance on same source
  Add real reproduction case for sbt#417
  Add trait-trait-212 for Scala 2.12.3
  ...

 Conflicts:
	internal/zinc-apiinfo/src/main/scala/sbt/internal/inc/ClassToAPI.scala
	project/build.properties
	zinc/src/main/scala/sbt/internal/inc/MixedAnalyzingCompiler.scala

The ClassToAPI conflict is due to:
* sbt#393 (a 1.x PR), conflicting with
* sbt#446 (a 1.0.x PR).

The build.properties conflict is due to different PRs bumping
sbt.version from 1.0.0 to 1.0.2 to 1.0.3. (sbt#413, sbt#418, sbt#453).

The MixedAnalyzingCompiler conflict is due to:
* sbt#427 (a 1.x PR), conflicting with
* sbt#452 (a 1.0.x PR).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants