Skip to content

Commit

Permalink
feat(#488): use default version if it isn't set at xmir
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Mar 27, 2024
1 parent 9e29387 commit 6d8a626
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
package org.eolang.jeo.representation.xmir;

import com.jcabi.xml.XMLDocument;
import java.util.List;
import java.util.Optional;
import org.eolang.jeo.representation.DefaultVersion;
import org.eolang.jeo.representation.bytecode.BytecodeClassProperties;

/**
Expand Down Expand Up @@ -60,7 +62,14 @@ public XmlClassProperties(final XMLDocument clazz) {
* @return Bytecode version.
*/
int version() {
return new HexString(this.clazz.xpath("./o[@name='version']/text()").get(0)).decodeAsInt();
final List<String> version = this.clazz.xpath("./o[@name='version']/text()");
final int result;
if (version.isEmpty()) {
result = new DefaultVersion().bytecode();
} else {
result = new HexString(version.get(0)).decodeAsInt();
}
return result;
}

/**
Expand Down

1 comment on commit 6d8a626

@0pdd
Copy link

@0pdd 0pdd commented on 6d8a626 Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 488-6ff6c12e discovered in src/main/java/org/eolang/jeo/representation/bytecode/CustomClassWriter.java) and submitted as #528. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.