Failure to parse generic constructor bytecode

Issue #274 resolved
Jesper Öqvist created an issue

ExtendJ 8.1.0-24-g7c0a012 Java SE 5

ExtendJ fails to parse the bytecode for this class:

package runtime;

// This is used by a test to verify that ExtendJ can load generic constructor signatures.
public class GenericConstructor {
  public <T> GenericConstructor(T t) {

The failure is triggered by this test that uses the constructor:

// Test that ExtendJ correctly parses generic constructor bytecode.
// .result: COMPILE_PASS
// .classpath: @RUNTIME_CLASSES@
import runtime.GenericConstructor;

public class Test {
  void pass() {
    new GenericConstructor(this);

Expected result: the program should compile correctly if the class GenericConstructor is loaded from bytecode compiled with Javac.

Actual result: when the class GenericConstructor is loaded from bytecode, ExtendJ crashes:

    [junit] Error while processing tests/generics/constructor_10p/
    [junit] Fatal exception:
    [junit] java.lang.Error: Trying to make a typeDescriptor() of Unknown
    [junit]     at org.extendj.ast.UnknownType.typeDescriptor_compute(
    [junit]     at org.extendj.ast.UnknownType.typeDescriptor(
    [junit]     at org.extendj.ast.ConstructorDecl.descName_compute(
    [junit]     at org.extendj.ast.ConstructorDecl.descName(
    [junit]     at org.extendj.ast.ConstructorDecl.emitInvokeConstructor(
    [junit]     at org.extendj.ast.ClassInstanceExpr.createBCode(
    [junit]     at org.extendj.ast.ExprStmt.createBCode(

Comments (1)

  1. Jesper Öqvist reporter

    Parse generic constructors from bytecode

    This fixes an issue in bytecode parsing for constructors. Generic constructors were previously parsed as non-generic constructors. The type parameters were incorrectly discarded.

    fixes #274 (bitbucket)

    → <<cset cd7effa71375>>

  2. Log in to comment