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

Parsing Inner Classes #667

Closed
chriszwickerocteris opened this issue Jul 19, 2019 · 2 comments
Milestone

Comments

@chriszwickerocteris
Copy link

@chriszwickerocteris chriszwickerocteris commented Jul 19, 2019

SFM 7.0.0

AsmInstantiatorDefinitionFactory seems to have an issue with inner (non-static) classes when generics are involved: in #visitMethod, parsing desc leads to an additional type as compared to parsing signature, finally leading to an IndexOutOfBoundsException.

Reproducing Test:

public class SfmListTests {
  private static Connection conn;

  @BeforeClass
  public static void init() throws SQLException {
    conn = DriverManager.getConnection("jdbc:postgresql://localhost:4001/testing", "postgres", "testing");
  }

  @Test
  public void failing() throws SQLException {
    final String query = String.join("\n",
      "with t (",
        "id, foo_id",
      " ) as ( values",
        "('a', 'b')",
      ")",
      "select * from t"
    );
    PreparedStatement stmt = conn.prepareStatement(query);
    ResultSet rs = stmt.executeQuery();
    
    final JdbcMapperFactory mapperFactory = JdbcMapperFactory.newInstance()
      .useAsm(false)
      .ignorePropertyNotFound()
      .addKeys("id")
      .addKeys("foos_id")
    ;
    final Iterator<Root> iterator = mapperFactory.newMapper(Root.class).iterator(rs);
  }

  public class Root {
    private String id;
    private List<Foo> foos;

    public Root() {}
    public Root(final String id, final List<Foo> foos) {
      this.id = id;
      this.foos = foos;
    }
  }

  class Foo {
    private String id;
    
    public Foo() {}
    public Foo(final String id) {
      this.id = id;
    }
  }
}
@arnaudroger

This comment has been minimized.

Copy link
Owner

@arnaudroger arnaudroger commented Jul 23, 2019

will see If can change that, the inner class have issue though because it needs a ref to theouter class, which might not be available ...

@chriszwickerocteris

This comment has been minimized.

Copy link
Author

@chriszwickerocteris chriszwickerocteris commented Jul 26, 2019

Not urgent, just came across this - easy to work around...

@arnaudroger arnaudroger added this to the 7.0.3 milestone Aug 9, 2019
@arnaudroger arnaudroger modified the milestones: 7.0.3, 7.0.4 Aug 20, 2019
@arnaudroger arnaudroger modified the milestones: 8.0.3, 8.0.4 Sep 13, 2019
arnaudroger added a commit that referenced this issue Nov 1, 2019
@arnaudroger arnaudroger closed this Nov 1, 2019
@arnaudroger arnaudroger modified the milestones: 8.2.0, 8.1.1 Nov 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.