Browse Source
* commit '998cfc79785130a7a9c4f98e02fbb5c1dda5903c': KERNEL-6186 升级J2V8 & V8bugfix/10.0
superman
4 years ago
14 changed files with 189 additions and 12 deletions
@ -0,0 +1,5 @@
|
||||
package com.eclipsesource.v8; |
||||
|
||||
public interface SignatureProvider { |
||||
public byte[] getSignature(String uri); |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.eclipsesource.v8; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-11-26 |
||||
*/ |
||||
public class V8OutOfMemoryError extends V8RuntimeException { |
||||
|
||||
V8OutOfMemoryError(final String message) { |
||||
super(message); |
||||
} |
||||
|
||||
V8OutOfMemoryError() { |
||||
super(); |
||||
} |
||||
} |
@ -0,0 +1,7 @@
|
||||
package com.eclipsesource.v8.inspector; |
||||
|
||||
public interface DebuggerConnectionListener { |
||||
public void onDebuggerConnected(); |
||||
|
||||
public void onDebuggerDisconnected(); |
||||
} |
@ -0,0 +1,67 @@
|
||||
package com.eclipsesource.v8.inspector; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import com.eclipsesource.v8.V8; |
||||
import com.eclipsesource.v8.V8Object; |
||||
|
||||
public class V8Inspector { |
||||
|
||||
private V8 runtime; |
||||
private long inspectorPtr = 0; |
||||
private boolean waitingForConnection = true; |
||||
private List<DebuggerConnectionListener> debuggerConnectionListeners; |
||||
|
||||
protected V8Inspector(final V8 runtime, final V8InspectorDelegate inspectorDelegate, final String contextName) { |
||||
this.runtime = runtime; |
||||
inspectorPtr = runtime.createInspector(inspectorDelegate, contextName); |
||||
debuggerConnectionListeners = new ArrayList<DebuggerConnectionListener>(); |
||||
} |
||||
|
||||
public static V8Inspector createV8Inspector(final V8 runtime, final V8InspectorDelegate inspectorDelegate, final String contextName) { |
||||
return new V8Inspector(runtime, inspectorDelegate, contextName); |
||||
} |
||||
|
||||
public static V8Inspector createV8Inspector(final V8 runtime, final V8InspectorDelegate inspectorDelegate) { |
||||
return new V8Inspector(runtime, inspectorDelegate, null); |
||||
} |
||||
|
||||
public void dispatchProtocolMessage(final String protocolMessage) { |
||||
try { |
||||
runtime.dispatchProtocolMessage(inspectorPtr, protocolMessage); |
||||
if (waitingForConnection) { |
||||
verifyDebuggerConnection(protocolMessage); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public void addDebuggerConnectionListener(final DebuggerConnectionListener listener) { |
||||
debuggerConnectionListeners.add(listener); |
||||
} |
||||
|
||||
public void removeDebuggerConnectionListener(final DebuggerConnectionListener listener) { |
||||
debuggerConnectionListeners.remove(listener); |
||||
} |
||||
|
||||
private void verifyDebuggerConnection(final String protocolMessage) { |
||||
V8Object json = null; |
||||
try { |
||||
json = runtime.executeObjectScript("JSON.parse(JSON.stringify(" + protocolMessage + "))"); |
||||
if (json.getString("method").equals("Runtime.runIfWaitingForDebugger")) { |
||||
waitingForConnection = false; |
||||
runtime.schedulePauseOnNextStatement(inspectorPtr, ""); |
||||
for (DebuggerConnectionListener listener : debuggerConnectionListeners) { |
||||
listener.onDebuggerConnected(); |
||||
} |
||||
} |
||||
} finally { |
||||
if (json != null) { |
||||
json.close(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,7 @@
|
||||
package com.eclipsesource.v8.inspector; |
||||
|
||||
public interface V8InspectorDelegate { |
||||
public void onResponse(String message); |
||||
|
||||
public void waitFrontendMessageOnPause(); |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue