From de6af3e1a7e60f4a195b133b107be582193ef494 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Wed, 17 Apr 2024 17:51:16 +0300 Subject: [PATCH 01/20] #3058: Fixed access modifier in EOorg/EOeolang/ --- .../src/main/java/EOorg/EOeolang/EOcage$EOencaged$EOencage.java | 2 +- .../main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" | 2 +- .../src/main/java/EOorg/EOeolang/EOcage$EO\317\206.java" | 2 +- eo-runtime/src/main/java/EOorg/EOeolang/EOio/Input.java | 2 +- .../EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOread.java | 2 +- .../EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOwrite.java | 2 +- .../src/main/java/EOorg/EOeolang/EOmalloc$EO\317\206.java" | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EOencage.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EOencage.java index 53032e2f9a..2cd8a46b57 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EOencage.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EOencage.java @@ -44,7 +44,7 @@ */ @Versionized @XmirObject(oname = "cage.encaged.encage") -final class EOcage$EOencaged$EOencage extends PhDefault implements Atom { +public final class EOcage$EOencaged$EOencage extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma diff --git "a/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" "b/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" index 589bbdcc88..90fcc6a66c 100644 --- "a/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" +++ "b/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" @@ -43,7 +43,7 @@ */ @Versionized @XmirObject(oname = "cage.encaged.@") -final class EOcage$EOencaged$EOφ extends PhDefault implements Atom { +public final class EOcage$EOencaged$EOφ extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma diff --git "a/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EO\317\206.java" "b/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EO\317\206.java" index 54b390702e..57fc77b535 100644 --- "a/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EO\317\206.java" +++ "b/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EO\317\206.java" @@ -42,7 +42,7 @@ */ @Versionized @XmirObject(oname = "cage.@") -final class EOcage$EOφ extends PhDefault implements Atom { +public final class EOcage$EOφ extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOio/Input.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOio/Input.java index 97a01b0eea..619fc1e24c 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOio/Input.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOio/Input.java @@ -39,7 +39,7 @@ * @since 0.28.0 */ @Versionized -public final class Input { +final class Input { /** * Default input. */ diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOread.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOread.java index cdc252de8e..7d5f87704a 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOread.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOread.java @@ -45,7 +45,7 @@ */ @Versionized @XmirObject(oname = "malloc.pointer.read") -final class EOmalloc$EOmemory_block_pointer$EOread extends PhDefault implements Atom { +public final class EOmalloc$EOmemory_block_pointer$EOread extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOwrite.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOwrite.java index 8de3f1ca71..7eb6ca1a9b 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOwrite.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOmemory_block_pointer$EOwrite.java @@ -46,7 +46,7 @@ */ @Versionized @XmirObject(oname = "malloc.pointer.write") -final class EOmalloc$EOmemory_block_pointer$EOwrite extends PhDefault implements Atom { +public final class EOmalloc$EOmemory_block_pointer$EOwrite extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma diff --git "a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EO\317\206.java" "b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EO\317\206.java" index 8eef779d81..575e197479 100644 --- "a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EO\317\206.java" +++ "b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EO\317\206.java" @@ -44,7 +44,7 @@ */ @Versionized @XmirObject(oname = "malloc.@") -final class EOmalloc$EOφ extends PhDefault implements Atom { +public final class EOmalloc$EOφ extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma From f52a52cd6336fb5b5e8239b7a1fe1eb5679e6dcc Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Fri, 26 Apr 2024 19:24:02 +0300 Subject: [PATCH 02/20] #3058: groovy checker, that EO classes are public --- .../groovy/check-eo-classes-are-public.groovy | 75 +++++++++++++++++++ eo-runtime/src/test/groovy/verify.groovy | 3 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy diff --git a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy new file mode 100644 index 0000000000..18f1c56f4f --- /dev/null +++ b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy @@ -0,0 +1,75 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2016-2024 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. + */ + +import com.sun.org.apache.bcel.internal.classfile.ClassParser +import com.sun.org.apache.bcel.internal.classfile.JavaClass +import java.nio.file.Files +import java.nio.file.Path +import java.util.stream.Collectors +import java.util.stream.Stream + +println 'Verify that all java classes named with EO are public' +Path[] sources = [ + basedir.toPath().resolve("target").resolve("classes"), + basedir.toPath().resolve("target").resolve("test-classes"), +] +Collection violations = stream_of(sources) + .filter(it -> { + println(it.toString()) + it.toString().endsWith(".class") && + it.toFile().getName().startsWith("EO") + }) + .map(path -> new ClassParser(path.toString()).parse()) + .filter (clazz -> should_be_public(clazz)) + .filter (clazz -> !clazz.isPublic()) + .collect(Collectors.toList()) +if (!violations.isEmpty()) { + throw new IllegalStateException( + String.format( + "Not all EO classes are public: %s\n", + violations + ) + ) +} + +static Stream stream_of(Path[] paths) { + println("start") + Stream accum = Stream.empty() + println("mid") + for (path in paths) { + accum = Stream.concat( + accum, + Files.walk(path) + ) + println("mid") + } + println("finish") + return accum +} + +static boolean should_be_public(JavaClass clazz) { + return clazz.className.startsWith("EO") && + !clazz.isNested() && + !clazz.className.endsWith("Test") +} diff --git a/eo-runtime/src/test/groovy/verify.groovy b/eo-runtime/src/test/groovy/verify.groovy index de9044a168..a82126e760 100644 --- a/eo-runtime/src/test/groovy/verify.groovy +++ b/eo-runtime/src/test/groovy/verify.groovy @@ -33,7 +33,8 @@ Path folder = basedir.toPath().resolve("src").resolve("test").resolve("groovy") tests = [ 'check-folders-numbering.groovy', 'check-all-java-classes-compiled.groovy', - 'check-runtime-deps.groovy' + 'check-runtime-deps.groovy', + 'check-eo-classes-are-public.groovy' ] for (it in tests) { def res = evaluate folder.resolve(it).toFile() From 38413268b24db4bec16d376690951120fe2ee7f1 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Fri, 26 Apr 2024 19:24:22 +0300 Subject: [PATCH 03/20] #3058: should be public --- eo-runtime/src/test/java/EOorg/EOeolang/EOfailed.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EOfailed.java b/eo-runtime/src/test/java/EOorg/EOeolang/EOfailed.java index 8421c167a7..acab47730c 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EOfailed.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EOfailed.java @@ -40,5 +40,5 @@ "JTCOP.RuleCorrectTestName", "JTCOP.RuleInheritanceInTests" }) -final class EOfailed extends PhDefault { +public final class EOfailed extends PhDefault { } From 34f79523dd3f8641bd932f1c3ac71523072ffd28 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Fri, 26 Apr 2024 20:39:54 +0300 Subject: [PATCH 04/20] #3058: correct filter --- .../groovy/check-eo-classes-are-public.groovy | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy index 18f1c56f4f..b5c75c51f0 100644 --- a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy +++ b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy @@ -31,45 +31,47 @@ import java.util.stream.Stream println 'Verify that all java classes named with EO are public' Path[] sources = [ - basedir.toPath().resolve("target").resolve("classes"), - basedir.toPath().resolve("target").resolve("test-classes"), + basedir.toPath().resolve("target").resolve("classes"), + basedir.toPath().resolve("target").resolve("test-classes"), ] Collection violations = stream_of(sources) .filter(it -> { - println(it.toString()) - it.toString().endsWith(".class") && - it.toFile().getName().startsWith("EO") + return it.toString().endsWith(".class") && + it.toFile().getName().startsWith("EO") }) .map(path -> new ClassParser(path.toString()).parse()) - .filter (clazz -> should_be_public(clazz)) - .filter (clazz -> !clazz.isPublic()) + .filter (clazz -> IsEoClass(clazz)) + .filter (clazz -> { + return !clazz.isPublic() + }) .collect(Collectors.toList()) if (!violations.isEmpty()) { throw new IllegalStateException( - String.format( - "Not all EO classes are public: %s\n", - violations - ) + String.format( + "Not all EO classes are public: %s\n", + violations + ) ) } static Stream stream_of(Path[] paths) { - println("start") - Stream accum = Stream.empty() + println("start") + Stream accum = Stream.empty() + println("mid") + for (path in paths) { + accum = Stream.concat( + accum, + Files.walk(path) + ) println("mid") - for (path in paths) { - accum = Stream.concat( - accum, - Files.walk(path) - ) - println("mid") - } - println("finish") - return accum + } + println("finish") + return accum } -static boolean should_be_public(JavaClass clazz) { - return clazz.className.startsWith("EO") && - !clazz.isNested() && - !clazz.className.endsWith("Test") +static boolean IsEoClass(JavaClass clazz) { + return clazz.className.startsWith("EO") && + ("org.eolang.Phi" in clazz.getInterfaceNames() || + "org.eolang.PhDefault" == clazz.getSuperclassName()) && + !clazz.isNested() } From 5f8d70ca0c16eabcbebce1a7fe027aa488f09336 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Fri, 26 Apr 2024 20:49:28 +0300 Subject: [PATCH 05/20] #3058: removed println --- .../src/test/groovy/check-eo-classes-are-public.groovy | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy index b5c75c51f0..65a2d9978b 100644 --- a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy +++ b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy @@ -29,7 +29,6 @@ import java.nio.file.Path import java.util.stream.Collectors import java.util.stream.Stream -println 'Verify that all java classes named with EO are public' Path[] sources = [ basedir.toPath().resolve("target").resolve("classes"), basedir.toPath().resolve("target").resolve("test-classes"), @@ -44,6 +43,7 @@ Collection violations = stream_of(sources) .filter (clazz -> { return !clazz.isPublic() }) + .map (clazz -> clazz.getClassName()) .collect(Collectors.toList()) if (!violations.isEmpty()) { throw new IllegalStateException( @@ -55,17 +55,13 @@ if (!violations.isEmpty()) { } static Stream stream_of(Path[] paths) { - println("start") Stream accum = Stream.empty() - println("mid") for (path in paths) { accum = Stream.concat( accum, Files.walk(path) ) - println("mid") } - println("finish") return accum } From 51a11a83d9778160534b0dd70fd32496ba354be3 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Fri, 26 Apr 2024 20:49:41 +0300 Subject: [PATCH 06/20] #3058: must be public --- .../java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOread.java | 2 +- .../java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOwrite.java | 2 +- .../src/main/java/EOorg/EOeolang/EOmalloc$EOof$EO\317\206.java" | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOread.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOread.java index 5f9ff39c03..2f4ff9bcb3 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOread.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOread.java @@ -45,7 +45,7 @@ */ @Versionized @XmirObject(oname = "malloc.of.allocated.read") -final class EOmalloc$EOof$EOallocated$EOread extends PhDefault implements Atom { +public final class EOmalloc$EOof$EOallocated$EOread extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma diff --git a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOwrite.java b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOwrite.java index ba97da96ad..61fd877b05 100644 --- a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOwrite.java +++ b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOwrite.java @@ -46,7 +46,7 @@ */ @Versionized @XmirObject(oname = "malloc.of.allocated.write") -final class EOmalloc$EOof$EOallocated$EOwrite extends PhDefault implements Atom { +public final class EOmalloc$EOof$EOallocated$EOwrite extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma diff --git "a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EO\317\206.java" "b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EO\317\206.java" index 11a3844fec..add7ab9fef 100644 --- "a/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EO\317\206.java" +++ "b/eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EO\317\206.java" @@ -44,7 +44,7 @@ */ @Versionized @XmirObject(oname = "malloc.of.@") -final class EOmalloc$EOof$EOφ extends PhDefault implements Atom { +public final class EOmalloc$EOof$EOφ extends PhDefault implements Atom { /** * Ctor. * @param sigma Sigma From 3b27d45cb0e2bcd2bda84882bfb298dadc7c50e7 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Fri, 26 Apr 2024 20:59:21 +0300 Subject: [PATCH 07/20] #3058: snake case --- .../test/groovy/check-eo-classes-are-public.groovy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy index 65a2d9978b..f452a1e79b 100644 --- a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy +++ b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy @@ -39,7 +39,7 @@ Collection violations = stream_of(sources) it.toFile().getName().startsWith("EO") }) .map(path -> new ClassParser(path.toString()).parse()) - .filter (clazz -> IsEoClass(clazz)) + .filter (clazz -> is_eo_class(clazz)) .filter (clazz -> { return !clazz.isPublic() }) @@ -47,10 +47,10 @@ Collection violations = stream_of(sources) .collect(Collectors.toList()) if (!violations.isEmpty()) { throw new IllegalStateException( - String.format( - "Not all EO classes are public: %s\n", - violations - ) + String.format( + "Not all EO classes are public: %s\n", + violations + ) ) } @@ -65,7 +65,7 @@ static Stream stream_of(Path[] paths) { return accum } -static boolean IsEoClass(JavaClass clazz) { +static boolean is_eo_class(JavaClass clazz) { return clazz.className.startsWith("EO") && ("org.eolang.Phi" in clazz.getInterfaceNames() || "org.eolang.PhDefault" == clazz.getSuperclassName()) && From 9eb8ad4a0d17dc9ef6c13d8fd2b0a380c37eeb8b Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Fri, 26 Apr 2024 21:23:53 +0300 Subject: [PATCH 08/20] #3058: Add dependency to groovy --- eo-runtime/pom.xml | 5 +++++ .../src/test/groovy/check-eo-classes-are-public.groovy | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml index f7febb73c4..ebf3ac178b 100644 --- a/eo-runtime/pom.xml +++ b/eo-runtime/pom.xml @@ -251,6 +251,11 @@ SOFTWARE. groovy-xml 3.0.21 + + org.apache.bcel + bcel + 5.2 + diff --git a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy index f452a1e79b..69dffb85f6 100644 --- a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy +++ b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy @@ -66,7 +66,7 @@ static Stream stream_of(Path[] paths) { } static boolean is_eo_class(JavaClass clazz) { - return clazz.className.startsWith("EO") && + return clazz.getClassName().startsWith("EO") && ("org.eolang.Phi" in clazz.getInterfaceNames() || "org.eolang.PhDefault" == clazz.getSuperclassName()) && !clazz.isNested() From aa68d37822a90bf1cfe79dab005a833814e551c0 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sat, 27 Apr 2024 20:01:36 +0300 Subject: [PATCH 09/20] #3058: moved dependency into other place --- eo-runtime/pom.xml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml index ebf3ac178b..6992384a67 100644 --- a/eo-runtime/pom.xml +++ b/eo-runtime/pom.xml @@ -140,6 +140,12 @@ SOFTWARE. test + + org.apache.bcel + bcel + 5.2 + test + @@ -251,11 +257,6 @@ SOFTWARE. groovy-xml 3.0.21 - - org.apache.bcel - bcel - 5.2 - From 4eb3413b559cffd861ba047a5d08ae43cd09a47a Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 14:39:01 +0300 Subject: [PATCH 10/20] #3058: Made it java test --- eo-runtime/pom.xml | 15 +++- .../groovy/check-eo-classes-are-public.groovy | 73 ------------------- .../EOeolang/EOClassesArePublicTest.java | 71 ++++++++++++++++++ 3 files changed, 83 insertions(+), 76 deletions(-) delete mode 100644 eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy create mode 100644 eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml index 6992384a67..96d3930d16 100644 --- a/eo-runtime/pom.xml +++ b/eo-runtime/pom.xml @@ -141,9 +141,18 @@ SOFTWARE. test - org.apache.bcel - bcel - 5.2 + org.reflections + reflections + 0.10.2 + + + com.google.guava + guava + 33.0.0-jre + + + com.google.guava + guava test diff --git a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy b/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy deleted file mode 100644 index 69dffb85f6..0000000000 --- a/eo-runtime/src/test/groovy/check-eo-classes-are-public.groovy +++ /dev/null @@ -1,73 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2016-2024 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. - */ - -import com.sun.org.apache.bcel.internal.classfile.ClassParser -import com.sun.org.apache.bcel.internal.classfile.JavaClass -import java.nio.file.Files -import java.nio.file.Path -import java.util.stream.Collectors -import java.util.stream.Stream - -Path[] sources = [ - basedir.toPath().resolve("target").resolve("classes"), - basedir.toPath().resolve("target").resolve("test-classes"), -] -Collection violations = stream_of(sources) - .filter(it -> { - return it.toString().endsWith(".class") && - it.toFile().getName().startsWith("EO") - }) - .map(path -> new ClassParser(path.toString()).parse()) - .filter (clazz -> is_eo_class(clazz)) - .filter (clazz -> { - return !clazz.isPublic() - }) - .map (clazz -> clazz.getClassName()) - .collect(Collectors.toList()) -if (!violations.isEmpty()) { - throw new IllegalStateException( - String.format( - "Not all EO classes are public: %s\n", - violations - ) - ) -} - -static Stream stream_of(Path[] paths) { - Stream accum = Stream.empty() - for (path in paths) { - accum = Stream.concat( - accum, - Files.walk(path) - ) - } - return accum -} - -static boolean is_eo_class(JavaClass clazz) { - return clazz.getClassName().startsWith("EO") && - ("org.eolang.Phi" in clazz.getInterfaceNames() || - "org.eolang.PhDefault" == clazz.getSuperclassName()) && - !clazz.isNested() -} diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java new file mode 100644 index 0000000000..bfe871e659 --- /dev/null +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java @@ -0,0 +1,71 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2024 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 EOorg.EOeolang; + +import com.google.common.reflect.ClassPath; +import com.jcabi.log.Logger; +import org.eolang.Phi; +import java.io.IOException; +import java.lang.reflect.Modifier; +import java.util.Set; +import java.util.stream.Collectors; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; + +/** + * Test that all EO.. classes are public. + */ +public class EOClassesArePublicTest { + + @Test + public void arePublic() throws IOException { + final Set> clazzes = ClassPath.from(ClassLoader.getSystemClassLoader()) + .getAllClasses() + .stream() + .filter(clazz -> clazz.getPackageName() + .equalsIgnoreCase("EOorg.EOeolang")) + .map(ClassPath.ClassInfo::load) + .filter(EOClassesArePublicTest::isEoClass) + .collect(Collectors.toSet()); + assert !clazzes.isEmpty(); + Logger.info(this.getClass(), "Found %d EO classes", clazzes.size()); + MatcherAssert.assertThat( + clazzes.stream() + .filter(clazz -> Modifier.isPublic(clazz.getModifiers())) + .collect(Collectors.toList()), + Matchers.empty() + ); + } + + /** + * Is EO.. class and is instance of {@link Phi}. + * @param clazz Class. + * @return true if is. + */ + private static boolean isEoClass(final Class clazz) { + return clazz.getSimpleName().startsWith("EO") && + Phi.class.isAssignableFrom(clazz); + } +} From d79b133224cfb310beb4fe6b7d3ce2ef3217043d Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 14:49:28 +0300 Subject: [PATCH 11/20] #3058: Made it java test --- .../src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java index bfe871e659..d4d9dcc1b4 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java @@ -53,7 +53,7 @@ public void arePublic() throws IOException { Logger.info(this.getClass(), "Found %d EO classes", clazzes.size()); MatcherAssert.assertThat( clazzes.stream() - .filter(clazz -> Modifier.isPublic(clazz.getModifiers())) + .filter(clazz -> !Modifier.isPublic(clazz.getModifiers())) .collect(Collectors.toList()), Matchers.empty() ); From 7c18e1b723ec686358a57d5d792f6042fff1b387 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 14:58:51 +0300 Subject: [PATCH 12/20] #3058: Made it java test --- eo-runtime/src/test/groovy/verify.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eo-runtime/src/test/groovy/verify.groovy b/eo-runtime/src/test/groovy/verify.groovy index a82126e760..de9044a168 100644 --- a/eo-runtime/src/test/groovy/verify.groovy +++ b/eo-runtime/src/test/groovy/verify.groovy @@ -33,8 +33,7 @@ Path folder = basedir.toPath().resolve("src").resolve("test").resolve("groovy") tests = [ 'check-folders-numbering.groovy', 'check-all-java-classes-compiled.groovy', - 'check-runtime-deps.groovy', - 'check-eo-classes-are-public.groovy' + 'check-runtime-deps.groovy' ] for (it in tests) { def res = evaluate folder.resolve(it).toFile() From b5e9642713e54be83885b7ce0ffc86f59faa5d40 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 15:18:44 +0300 Subject: [PATCH 13/20] #3058: Edited pom --- eo-runtime/pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml index 96d3930d16..0f62a38d47 100644 --- a/eo-runtime/pom.xml +++ b/eo-runtime/pom.xml @@ -140,16 +140,6 @@ SOFTWARE. test - - org.reflections - reflections - 0.10.2 - - - com.google.guava - guava - 33.0.0-jre - com.google.guava guava From 9066bc16135cd2dd7067d65ee7606bfff752eb5f Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 15:19:23 +0300 Subject: [PATCH 14/20] #3058: violations --- .../EOeolang/EOClassesArePublicTest.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java index d4d9dcc1b4..d09ecf2599 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java @@ -21,23 +21,27 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +/* + * @checkstyle PackageNameCheck (10 lines) + */ package EOorg.EOeolang; import com.google.common.reflect.ClassPath; import com.jcabi.log.Logger; -import org.eolang.Phi; import java.io.IOException; import java.lang.reflect.Modifier; import java.util.Set; import java.util.stream.Collectors; +import org.eolang.Phi; +import org.junit.jupiter.api.Test; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.jupiter.api.Test; /** * Test that all EO.. classes are public. + * @since 0.38 */ -public class EOClassesArePublicTest { +public class EoClassesArePublicTest { @Test public void arePublic() throws IOException { @@ -47,14 +51,14 @@ public void arePublic() throws IOException { .filter(clazz -> clazz.getPackageName() .equalsIgnoreCase("EOorg.EOeolang")) .map(ClassPath.ClassInfo::load) - .filter(EOClassesArePublicTest::isEoClass) + .filter(EoClassesArePublicTest::isEoClass) .collect(Collectors.toSet()); assert !clazzes.isEmpty(); Logger.info(this.getClass(), "Found %d EO classes", clazzes.size()); MatcherAssert.assertThat( - clazzes.stream() - .filter(clazz -> !Modifier.isPublic(clazz.getModifiers())) - .collect(Collectors.toList()), + clazzes.stream() + .filter(clazz -> !Modifier.isPublic(clazz.getModifiers())) + .collect(Collectors.toList()), Matchers.empty() ); } @@ -62,10 +66,10 @@ public void arePublic() throws IOException { /** * Is EO.. class and is instance of {@link Phi}. * @param clazz Class. - * @return true if is. + * @return True if is. */ private static boolean isEoClass(final Class clazz) { - return clazz.getSimpleName().startsWith("EO") && - Phi.class.isAssignableFrom(clazz); + return clazz.getSimpleName().startsWith("EO") + && Phi.class.isAssignableFrom(clazz); } } From 45adb4361818542aa1c6eabb06a64a845246bcfe Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 15:22:47 +0300 Subject: [PATCH 15/20] #3058: violations --- .../{EOClassesArePublicTest.java => EoClassesArePublicTest.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename eo-runtime/src/test/java/EOorg/EOeolang/{EOClassesArePublicTest.java => EoClassesArePublicTest.java} (100%) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java similarity index 100% rename from eo-runtime/src/test/java/EOorg/EOeolang/EOClassesArePublicTest.java rename to eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java From b60910c8e4fbee7c7fc8cfc009f69bc927480ff3 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 15:29:46 +0300 Subject: [PATCH 16/20] #3058: violations --- .../src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java index d09ecf2599..dc5feb3119 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java @@ -33,9 +33,9 @@ import java.util.Set; import java.util.stream.Collectors; import org.eolang.Phi; -import org.junit.jupiter.api.Test; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; /** * Test that all EO.. classes are public. @@ -48,8 +48,7 @@ public void arePublic() throws IOException { final Set> clazzes = ClassPath.from(ClassLoader.getSystemClassLoader()) .getAllClasses() .stream() - .filter(clazz -> clazz.getPackageName() - .equalsIgnoreCase("EOorg.EOeolang")) + .filter(clazz -> clazz.getPackageName().equals("EOorg.EOeolang")) .map(ClassPath.ClassInfo::load) .filter(EoClassesArePublicTest::isEoClass) .collect(Collectors.toSet()); From ac4be01a53be365655b2a84a7cb5a37e86ae5e8f Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 15:42:57 +0300 Subject: [PATCH 17/20] #3058: jtcop-maven-plugin:1.2.4:check (default) --- .../src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java index dc5feb3119..04451bdc15 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java @@ -41,6 +41,7 @@ * Test that all EO.. classes are public. * @since 0.38 */ +@SuppressWarnings("JTCOP.RuleAllTestsHaveProductionClass") public class EoClassesArePublicTest { @Test @@ -55,6 +56,7 @@ public void arePublic() throws IOException { assert !clazzes.isEmpty(); Logger.info(this.getClass(), "Found %d EO classes", clazzes.size()); MatcherAssert.assertThat( + "All EO.. classes should be public", clazzes.stream() .filter(clazz -> !Modifier.isPublic(clazz.getModifiers())) .collect(Collectors.toList()), @@ -67,6 +69,7 @@ public void arePublic() throws IOException { * @param clazz Class. * @return True if is. */ + @SuppressWarnings("JTCOP.RulePresentTense") private static boolean isEoClass(final Class clazz) { return clazz.getSimpleName().startsWith("EO") && Phi.class.isAssignableFrom(clazz); From 6383f2265916f6a177b3ba003b2446eba1cef4ca Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Sun, 28 Apr 2024 16:00:57 +0300 Subject: [PATCH 18/20] #3058: jtcop-maven-plugin:1.2.4:check (default) --- .../src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java index 04451bdc15..ebe4c05523 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java @@ -45,6 +45,7 @@ public class EoClassesArePublicTest { @Test + @SuppressWarnings("JTCOP.RulePresentTense") public void arePublic() throws IOException { final Set> clazzes = ClassPath.from(ClassLoader.getSystemClassLoader()) .getAllClasses() @@ -69,7 +70,6 @@ public void arePublic() throws IOException { * @param clazz Class. * @return True if is. */ - @SuppressWarnings("JTCOP.RulePresentTense") private static boolean isEoClass(final Class clazz) { return clazz.getSimpleName().startsWith("EO") && Phi.class.isAssignableFrom(clazz); From 66c72b9e31223684ad91ee99e2f1ddee1b40c6e4 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Thu, 2 May 2024 14:22:15 +0300 Subject: [PATCH 19/20] #3058: Suppress warning "PMD.PackageCase" --- .../src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java index ebe4c05523..158b7dfd0b 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java @@ -41,7 +41,7 @@ * Test that all EO.. classes are public. * @since 0.38 */ -@SuppressWarnings("JTCOP.RuleAllTestsHaveProductionClass") +@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "PMD.PackageCase"}) public class EoClassesArePublicTest { @Test From e4b8c0e3cbbaa27831972fa088d17d138f4e1f58 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Thu, 2 May 2024 14:28:22 +0300 Subject: [PATCH 20/20] #3058: excluded path --- .codacy.yml | 1 + .../src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.codacy.yml b/.codacy.yml index 61e804e4b7..6dff37e697 100644 --- a/.codacy.yml +++ b/.codacy.yml @@ -6,3 +6,4 @@ exclude_paths: - "eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOread.java" - "eo-runtime/src/main/java/EOorg/EOeolang/EOmalloc$EOof$EOallocated$EOwrite.java" - "eo-runtime/src/test/java/EOorg/EOeolang/EOmallocTest.java" + - "eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java" diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java index 158b7dfd0b..ebe4c05523 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EoClassesArePublicTest.java @@ -41,7 +41,7 @@ * Test that all EO.. classes are public. * @since 0.38 */ -@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "PMD.PackageCase"}) +@SuppressWarnings("JTCOP.RuleAllTestsHaveProductionClass") public class EoClassesArePublicTest { @Test