- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Does case object create "crufty" bytecode?
Tue, 2009-12-22, 08:00
I am trying to use the proguard tool in an attempt to shrink a self-contained scala application (sbaz). When I run proguard, I get the following messages:
Warning: scala.collection.immutable.RedBlack: can't find referenced class scala.collection.immutable.RedBlack$Empty
Warning: scala.collection.immutable.RedBlack$Empty$: can't find referenced class scala.collection.immutable.RedBlack$Empty
Attempting to look in the scala-library.jar file shows that the scala.collection.immutable.RedBlack$Empty in fact does not exist; only the ...RedBlack$Empty$ is there.
matlikj@hydra:~/workspace/sbaz$ jar -tvf lib/scala-library.jar | grep RedBlack.Empty
5334 Sun Dec 20 17:30:52 EST 2009 scala/collection/immutable/RedBlack$Empty$.class
Looking at the code for the Empty object, I see the following:
@serializable
case object Empty extends Tree[Nothing] {
def ...
Before now, I've only ever seen case classes, not case objects. If my understanding is correct, a case class would generate both the $Empty and the $Empty$, where the object is the former and the class is the latter. For the case object, it would appear that only the $Empty$ is being created, but proguard's bytecode processing seems to recognize that there are references to $Empty. Since $Empty doesn't exist, and it doesn't seem to be needed, it makes me wonder if there may be some faulty bytecode being generated to reference this class even though it is never generated. If I am missing something, please let me know.
Warning: scala.collection.immutable.RedBlack: can't find referenced class scala.collection.immutable.RedBlack$Empty
Warning: scala.collection.immutable.RedBlack$Empty$: can't find referenced class scala.collection.immutable.RedBlack$Empty
Attempting to look in the scala-library.jar file shows that the scala.collection.immutable.RedBlack$Empty in fact does not exist; only the ...RedBlack$Empty$ is there.
matlikj@hydra:~/workspace/sbaz$ jar -tvf lib/scala-library.jar | grep RedBlack.Empty
5334 Sun Dec 20 17:30:52 EST 2009 scala/collection/immutable/RedBlack$Empty$.class
Looking at the code for the Empty object, I see the following:
@serializable
case object Empty extends Tree[Nothing] {
def ...
Before now, I've only ever seen case classes, not case objects. If my understanding is correct, a case class would generate both the $Empty and the $Empty$, where the object is the former and the class is the latter. For the case object, it would appear that only the $Empty$ is being created, but proguard's bytecode processing seems to recognize that there are references to $Empty. Since $Empty doesn't exist, and it doesn't seem to be needed, it makes me wonder if there may be some faulty bytecode being generated to reference this class even though it is never generated. If I am missing something, please let me know.
Tue, 2009-12-22, 08:47
#2
Re: Does case object create "crufty" bytecode?
Sorry for the repeat, I dropped the distribution list.
Interesting. Unless 2.8 uses 2.7 to compile, I think this issue is back then. The symptoms are showing from a build created two days ago. I've just changed my environment to point to the latest as my SCALA_HOME and initiated a rebuild in case my environment is playing a part, but I thought the bootstrapping process used by the scala build scripts defined the compiler version used.
Additionally, note that the code executes fine, it is a third party tool that inspects the byte code that is complaining.
On Tue, Dec 22, 2009 at 2:08 AM, Blair Zajac <blair@orcaware.com> wrote:
Interesting. Unless 2.8 uses 2.7 to compile, I think this issue is back then. The symptoms are showing from a build created two days ago. I've just changed my environment to point to the latest as my SCALA_HOME and initiated a rebuild in case my environment is playing a part, but I thought the bootstrapping process used by the scala build scripts defined the compiler version used.
Additionally, note that the code executes fine, it is a third party tool that inspects the byte code that is complaining.
On Tue, Dec 22, 2009 at 2:08 AM, Blair Zajac <blair@orcaware.com> wrote:
On 12/21/09 10:59 PM, James Matlik wrote:
I am trying to use the proguard tool in an attempt to shrink a
self-contained scala application (sbaz). When I run proguard, I get the
following messages:
Warning: scala.collection.immutable.RedBlack: can't find referenced
class scala.collection.immutable.RedBlack$Empty
Warning: scala.collection.immutable.RedBlack$Empty$: can't find
referenced class scala.collection.immutable.RedBlack$Empty
This is a bug in 2.7.x that is fixed in 2.8.x. See these tickets which ran into the same problems:
https://issues.rpath.com/browse/CNY-3260
https://lampsvn.epfl.ch/trac/scala/ticket/1167
Regards,
Blair
Tue, 2009-12-22, 14:37
#3
Re: Does case object create "crufty" bytecode?
It would appear that the behavior I describe is related to 2.8, as I've rerun the the scala build and proguard processing with 2.7 completely removed from mix.
Certainly this isn't a high priority issue, as it doesn't stop Scala code from running. I do think it is a loose end that should be corrected eventually, as it can cause problems for third party tools. Fortunately, proguard allows you to ignore specific warnings using a configuration flag.
On Tue, Dec 22, 2009 at 2:36 AM, James Matlik <james.matlik@gmail.com> wrote:
Certainly this isn't a high priority issue, as it doesn't stop Scala code from running. I do think it is a loose end that should be corrected eventually, as it can cause problems for third party tools. Fortunately, proguard allows you to ignore specific warnings using a configuration flag.
On Tue, Dec 22, 2009 at 2:36 AM, James Matlik <james.matlik@gmail.com> wrote:
Sorry for the repeat, I dropped the distribution list.
Interesting. Unless 2.8 uses 2.7 to compile, I think this issue is back then. The symptoms are showing from a build created two days ago. I've just changed my environment to point to the latest as my SCALA_HOME and initiated a rebuild in case my environment is playing a part, but I thought the bootstrapping process used by the scala build scripts defined the compiler version used.
Additionally, note that the code executes fine, it is a third party tool that inspects the byte code that is complaining.
On Tue, Dec 22, 2009 at 2:08 AM, Blair Zajac <blair@orcaware.com> wrote:
On 12/21/09 10:59 PM, James Matlik wrote:
I am trying to use the proguard tool in an attempt to shrink a
self-contained scala application (sbaz). When I run proguard, I get the
following messages:
Warning: scala.collection.immutable.RedBlack: can't find referenced
class scala.collection.immutable.RedBlack$Empty
Warning: scala.collection.immutable.RedBlack$Empty$: can't find
referenced class scala.collection.immutable.RedBlack$Empty
This is a bug in 2.7.x that is fixed in 2.8.x. See these tickets which ran into the same problems:
https://issues.rpath.com/browse/CNY-3260
https://lampsvn.epfl.ch/trac/scala/ticket/1167
Regards,
Blair
Tue, 2009-12-22, 15:47
#4
Re: Does case object create "crufty" bytecode?
On Tue, Dec 22, 2009 at 08:32:05AM -0500, James Matlik wrote:
> It would appear that the behavior I describe is related to 2.8, as
> I've rerun the the scala build and proguard processing with 2.7
> completely removed from mix.
I have 80% done my intention to get a fully working proguard setup and
add something super easy so people can type "ant proguard" or whatever
and get packaged shrunk jars. Here is an excerpt from the .pro file.
# TODO
# scala.collection.immutable.RedBlack$Empty
-dontwarn scala.collection.immutable.RedBlack$Empty
I am also working on a big bytecode library which will find all these
issues. I think this one is tricky though. Read the comments in
http://lampsvn.epfl.ch/trac/scala/ticket/1572
for a small taste. Search for the many open tickets on inner classes
for a larger taste.
On 12/21/09 10:59 PM, James Matlik wrote:
> I am trying to use the proguard tool in an attempt to shrink a
> self-contained scala application (sbaz). When I run proguard, I get the
> following messages:
>
> Warning: scala.collection.immutable.RedBlack: can't find referenced
> class scala.collection.immutable.RedBlack$Empty
> Warning: scala.collection.immutable.RedBlack$Empty$: can't find
> referenced class scala.collection.immutable.RedBlack$Empty
This is a bug in 2.7.x that is fixed in 2.8.x. See these tickets which
ran into the same problems:
https://issues.rpath.com/browse/CNY-3260
https://lampsvn.epfl.ch/trac/scala/ticket/1167
Regards,
Blair