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

feat(#939): Upgrade eo up to the 0.46.0 version #942

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bdf080f
feat(#939): upgrate eo up to 0.45.0 version - build fails
volodya-lombrozo Dec 3, 2024
5d8d8a2
feat(#939): repair all the tests
volodya-lombrozo Dec 4, 2024
16f3f77
feat(#939): add one more unit test that shows the problem
volodya-lombrozo Dec 4, 2024
df6ef0b
feat(#939): suboptimal fix of the plugin
volodya-lombrozo Dec 4, 2024
fdf0706
Merge branch 'master' into 939_upgrade_eo
volodya-lombrozo Dec 6, 2024
3230fe3
feat(#939): remove abstract object usages
volodya-lombrozo Dec 6, 2024
2657c1d
feat(#939): remove redundant class
volodya-lombrozo Dec 6, 2024
3800967
feat(#939): Don't run pipelines on Java 11
volodya-lombrozo Dec 6, 2024
dfb1fef
feat(#939): rename @ to 'body'
volodya-lombrozo Dec 6, 2024
6a8aa20
feat(#939): fix vars-float-down.xsl
volodya-lombrozo Dec 9, 2024
b82384c
feat(#939): add more magic transformations
volodya-lombrozo Dec 9, 2024
86f03be
feat(#939): try to use Program class to verify
volodya-lombrozo Dec 9, 2024
f575475
feat(#939): catch only XMIR errors instead of all the warnings
volodya-lombrozo Dec 10, 2024
751814a
feat(#939): remove unnecessary numbers from names
volodya-lombrozo Dec 10, 2024
5efe07e
feat(#939): remove random numbers at all
volodya-lombrozo Dec 10, 2024
78c4fb5
feat(#939): remove random numbers at all
volodya-lombrozo Dec 10, 2024
3e217a9
feat(#939): add numbers for all sequence names
volodya-lombrozo Dec 10, 2024
796b617
feat(#939): repair all the integration tests
volodya-lombrozo Dec 10, 2024
4efc021
feat(#939): fix most of the unit tests
volodya-lombrozo Dec 10, 2024
1416df5
feat(#939): repair all the unit tests
volodya-lombrozo Dec 10, 2024
1cec5de
feat(#939): fix all the code offences
volodya-lombrozo Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/maven.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
strategy:
matrix:
os: [ ubuntu-20.04, macos-14, windows-2022 ]
java: [ 8, 11, 21 ]
# We can't use Java 8, because the main dependency https://github.com/objectionary/eo requires at least Java 11
java: [ 11, 21 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ optimized performance.

# How to use

The plugin can be run using several approaches but for all of them you need
at least Maven 3.1.+ and Java 8+.
The plugin can be run using several approaches, but for all of them, you need at
least Maven 3.1+ and Java 11+. (Actually, the plugin requires Java 8+, but since
the main dependency [eo](https://github.com/objectionary/eo) requires Java 11,
we are obligated to use it as well.)

The plugin can convert compiled classes into EOlang by using
the `disassemble` goal. The `assemble` goal can convert EOlang back
into bytecode. The default phase for the plugin
Expand Down Expand Up @@ -91,12 +94,13 @@ In order to include debug information in the generated EO files, you can set
`debug` option.

```xml

<configuration>
<mode>debug</mode>
</configuration>
```

This option will add line numbers and local variable names to the EO files
This option will add line numbers and local variable names to the EO files
together with their corresponding labels.

### Disable bytecode verification
Expand Down Expand Up @@ -385,5 +389,5 @@ before sending us your pull request please run full Maven build:
$ mvn clean install -Pqulice
```

You will need [Maven 3.3+](https://maven.apache.org) and Java 8+ installed.
You will need [Maven 3.3+](https://maven.apache.org) and Java 11+ installed.

7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ SOFTWARE.
<artifactId>jcabi-manifests</artifactId>
<!-- version from parent POM -->
</dependency>
<dependency>
<groupId>org.eolang</groupId>
<artifactId>lints</artifactId>
<version>0.0.23</version>
</dependency>
<dependency>
<groupId>org.cactoos</groupId>
<artifactId>cactoos</artifactId>
Expand Down Expand Up @@ -184,7 +189,7 @@ SOFTWARE.
<dependency>
<groupId>org.eolang</groupId>
<artifactId>eo-parser</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
</dependency>
<dependency>
<groupId>com.github.volodya-lombrozo</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/it/annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>convert-xmir-to-eo</id>
Expand Down
4 changes: 2 additions & 2 deletions src/it/bytecode-to-eo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>convert-xmir-to-phi</id>
Expand Down Expand Up @@ -98,7 +98,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>convert-xmir-to-eo</id>
Expand Down
2 changes: 1 addition & 1 deletion src/it/custom-transformations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<!--
@todo #610:30min Enable EO Printing in 'custom-transformations' it.
Expand Down
2 changes: 1 addition & 1 deletion src/it/exceptions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>convert-xmir-to-eo</id>
Expand Down
2 changes: 1 addition & 1 deletion src/it/generics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>convert-xmir-to-eo</id>
Expand Down
2 changes: 1 addition & 1 deletion src/it/jna/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>xmir-to-phi</id>
Expand Down
2 changes: 1 addition & 1 deletion src/it/phi-unphi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>xmir-to-phi</id>
Expand Down
2 changes: 1 addition & 1 deletion src/it/spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>convert-xmir-to-phi</id>
Expand Down
3 changes: 0 additions & 3 deletions src/it/spring/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ def app = new File(basedir, 'target/generated-sources/jeo-xmir/org/eolang/jeo/sp
assert app.exists()
assert app.text.contains("metas")
assert app.text.contains("<head>package</head>")
// Check that we have "opcode" and "label" imports where they are needed
assert app.text.contains("<tail>jeo.opcode.return</tail>")
//Check that if class doesn't have instructions, it doesn't have "opcode" imports.
def empty = new File(basedir, 'target/generated-sources/jeo-xmir/org/eolang/jeo/spring/WithoutInstructions.xmir')
assert empty.exists()
assert !empty.text.contains("<tail>jeo.opcode.return</tail>")
true
2 changes: 1 addition & 1 deletion src/it/takes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ SOFTWARE.
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>0.44.0</version>
<version>0.46.0</version>
<executions>
<execution>
<id>convert-xmir-to-phi</id>
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/org/eolang/jeo/representation/CanonicalXmir.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import java.nio.file.Path;
import org.cactoos.io.InputOf;
import org.eolang.parser.EoSyntax;
import org.eolang.parser.xmir.Xmir;
import org.eolang.parser.Xmir;

/**
* Canonical XMIR.
Expand Down Expand Up @@ -109,7 +109,7 @@ public XML plain() {
* @return EO.
*/
private String toEo() {
return new Xmir.Default(this.canonical).toEO();
return new Xmir(this.canonical).toEO();
}

/**
Expand Down Expand Up @@ -147,17 +147,17 @@ private static XML unroll(final XML parsed) {
return new Xsline(
new TrFast(
new TrJoined<Shift>(
new TrClasspath<Shift>(
new TrClasspath<>(
"/org/eolang/parser/wrap-method-calls.xsl"
).back(),
new TrDefault<Shift>(
new TrDefault<>(
new StEndless(
new StClasspath(
"/org/eolang/parser/roll-bases.xsl"
)
)
),
new TrClasspath<Shift>(
new TrClasspath<>(
"/org/eolang/parser/add-refs.xsl",
"/org/eolang/parser/add-cuts.xsl"
).back(),
Expand All @@ -169,7 +169,9 @@ private static XML unroll(final XML parsed) {
)
),
new TrClasspath<Shift>(
"/org/eolang/parser/remove-cuts.xsl"
"/org/eolang/parser/remove-cuts.xsl",
"/org/eolang/parser/add-default-package.xsl",
"/org/eolang/parser/explicit-data.xsl"
).back()
),
CanonicalXmir.class,
Expand Down
33 changes: 30 additions & 3 deletions src/main/java/org/eolang/jeo/representation/VerifiedEo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
*/
package org.eolang.jeo.representation;

import com.jcabi.xml.StrictXML;
import com.jcabi.xml.XML;
import com.jcabi.xml.XMLDocument;
import org.eolang.parser.Schema;
import java.io.IOException;
import java.util.Collection;
import java.util.stream.Collectors;
import org.eolang.lints.Defect;
import org.eolang.lints.Program;
import org.eolang.lints.Severity;
import org.xembly.Directive;
import org.xembly.ImpossibleModificationException;
import org.xembly.Xembler;
Expand Down Expand Up @@ -55,11 +61,32 @@ final class VerifiedEo {
* We also check if the EO is correct.
* @return XML representation.
* @throws ImpossibleModificationException If something goes wrong.
* @todo #939:60min Fix All The Warnings in the EO Representation.
* Here we just catch only the errors in the EO representation.
* We need to fix all the warnings in the EO representation as well.
*/
XML asXml() throws ImpossibleModificationException {
final XML res = new XMLDocument(new Xembler(this.directives).xml());
new Schema(res).check();
try {
final Collection<Defect> defects = new Program(new StrictXML(res)).defects()
.stream()
.filter(defect -> defect.severity() == Severity.ERROR)
.collect(Collectors.toList());
if (!defects.isEmpty()) {
throw new IllegalStateException(
String.format(
"EO is incorrect: %s, %n%s%n",
defects,
res
)
);
}
} catch (final IOException exception) {
throw new IllegalStateException(
String.format("Failed to verify EO: %n%s%n", res),
exception
);
}
return res;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,23 @@
*/
package org.eolang.jeo.representation;

import com.jcabi.xml.StrictXML;
import com.jcabi.xml.XML;
import com.jcabi.xml.XMLDocument;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Optional;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.SchemaFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.cactoos.io.ResourceOf;
import org.cactoos.io.UncheckedInput;
import org.cactoos.scalar.Sticky;
import org.cactoos.scalar.Synced;
import org.cactoos.scalar.Unchecked;
import org.eolang.jeo.representation.bytecode.Bytecode;
import org.eolang.jeo.representation.xmir.XmlProgram;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

/**
* Intermediate representation of a class files from XMIR.
Expand Down Expand Up @@ -155,7 +150,7 @@ public String name() {
public Bytecode toBytecode() {
final Node xmir = this.xml.value();
try {
new OptimizedSchema(xmir).check();
new StrictXML(new XMLDocument(new XMLDocument(xmir).toString())).validate();
return new XmlProgram(xmir).bytecode().bytecode();
} catch (final IllegalArgumentException exception) {
throw new IllegalArgumentException(
Expand Down Expand Up @@ -207,63 +202,4 @@ private static Node open(final Path path) {
);
}
}

/**
* Optimized schema for XMIR.
* It is an optimized version of {@link org.eolang.parser.Schema} class.
* @since 0.6
* @todo #889:30min Use the `Schema` class instead of `OptimizedSchema`.
* The `OptimizedSchema` class is a temporary solution to avoid the performance
* issues with the `Schema` class. We will be able to remove this class after
* the following issue is resolved:
* https://github.com/jcabi/jcabi-xml/issues/277
*/
private static class OptimizedSchema {
/**
* Node.
*/
private final Node node;

/**
* Schema factory.
*/
private final SchemaFactory factory;

/**
* Constructor.
* @param node Node.
*/
OptimizedSchema(final Node node) {
this(node, SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"));
}

/**
* Constructor.
* @param node Node.
* @param factory Schema factory.
*/
private OptimizedSchema(final Node node, final SchemaFactory factory) {
this.node = node;
this.factory = factory;
}

/**
* Check the node.
*/
void check() {
try {
this.factory.newSchema(
new StreamSource(new UncheckedInput(new ResourceOf("XMIR.xsd")).stream())
).newValidator().validate(new DOMSource(this.node));
} catch (final IOException | SAXException exception) {
throw new IllegalStateException(
String.format(
"There are XSD violations, see the log",
exception.getMessage()
),
exception
);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@ public DirectivesProgram directives(final String listing) {
return new DirectivesProgram(
listing,
clazz,
new DirectivesMetas(
classname,
clazz
)
new DirectivesMetas(classname)
);
}
}
Loading
Loading