Skip to content

Commit

Permalink
More stub code for native methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Horcrux7 committed Jan 8, 2022
1 parent 914c717 commit b90523d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Volker Berlin (i-net software)
* Copyright 2020 - 2022 Volker Berlin (i-net software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,4 +47,28 @@ static int hashCode(Object x) {
@Import( js="(val)=>Object.assign({},val)")
@Replace( "java/lang/Object.clone()Ljava/lang/Object;" )
private static native Object clone0();

/**
* Replacement for {@link Object#notify()}
*/
@Replace( "java/lang/Object.notify()V" )
public final void notify0() {
// nothing
}

/**
* Replacement for {@link Object#notifyAll()}
*/
@Replace( "java/lang/Object.notifyAll()V" )
public final void notifyAll0() {
// nothing
}

/**
* Replacement for {@link Object#wait(long)}
*/
@Replace( "java/lang/Object.wait(J)V" )
public final void wait0(long timeout) {
// nothing
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Volker Berlin (i-net software)
* Copyright 2021 - 2022 Volker Berlin (i-net software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@
/**
* Replacement methods for the class java.lang.SecurityManager.
*
* 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.
*
* @author Volker Berlin
*/
class ReplacementForSecurityManager {
Expand Down Expand Up @@ -57,4 +59,20 @@ public void checkPermission(Permission perm) {
protected Class[] getClassContext() {
return null;
}

/**
* Replacement for {@link SecurityManager#checkAccess(Thread)}
*/
@Replace( "java/lang/SecurityManager.checkAccess(Ljava/lang/Thread;)V" )
public void checkAccess(Thread t) {
// nothing
}

/**
* Replacement for {@link SecurityManager#checkAccess(ThreadGroup)}
*/
@Replace( "java/lang/SecurityManager.checkAccess(Ljava/lang/ThreadGroup;)V" )
public void checkAccess(ThreadGroup g) {
// nothing
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Volker Berlin (i-net software)
* Copyright 2021 - 2022 Volker Berlin (i-net software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,13 +22,7 @@
*
* @author Volker Berlin
*/
@Replace( "java/security/AccessControlContext" )
class ReplacementForAccessControlContext {

/**
* Replacement for getDebug().
*/
@Replace( "java/security/AccessControlContext.getDebug()Lsun/security/util/Debug;" )
static Object getDebug() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Volker Berlin (i-net software)
* Copyright 2020 - 2022 Volker Berlin (i-net software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -91,4 +91,12 @@ private static AccessControlContext getInheritedAccessControlContext() {
public static void checkPermission(Permission perm) {
// nothing, there is no security check in WASM
}

/**
* Replacement for getContext().
*/
@Replace( "java/security/AccessController.getContext()Ljava/security/AccessControlContext;" )
public static ReplacementForAccessControlContext getContext() {
return new ReplacementForAccessControlContext();
}
}

0 comments on commit b90523d

Please sign in to comment.