question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for java records

See original GitHub issue

It would be awesome to map an xls/xlsx record to a java record, like this one:

public record MyRecord(
        @ExcelCellName("Writing code")
        String writingCode
) {
}

… but currently Poiji throws an exception:

com.poiji.exception.PoijiInstantiationException: Cannot create a new instance of com.model.MyRecord
	at com.poiji.util.ReflectUtil.newInstanceOf(ReflectUtil.java:28)
	at com.poiji.bind.mapping.HSSFUnmarshaller.deserializeRowToInstance(HSSFUnmarshaller.java:163)
	at com.poiji.bind.mapping.HSSFUnmarshaller.processRowsToObjects(HSSFUnmarshaller.java:97)
	at com.poiji.bind.mapping.HSSFUnmarshaller.unmarshal(HSSFUnmarshaller.java:80)
	at com.poiji.bind.Poiji.fromExcel(Poiji.java:220)
	at com.poiji.bind.Poiji.fromExcel(Poiji.java:196)
	....
	....
	....
	....
	....
Caused by: java.lang.NoSuchMethodException: com.model.MyRecord.<init>()
	at java.base/java.lang.Class.getConstructor0(Class.java:3508)
	at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2711)
	at com.poiji.util.ReflectUtil.newInstanceOf(ReflectUtil.java:22)
	... 108 common frames omitted

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
t-jdcommented, Oct 3, 2021

Hi @ozlerhakan I will take a look once I have free time, but I don’t promise, maybe someone else will do it before me

0reactions
ozlerhakancommented, Apr 10, 2022

right now there are some limits to unable java records on Poiji. This does not mean that we don’t add it to Poiji, however, once we handle it, I re open this issue to integrate it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4 Records - Java - Oracle Help Center
JDK 14 introduces records, which are a new kind of type declaration. Like an enum, a record is a restricted form of a...
Read more >
Java 14 Record Keyword - Baeldung
With the release of Java 14, we can now use records to remedy these problems. In this tutorial, we'll look at the fundamentals...
Read more >
Java 14 Records Class | DigitalOcean
Java 14 introduced a new way to create classes called Records. ... Both Eclipse and IntelliJ already provide support for Java 14, ...
Read more >
[#FREEMARKER-183] Add support for Java records - ASF JIRA
Hi, ddekany! Is there any progress on this issue? Java Records became standard and next LTS release was publised (Java 17). Maybe you...
Read more >
How to use Record in Java? Example - Java67
Can you add static methods on Java records? You can add static methods inside the java record definition. This allows having access to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found