Skip to content

Commit

Permalink
Fix template generation of Loader.java for JRuby
Browse files Browse the repository at this point in the history
The original work nearly worked but 3 fields needed to be accessed
by the extended type JRuby needs to create to properly have
`getName()` return RubySymbol instead of j.l.String.

This PR additional removes an unused field when generating JRuby version
of Loader.java because it is only needed for `getName()` when it
returns j.l.String.
  • Loading branch information
enebo committed Nov 10, 2023
1 parent 7bf28ea commit 09d561e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions templates/java/org/prism/Loader.java.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ public class Loader {

private final ByteBuffer buffer;
private final Nodes.Source source;
private String encodingName;
protected String encodingName;
<%- if string_type == "String" -%>
private Charset encodingCharset;
<%- end -%>
private ConstantPool constantPool;
private Loader(byte[] serialized, Nodes.Source source) {
protected Loader(byte[] serialized, Nodes.Source source) {
this.buffer = ByteBuffer.wrap(serialized).order(ByteOrder.nativeOrder());
this.source = source;
}
private ParseResult load() {
protected ParseResult load() {
expect((byte) 'P', "incorrect prism header");
expect((byte) 'R', "incorrect prism header");
expect((byte) 'I', "incorrect prism header");
Expand All @@ -106,7 +108,9 @@ public class Loader {
byte[] encodingNameBytes = new byte[encodingLength];
buffer.get(encodingNameBytes);
this.encodingName = new String(encodingNameBytes, StandardCharsets.US_ASCII);
<%- if string_type == "String" -%>
this.encodingCharset = getEncodingCharset(this.encodingName);
<%- end -%>

source.setStartLine(loadVarInt());

Expand Down

0 comments on commit 09d561e

Please sign in to comment.