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

AbstractTypeSymbol reaches GenASM in the throws annotation of a method #7122

Closed
scabug opened this issue Feb 12, 2013 · 3 comments
Closed

AbstractTypeSymbol reaches GenASM in the throws annotation of a method #7122

scabug opened this issue Feb 12, 2013 · 3 comments
Assignees
Labels

Comments

@scabug
Copy link

scabug commented Feb 12, 2013

In JPlainBuilder.genMethod() the exceptions an (ICode) IMethod m throws are obtained via

  val (excs, others) = m.symbol.annotations partition (_.symbol == ThrowsClass)

The test added in commit 02dd4c97 includes a source file (reproduced below)

class ScalaClassWithCheckedExceptions_1[E1 <: Exception] @throws[NullPointerException]("") () {
  @throws[E1]("") def bar() {}
  @throws[IllegalStateException]("") def baz(x: Int) {}
  // FIXME: SI-7066
  // @throws[E2]("") def foo[E2 <: Exception] {}
}

that results in an AbstractTypeSymbol "E1" reaching GenASM, as part of

@throws[E1]("") def bar() {}

In terms of ASM's Textify the resulting class file includes:

// class version 50.0 (50)
// access flags 0x21
// signature <E1:Ljava/lang/Exception;>Ljava/lang/Object;
// declaration: ScalaClassWithCheckedExceptions_1<E1 extends java.lang.Exception>
public class ScalaClassWithCheckedExceptions_1 {

...

  public bar()V throws E1 
    RETURN
    MAXSTACK = 0
    MAXLOCALS = 1

Although there's no "E1" class file the bytecode verifier doesn't complain.

@scabug
Copy link
Author

scabug commented Feb 12, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7122?orig=1
Reporter: @magarciaEPFL
See #6860

@scabug
Copy link
Author

scabug commented Feb 12, 2013

@magarciaEPFL said:
It would be great if the outcome for this bug also makes it to the scaladoc for scala.throws

For comparison, Java:

class S<E1 extends Error> {

  public void bar() throws E1 {  }

}

Resulting bytecode, displayed by javap -c -private -s S

Compiled from "S.java"
class S extends java.lang.Object{
S();
  Signature: ()V
  Code:
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return

public void bar()   throws java.lang.Error;
  Signature: ()V
  Code:
   0:   return

}

@SethTisue
Copy link
Member

closing stale backend tickets; comment/reopen if you have evidence this is still applicable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants