forked from iterate-ch/rococoa
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try to catch exception when invoking a method in ObjCClass
- Loading branch information
Showing
5 changed files
with
62 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
import java.util.concurrent.Executors; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; | ||
import org.rococoa.cocoa.foundation.NSString; | ||
|
@@ -20,29 +19,13 @@ | |
|
||
|
||
/** | ||
* Test1. | ||
* Integration Test. | ||
* | ||
* @author <a href="mailto:[email protected]">Naohide Sano</a> (nsano) | ||
* @version 0.00 2023-06-30 nsano initial version <br> | ||
*/ | ||
public class Test1 { | ||
|
||
@Test | ||
@Disabled | ||
void test1() throws Exception { | ||
// MethodHandle methodHandleFieldDirect = lookup.unreflectGetter(fieldName); | ||
// CallSite callSiteField = new ConstantCallSite(methodHandleFieldDirect); | ||
// methodHandleFieldDirect = callSiteField.dynamicInvoker(); | ||
// name = (String) methodHandleFieldDirect.invokeExact(new Employee()); | ||
// | ||
// | ||
////Lookup invoke dynamic | ||
// methodType = MethodType.methodType(String.class); | ||
// methodHandle = lookup.findVirtual(Employee.class, "getName", methodType); | ||
// CallSite callSiteMethod = new ConstantCallSite(methodHandleFieldDirect); | ||
// methodHandle = callSiteMethod.dynamicInvoker(); | ||
} | ||
|
||
@Test | ||
@DisabledIfEnvironmentVariable(named = "GITHUB_WORKFLOW", matches = ".*") | ||
void test2() throws Exception { | ||
|
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,51 @@ | ||
/* | ||
* Copyright (c) 2024 by Naohide Sano, All rights reserved. | ||
* | ||
* Programmed by Naohide Sano | ||
*/ | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.rococoa.cocoa.foundation.NSArray; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
|
||
/** | ||
* TestCase. | ||
* | ||
* @author <a href="mailto:[email protected]">Naohide Sano</a> (nsano) | ||
* @version 0.00 2024-03-26 nsano initial version <br> | ||
*/ | ||
public class TestCase { | ||
|
||
@Test | ||
@Disabled | ||
void test1() throws Exception { | ||
// MethodHandle methodHandleFieldDirect = lookup.unreflectGetter(fieldName); | ||
// CallSite callSiteField = new ConstantCallSite(methodHandleFieldDirect); | ||
// methodHandleFieldDirect = callSiteField.dynamicInvoker(); | ||
// name = (String) methodHandleFieldDirect.invokeExact(new Employee()); | ||
// | ||
// | ||
////Lookup invoke dynamic | ||
// methodType = MethodType.methodType(String.class); | ||
// methodHandle = lookup.findVirtual(Employee.class, "getName", methodType); | ||
// CallSite callSiteMethod = new ConstantCallSite(methodHandleFieldDirect); | ||
// methodHandle = callSiteMethod.dynamicInvoker(); | ||
} | ||
|
||
NSArray array() { | ||
return null; | ||
} | ||
|
||
@Test | ||
void test2() throws Exception { | ||
NSArray array = array(); | ||
assertThrows(NullPointerException.class, () -> { | ||
List<?> list = array.toList(); | ||
}); | ||
} | ||
} |