Compiler/Runtime Diagnostics

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiler/Runtime Diagnostics

Eric Kolotyluk
I posted the following problem to scala-users, and got back a few interesting responses that were useful.

In one case this could be confusion between the case class instance, and the companion object type.

In another case, this is the same type being loaded by different class loaders.

These are all good explanations, but the compiler/runtime diagnostics are not very helpful.

<oldStory>
A helicopter pilot is flying a client to SeaTac airport, but there is a lot of fox and he has lost his bearings. He sees a building with someone on the roof having a cigarette so he flies over. He yells out the window "where are we" and the person on the roof yells back "you are in a helicopter". The pilot checks his compass and then heads directly for SeaTac.

While they are on the way the client asks the pilot "how did you know where you were from that answer?" The pilot says "well, the answer was completely correct, but also completely useless, so I knew that person worked for Microsoft, and I know my way from Microsoft to SeaTac."
</oldStory>

Truly, Microsoft are not the only ones who are guilty of this, most computer diagnostics are similarly not useful.

One of the interesting things I have seen working with Apache Maven is that often the diagnostics contain a URI that will take you to an article related to the error encountered, with a better discussion of the possible causes of the error, along with advice on how to resolve the error.

Question: would it be possible to have the Scala compiler and runtime emit some handy URIs to articles. For example
play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]
<http://scala-lan.org/runtime-diagnotics/class-cast-exception/cannot-cast-to-same-type/>
This implies that the Scala runtime is smart enough to realize that models.UserProfile is the same name as models.UserProfile, and deserves a special explanation (cannot-cast-to-same-type).

I know that for me, troubleshooting would be far less abstruse if there were better diagnostics.

Cheers, Eric


On 2014-09-11 11:18 AM, Eric Kolotyluk wrote:
What does it mean in Scala when you cannot cast a type to itself, or am I reading this wrong?

play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]

Cheers, Eric

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Compiler/Runtime Diagnostics

som-snytt
Instead of just -Xcheckinit, perhaps -Xcheck:init,cast where the unsafe operation is wrapped in an appropriate try with verbose diagnostics.

With class loading, you often want ScalaClassLoader.originOfClass and classPathURLs or reflect.runtime.ReflectionUtils.show(loader).

There is a small name clash with -Ycheck:typer etc.

I, too, would be a bit miffed if someone put out my smoke by flying too close.


On Thu, Sep 11, 2014 at 1:25 PM, Eric Kolotyluk <[hidden email]> wrote:
I posted the following problem to scala-users, and got back a few interesting responses that were useful.

In one case this could be confusion between the case class instance, and the companion object type.

In another case, this is the same type being loaded by different class loaders.

These are all good explanations, but the compiler/runtime diagnostics are not very helpful.

<oldStory>
A helicopter pilot is flying a client to SeaTac airport, but there is a lot of fox and he has lost his bearings. He sees a building with someone on the roof having a cigarette so he flies over. He yells out the window "where are we" and the person on the roof yells back "you are in a helicopter". The pilot checks his compass and then heads directly for SeaTac.

While they are on the way the client asks the pilot "how did you know where you were from that answer?" The pilot says "well, the answer was completely correct, but also completely useless, so I knew that person worked for Microsoft, and I know my way from Microsoft to SeaTac."
</oldStory>

Truly, Microsoft are not the only ones who are guilty of this, most computer diagnostics are similarly not useful.

One of the interesting things I have seen working with Apache Maven is that often the diagnostics contain a URI that will take you to an article related to the error encountered, with a better discussion of the possible causes of the error, along with advice on how to resolve the error.

Question: would it be possible to have the Scala compiler and runtime emit some handy URIs to articles. For example
play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]
<http://scala-lan.org/runtime-diagnotics/class-cast-exception/cannot-cast-to-same-type/>
This implies that the Scala runtime is smart enough to realize that models.UserProfile is the same name as models.UserProfile, and deserves a special explanation (cannot-cast-to-same-type).

I know that for me, troubleshooting would be far less abstruse if there were better diagnostics.

Cheers, Eric


On 2014-09-11 11:18 AM, Eric Kolotyluk wrote:
What does it mean in Scala when you cannot cast a type to itself, or am I reading this wrong?

play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]

Cheers, Eric

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Compiler/Runtime Diagnostics

Viktor Klang
I think it's a shame that ClassCastException doesn't include the classloaders as it is generated and thrown by the JVM.
A good suggestion to fix for Java9?

On Fri, Sep 12, 2014 at 12:02 AM, Som Snytt <[hidden email]> wrote:
Instead of just -Xcheckinit, perhaps -Xcheck:init,cast where the unsafe operation is wrapped in an appropriate try with verbose diagnostics.

With class loading, you often want ScalaClassLoader.originOfClass and classPathURLs or reflect.runtime.ReflectionUtils.show(loader).

There is a small name clash with -Ycheck:typer etc.

I, too, would be a bit miffed if someone put out my smoke by flying too close.


On Thu, Sep 11, 2014 at 1:25 PM, Eric Kolotyluk <[hidden email]> wrote:
I posted the following problem to scala-users, and got back a few interesting responses that were useful.

In one case this could be confusion between the case class instance, and the companion object type.

In another case, this is the same type being loaded by different class loaders.

These are all good explanations, but the compiler/runtime diagnostics are not very helpful.

<oldStory>
A helicopter pilot is flying a client to SeaTac airport, but there is a lot of fox and he has lost his bearings. He sees a building with someone on the roof having a cigarette so he flies over. He yells out the window "where are we" and the person on the roof yells back "you are in a helicopter". The pilot checks his compass and then heads directly for SeaTac.

While they are on the way the client asks the pilot "how did you know where you were from that answer?" The pilot says "well, the answer was completely correct, but also completely useless, so I knew that person worked for Microsoft, and I know my way from Microsoft to SeaTac."
</oldStory>

Truly, Microsoft are not the only ones who are guilty of this, most computer diagnostics are similarly not useful.

One of the interesting things I have seen working with Apache Maven is that often the diagnostics contain a URI that will take you to an article related to the error encountered, with a better discussion of the possible causes of the error, along with advice on how to resolve the error.

Question: would it be possible to have the Scala compiler and runtime emit some handy URIs to articles. For example
play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]
<http://scala-lan.org/runtime-diagnotics/class-cast-exception/cannot-cast-to-same-type/>
This implies that the Scala runtime is smart enough to realize that models.UserProfile is the same name as models.UserProfile, and deserves a special explanation (cannot-cast-to-same-type).

I know that for me, troubleshooting would be far less abstruse if there were better diagnostics.

Cheers, Eric


On 2014-09-11 11:18 AM, Eric Kolotyluk wrote:
What does it mean in Scala when you cannot cast a type to itself, or am I reading this wrong?

play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]

Cheers, Eric

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Compiler/Runtime Diagnostics

Eric Kolotyluk
OK, I submitted a feature request to Oracle to have
Execution exception[[ClassCastException: foo cannot be cast to foo]]
changed to
Execution exception[[ClassCastException: foo[classloader1] cannot be cast to foo[classloader2]: you need to use the same classloader]
Hopefully someone on the Java team will care.

Cheers, Eric

On 2014-09-12 2:20 AM, √iktor Ҡlang wrote:
I think it's a shame that ClassCastException doesn't include the classloaders as it is generated and thrown by the JVM.
A good suggestion to fix for Java9?

On Fri, Sep 12, 2014 at 12:02 AM, Som Snytt <[hidden email]> wrote:
Instead of just -Xcheckinit, perhaps -Xcheck:init,cast where the unsafe operation is wrapped in an appropriate try with verbose diagnostics.

With class loading, you often want ScalaClassLoader.originOfClass and classPathURLs or reflect.runtime.ReflectionUtils.show(loader).

There is a small name clash with -Ycheck:typer etc.

I, too, would be a bit miffed if someone put out my smoke by flying too close.


On Thu, Sep 11, 2014 at 1:25 PM, Eric Kolotyluk <[hidden email]> wrote:
I posted the following problem to scala-users, and got back a few interesting responses that were useful.

In one case this could be confusion between the case class instance, and the companion object type.

In another case, this is the same type being loaded by different class loaders.

These are all good explanations, but the compiler/runtime diagnostics are not very helpful.

<oldStory>
A helicopter pilot is flying a client to SeaTac airport, but there is a lot of fox and he has lost his bearings. He sees a building with someone on the roof having a cigarette so he flies over. He yells out the window "where are we" and the person on the roof yells back "you are in a helicopter". The pilot checks his compass and then heads directly for SeaTac.

While they are on the way the client asks the pilot "how did you know where you were from that answer?" The pilot says "well, the answer was completely correct, but also completely useless, so I knew that person worked for Microsoft, and I know my way from Microsoft to SeaTac."
</oldStory>

Truly, Microsoft are not the only ones who are guilty of this, most computer diagnostics are similarly not useful.

One of the interesting things I have seen working with Apache Maven is that often the diagnostics contain a URI that will take you to an article related to the error encountered, with a better discussion of the possible causes of the error, along with advice on how to resolve the error.

Question: would it be possible to have the Scala compiler and runtime emit some handy URIs to articles. For example
play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]
<http://scala-lan.org/runtime-diagnotics/class-cast-exception/cannot-cast-to-same-type/>
This implies that the Scala runtime is smart enough to realize that models.UserProfile is the same name as models.UserProfile, and deserves a special explanation (cannot-cast-to-same-type).

I know that for me, troubleshooting would be far less abstruse if there were better diagnostics.

Cheers, Eric


On 2014-09-11 11:18 AM, Eric Kolotyluk wrote:
What does it mean in Scala when you cannot cast a type to itself, or am I reading this wrong?

play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]

Cheers, Eric

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Cheers,

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Compiler/Runtime Diagnostics

som-snytt
Then you pull out whatever hairs remain and go, How did that get on a different class loader?

Of course this doesn't address that compiler message

expected: foo  found: foo

How much is US$10 in bitcoinage?


On Fri, Sep 12, 2014 at 8:13 AM, Eric Kolotyluk <[hidden email]> wrote:
OK, I submitted a feature request to Oracle to have
Execution exception[[ClassCastException: foo cannot be cast to foo]]
changed to
Execution exception[[ClassCastException: foo[classloader1] cannot be cast to foo[classloader2]: you need to use the same classloader]
Hopefully someone on the Java team will care.

Cheers, Eric


On 2014-09-12 2:20 AM, √iktor Ҡlang wrote:
I think it's a shame that ClassCastException doesn't include the classloaders as it is generated and thrown by the JVM.
A good suggestion to fix for Java9?

On Fri, Sep 12, 2014 at 12:02 AM, Som Snytt <[hidden email]> wrote:
Instead of just -Xcheckinit, perhaps -Xcheck:init,cast where the unsafe operation is wrapped in an appropriate try with verbose diagnostics.

With class loading, you often want ScalaClassLoader.originOfClass and classPathURLs or reflect.runtime.ReflectionUtils.show(loader).

There is a small name clash with -Ycheck:typer etc.

I, too, would be a bit miffed if someone put out my smoke by flying too close.


On Thu, Sep 11, 2014 at 1:25 PM, Eric Kolotyluk <[hidden email]> wrote:
I posted the following problem to scala-users, and got back a few interesting responses that were useful.

In one case this could be confusion between the case class instance, and the companion object type.

In another case, this is the same type being loaded by different class loaders.

These are all good explanations, but the compiler/runtime diagnostics are not very helpful.

<oldStory>
A helicopter pilot is flying a client to SeaTac airport, but there is a lot of fox and he has lost his bearings. He sees a building with someone on the roof having a cigarette so he flies over. He yells out the window "where are we" and the person on the roof yells back "you are in a helicopter". The pilot checks his compass and then heads directly for SeaTac.

While they are on the way the client asks the pilot "how did you know where you were from that answer?" The pilot says "well, the answer was completely correct, but also completely useless, so I knew that person worked for Microsoft, and I know my way from Microsoft to SeaTac."
</oldStory>

Truly, Microsoft are not the only ones who are guilty of this, most computer diagnostics are similarly not useful.

One of the interesting things I have seen working with Apache Maven is that often the diagnostics contain a URI that will take you to an article related to the error encountered, with a better discussion of the possible causes of the error, along with advice on how to resolve the error.

Question: would it be possible to have the Scala compiler and runtime emit some handy URIs to articles. For example
play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]
<http://scala-lan.org/runtime-diagnotics/class-cast-exception/cannot-cast-to-same-type/>
This implies that the Scala runtime is smart enough to realize that models.UserProfile is the same name as models.UserProfile, and deserves a special explanation (cannot-cast-to-same-type).

I know that for me, troubleshooting would be far less abstruse if there were better diagnostics.

Cheers, Eric


On 2014-09-11 11:18 AM, Eric Kolotyluk wrote:
What does it mean in Scala when you cannot cast a type to itself, or am I reading this wrong?

play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]

Cheers, Eric

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Cheers,


--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Compiler/Runtime Diagnostics

Eric Kolotyluk
As an aside: apparently a 3rd party package we are using, uses multiple classloaders. What makes this really problematic is that the stack trace highlights code that is nowhere near the source of the problem (which I am still looking for), and the current message from the exception does nothing to hint to classloader problems, when it could.

Cheers, Eric

On 2014-09-12 8:47 AM, Som Snytt wrote:
Then you pull out whatever hairs remain and go, How did that get on a different class loader?

Of course this doesn't address that compiler message

expected: foo  found: foo

How much is US$10 in bitcoinage?


On Fri, Sep 12, 2014 at 8:13 AM, Eric Kolotyluk <[hidden email]> wrote:
OK, I submitted a feature request to Oracle to have
Execution exception[[ClassCastException: foo cannot be cast to foo]]
changed to
Execution exception[[ClassCastException: foo[classloader1] cannot be cast to foo[classloader2]: you need to use the same classloader]
Hopefully someone on the Java team will care.

Cheers, Eric


On 2014-09-12 2:20 AM, √iktor Ҡlang wrote:
I think it's a shame that ClassCastException doesn't include the classloaders as it is generated and thrown by the JVM.
A good suggestion to fix for Java9?

On Fri, Sep 12, 2014 at 12:02 AM, Som Snytt <[hidden email]> wrote:
Instead of just -Xcheckinit, perhaps -Xcheck:init,cast where the unsafe operation is wrapped in an appropriate try with verbose diagnostics.

With class loading, you often want ScalaClassLoader.originOfClass and classPathURLs or reflect.runtime.ReflectionUtils.show(loader).

There is a small name clash with -Ycheck:typer etc.

I, too, would be a bit miffed if someone put out my smoke by flying too close.


On Thu, Sep 11, 2014 at 1:25 PM, Eric Kolotyluk <[hidden email]> wrote:
I posted the following problem to scala-users, and got back a few interesting responses that were useful.

In one case this could be confusion between the case class instance, and the companion object type.

In another case, this is the same type being loaded by different class loaders.

These are all good explanations, but the compiler/runtime diagnostics are not very helpful.

<oldStory>
A helicopter pilot is flying a client to SeaTac airport, but there is a lot of fox and he has lost his bearings. He sees a building with someone on the roof having a cigarette so he flies over. He yells out the window "where are we" and the person on the roof yells back "you are in a helicopter". The pilot checks his compass and then heads directly for SeaTac.

While they are on the way the client asks the pilot "how did you know where you were from that answer?" The pilot says "well, the answer was completely correct, but also completely useless, so I knew that person worked for Microsoft, and I know my way from Microsoft to SeaTac."
</oldStory>

Truly, Microsoft are not the only ones who are guilty of this, most computer diagnostics are similarly not useful.

One of the interesting things I have seen working with Apache Maven is that often the diagnostics contain a URI that will take you to an article related to the error encountered, with a better discussion of the possible causes of the error, along with advice on how to resolve the error.

Question: would it be possible to have the Scala compiler and runtime emit some handy URIs to articles. For example
play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]
<http://scala-lan.org/runtime-diagnotics/class-cast-exception/cannot-cast-to-same-type/>
This implies that the Scala runtime is smart enough to realize that models.UserProfile is the same name as models.UserProfile, and deserves a special explanation (cannot-cast-to-same-type).

I know that for me, troubleshooting would be far less abstruse if there were better diagnostics.

Cheers, Eric


On 2014-09-11 11:18 AM, Eric Kolotyluk wrote:
What does it mean in Scala when you cannot cast a type to itself, or am I reading this wrong?

play.api.Application$$anon$1: Execution exception[[ClassCastException: models.UserProfile cannot be cast to models.UserProfile]]

Cheers, Eric

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Cheers,



--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.