Skip to content

Commit b90523d

Browse files
committed
More stub code for native methods
1 parent 914c717 commit b90523d

File tree

4 files changed

+55
-11
lines changed

4 files changed

+55
-11
lines changed

src/de/inetsoftware/jwebassembly/api/java/lang/ReplacementForObject.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 Volker Berlin (i-net software)
2+
* Copyright 2020 - 2022 Volker Berlin (i-net software)
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,4 +47,28 @@ static int hashCode(Object x) {
4747
@Import( js="(val)=>Object.assign({},val)")
4848
@Replace( "java/lang/Object.clone()Ljava/lang/Object;" )
4949
private static native Object clone0();
50+
51+
/**
52+
* Replacement for {@link Object#notify()}
53+
*/
54+
@Replace( "java/lang/Object.notify()V" )
55+
public final void notify0() {
56+
// nothing
57+
}
58+
59+
/**
60+
* Replacement for {@link Object#notifyAll()}
61+
*/
62+
@Replace( "java/lang/Object.notifyAll()V" )
63+
public final void notifyAll0() {
64+
// nothing
65+
}
66+
67+
/**
68+
* Replacement for {@link Object#wait(long)}
69+
*/
70+
@Replace( "java/lang/Object.wait(J)V" )
71+
public final void wait0(long timeout) {
72+
// nothing
73+
}
5074
}

src/de/inetsoftware/jwebassembly/api/java/lang/ReplacementForSecurityManager.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Volker Berlin (i-net software)
2+
* Copyright 2021 - 2022 Volker Berlin (i-net software)
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@
2222
/**
2323
* Replacement methods for the class java.lang.SecurityManager.
2424
*
25+
* We does not want use a SecurityManager and we does not want compile all the classes that the SecurityManager need that we override it with a stub.
26+
*
2527
* @author Volker Berlin
2628
*/
2729
class ReplacementForSecurityManager {
@@ -57,4 +59,20 @@ public void checkPermission(Permission perm) {
5759
protected Class[] getClassContext() {
5860
return null;
5961
}
62+
63+
/**
64+
* Replacement for {@link SecurityManager#checkAccess(Thread)}
65+
*/
66+
@Replace( "java/lang/SecurityManager.checkAccess(Ljava/lang/Thread;)V" )
67+
public void checkAccess(Thread t) {
68+
// nothing
69+
}
70+
71+
/**
72+
* Replacement for {@link SecurityManager#checkAccess(ThreadGroup)}
73+
*/
74+
@Replace( "java/lang/SecurityManager.checkAccess(Ljava/lang/ThreadGroup;)V" )
75+
public void checkAccess(ThreadGroup g) {
76+
// nothing
77+
}
6078
}

src/de/inetsoftware/jwebassembly/api/java/security/ReplacementForAccessControlContext.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 Volker Berlin (i-net software)
2+
* Copyright 2021 - 2022 Volker Berlin (i-net software)
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,13 +22,7 @@
2222
*
2323
* @author Volker Berlin
2424
*/
25+
@Replace( "java/security/AccessControlContext" )
2526
class ReplacementForAccessControlContext {
2627

27-
/**
28-
* Replacement for getDebug().
29-
*/
30-
@Replace( "java/security/AccessControlContext.getDebug()Lsun/security/util/Debug;" )
31-
static Object getDebug() {
32-
return null;
33-
}
3428
}

src/de/inetsoftware/jwebassembly/api/java/security/ReplacementForAccessController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 Volker Berlin (i-net software)
2+
* Copyright 2020 - 2022 Volker Berlin (i-net software)
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -91,4 +91,12 @@ private static AccessControlContext getInheritedAccessControlContext() {
9191
public static void checkPermission(Permission perm) {
9292
// nothing, there is no security check in WASM
9393
}
94+
95+
/**
96+
* Replacement for getContext().
97+
*/
98+
@Replace( "java/security/AccessController.getContext()Ljava/security/AccessControlContext;" )
99+
public static ReplacementForAccessControlContext getContext() {
100+
return new ReplacementForAccessControlContext();
101+
}
94102
}

0 commit comments

Comments
 (0)