diff --git a/pom.xml b/pom.xml index c7134f55b..331cf4d5a 100644 --- a/pom.xml +++ b/pom.xml @@ -244,6 +244,14 @@ SOFTWARE. + + maven-invoker-plugin + + + custom-transformations/pom.xml + + + diff --git a/src/it/custom-transformations/src/main/java/org/eolang/innerclasses/Top.java b/src/it/custom-transformations/src/main/java/org/eolang/innerclasses/Top.java new file mode 100644 index 000000000..a38f7225b --- /dev/null +++ b/src/it/custom-transformations/src/main/java/org/eolang/innerclasses/Top.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.eolang.innerclasses; + +public class Top { + + public void print() { + new TopInnerStatic().print(); + this.new TopInnerInstance().print(); + } + + private static class TopInnerStatic { + public void print() { + System.out.println("TopInnerStatic"); + } + } + + private class TopInnerInstance { + public void print() { + System.out.println("TopInnerInstance"); + } + } +} \ No newline at end of file diff --git a/src/it/custom-transformations/src/main/java/org/eolang/spring/SwitchInsideLoopCase.java b/src/it/custom-transformations/src/main/java/org/eolang/spring/SwitchInsideLoopCase.java new file mode 100644 index 000000000..7aadb4aae --- /dev/null +++ b/src/it/custom-transformations/src/main/java/org/eolang/spring/SwitchInsideLoopCase.java @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.eolang.spring; + +public class SwitchInsideLoopCase { + + public int example(byte x) { + for (int i = 0; i < 10; ++i) { + switch (x) { + case 1: + break; + default: + throw new IllegalArgumentException("Unexpected value: " + x); + } + } + return 2; + } + +} \ No newline at end of file diff --git a/src/it/custom-transformations/src/main/java/org/eolang/spring/package-info.java b/src/it/custom-transformations/src/main/java/org/eolang/spring/package-info.java new file mode 100644 index 000000000..9ba1a91b1 --- /dev/null +++ b/src/it/custom-transformations/src/main/java/org/eolang/spring/package-info.java @@ -0,0 +1,29 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +/** + * This package contains all the cases that accidentaly broke `spring-fat` integration test. + * So, all the identified cases are placed here. + * @since 0.3 + */ +package org.eolang.spring; diff --git a/src/it/spring-fat/pom.xml b/src/it/spring-fat/pom.xml index f512d15a0..5c5709794 100644 --- a/src/it/spring-fat/pom.xml +++ b/src/it/spring-fat/pom.xml @@ -91,6 +91,7 @@ SOFTWARE. the test. --> true + true diff --git a/src/main/java/org/eolang/jeo/representation/bytecode/VerifiedClassWriter.java b/src/main/java/org/eolang/jeo/representation/bytecode/VerifiedClassWriter.java index 1ab9bb835..9c0b052e5 100644 --- a/src/main/java/org/eolang/jeo/representation/bytecode/VerifiedClassWriter.java +++ b/src/main/java/org/eolang/jeo/representation/bytecode/VerifiedClassWriter.java @@ -71,7 +71,7 @@ private static void verify(final byte[] bytes) { ); verifier.setClassLoader(Thread.currentThread().getContextClassLoader()); new Analyzer<>(verifier).analyze(clazz.name, method); - } catch (final AnalyzerException exception) { + } catch (final ClassFormatError | AnalyzerException exception) { throw new IllegalStateException( String.format( "Bytecode verification failed for the class '%s' and method '%s'", diff --git a/src/main/java/org/eolang/jeo/representation/directives/DirectivesMethodVisitor.java b/src/main/java/org/eolang/jeo/representation/directives/DirectivesMethodVisitor.java index b835c00d3..3ee3660d2 100644 --- a/src/main/java/org/eolang/jeo/representation/directives/DirectivesMethodVisitor.java +++ b/src/main/java/org/eolang/jeo/representation/directives/DirectivesMethodVisitor.java @@ -25,7 +25,6 @@ import java.util.Iterator; import org.eolang.jeo.representation.DefaultVersion; -import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; @@ -42,6 +41,14 @@ * Probably in this issue you will need to add some additional * parsing logic. * See {@link #visitInvokeDynamicInsn} method. + * @todo #488:90min Implement the rest of instruction mappings to XMIR directives. + * Currently we left several instructions unimplemented: + * {@link #visitLookupSwitchInsn}, + * {@link #visitTableSwitchInsn}, + * {@link #visitMultiANewArrayInsn}, + * {@link #visitIincInsn}. + * We need to implement them and add tests for them. + * Don't forget to enable 'custom-transformations' integration test. */ @SuppressWarnings("PMD.TooManyMethods") public final class DirectivesMethodVisitor extends MethodVisitor implements Iterable { @@ -155,11 +162,6 @@ public void visitTryCatchBlock( super.visitTryCatchBlock(start, end, handler, type); } - @Override - public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) { - return super.visitAnnotation(descriptor, visible); - } - @Override public Iterator iterator() { return this.method.iterator();