class Log {public void log(String s) { System.out.println(s); }}
abstract class Businessy {protected Log log = new Log();public abstract void makeSomeMoney();}
class PetStore extends Businessy {public void makeSomeMoney() { /* sell pets */ }}
class PetStore extends Businessy {def makeSomeMoney() { /* sell pets */ }}
--
Grzegorz KossakowskiScalac hacker at Typesafetwitter: @gkossakowskigithub: @gkossakowski
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "scala-language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-language/0B678ZjZQAw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-languag...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
Jason - the point is a more general one about how scalac and javac handle transitive deps that are not used. I mean - if my PetStore code never tries to reference the log field, why does it matter what visibility it has?In javac, even adding this to PetStore means that the logging JAR becomes necessaryclass PetStore extends Businessy {public void makeSomeMoney() { System.out.println(log); }}
It works in 2.11.0-M4, specifically since I fixed SI-7439.
--
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
warning: Class org.apache.commons.logging.Log not found - continuing with a stub.
My questions:
1) under what circumstances is this warning of an issue that will manifest as a failure at runtime *assuming at runtime that jar IS on the classpath*?
2) Is there a way to silence this warning safely without just addind more (unneeded, it seems) items to the classpath?
3) What could be done to better support build tools that try to keep compile dependencies as a subset of runtime dependencies that are actually needed by the source code in question?
Thanks!
What Scala version(s) are you testing with? Robustness to missing dependencies fluctuated somewhat through 2.10 and 2.11 releases.
Could you boil this down to a test case like this one? I’ll then be better able to answer your questions.
% cat sandbox/test.scala
class A
class B {
def foo(a: A) = a
def bar = 42
}
% (export V=2.11.7; ~/scala/$V/bin/scalac sandbox/test.scala; rm A.class; ~/scala/$V/bin/scala -nc -e 'new B().bar')
% (export V=2.11.7; ~/scala/$V/bin/scalac sandbox/test.scala; rm A.class; ~/scala/$V/bin/scala -nc -e 'new B().foo(null)')
error: missing or invalid dependency detected while loading class file 'B.class'.
Could not access type A in package <empty>,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'B.class' was compiled against an incompatible version of <empty>.
/code/scala on topic/nuke-impl-classes-2*
As you can see from my test, the intention is to create a stub symbol for the type of the parameter a when we read the B.class, and defer any error until typechecking can’t proceed without knowing more about that type.
Regards,
-jason
07:09:29 warning: Class org.apache.commons.logging.Log not found - continuing with a stub. 07:09:29 one warning found
Are you compiling with -optimize at the time? I notice that under this mode, our ClassFileParser (that we use to read the signatures of Java originated classes) reads the signatures of private fields which would include private static Logger LOG = ....
Looks like the same problem (right down to Hadoop) was reported in the comments of a kindred bug.
We should definitely demote that warning if it is just on a a private field. Please raise a ticket and I’ll improve this.
Here's the test case: https://gist.github.com/64fe18c74eac9d49092e
In the meantime, you can safely ignore the warning. It will turn into an error if it really prevents the compiler from making a decision later on. We don't currently have a means to disable the warning, sort of customizing the reporter in the compiler, which is a bit of a pain.
-jason
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.