forked from icon-project/goloop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
295 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
javaee/exec/test/java/foundation/icon/ee/tooling/ClassRejectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright 2022 ICON Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package foundation.icon.ee.tooling; | ||
|
||
import foundation.icon.ee.test.SimpleTest; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import score.Context; | ||
|
||
import java.math.BigInteger; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class ClassRejectionTest extends SimpleTest { | ||
|
||
public static class ClassNotInJCL { | ||
public ClassNotInJCL() { | ||
byte[] b = null; | ||
Objects.requireNonNull(b); | ||
} | ||
} | ||
|
||
public static class ClassNotInJCL2 { | ||
public ClassNotInJCL2() { | ||
System.out.println("test"); | ||
} | ||
} | ||
|
||
public static class ClassNotInJCL3 { | ||
public ClassNotInJCL3() { | ||
List<String> list = new ArrayList<>(); | ||
list.add("a"); | ||
Context.println(list.toString()); | ||
} | ||
} | ||
|
||
public static class ClassNotInJCL4 { | ||
public ClassNotInJCL4() { | ||
Map<String, String> map = new HashMap<>(); | ||
map.put("a", "test"); | ||
Context.println(map.toString()); | ||
} | ||
} | ||
|
||
public static class MethodNotSupported { | ||
public MethodNotSupported() { | ||
Context.println("2^10=" + BigInteger.TWO.pow(10)); | ||
} | ||
} | ||
|
||
public static class MethodNotSupported2 { | ||
public MethodNotSupported2() { | ||
String a = "test"; | ||
Context.println(String.format("%s", a)); | ||
} | ||
} | ||
|
||
public static class MethodNotSupported3 { | ||
public MethodNotSupported3() { | ||
Arrays.asList("a", "b"); | ||
} | ||
} | ||
|
||
@Test | ||
public void testOptimize() { | ||
final Class<?>[] cases = new Class[]{ | ||
ClassNotInJCL.class, | ||
ClassNotInJCL2.class, | ||
ClassNotInJCL3.class, | ||
ClassNotInJCL4.class, | ||
MethodNotSupported.class, | ||
MethodNotSupported2.class, | ||
MethodNotSupported3.class, | ||
}; | ||
for (var c : cases) { | ||
Exception e = Assertions.assertThrows( | ||
UnsupportedOperationException.class, | ||
() -> makeRelJar(c)); | ||
System.out.println(e.getMessage()); | ||
} | ||
} | ||
|
||
public static class LambdaPredicate { | ||
public LambdaPredicate() { | ||
var list = List.of("a", "b"); | ||
list.removeIf(e -> e.equals("a")); | ||
} | ||
} | ||
|
||
@Test | ||
public void testLambda() { | ||
Assertions.assertThrows( | ||
UnsupportedOperationException.class, | ||
() -> makeRelJar(LambdaPredicate.class)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
GROUP=foundation.icon | ||
VERSION=0.9.1 | ||
VERSION=0.9.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.