Comments (6)
Bypassing the public Java API to reach into the JVM for the stop()
implementation isn't going to be portable, or supported in the long run. There is indeed no replacement for the stop()
due to its semantics being problematic in the first place (i.e. skips proper unwinding of the stack)
The thing about being a REPL though is that you sort of have control over the compiler, at least for the part that was entered through the REPL. It might be possible to artificially add in a "blackhole"-style empty method at the backedges of all the loops to allow interrupts to have an anchor point to deliver to.
For reference, here's JDK8 HotSpot JVM/Linux's Thread.interrupt()
and Thread.isInterrupted()
's underlying implementation.
https://github.com/openjdk/jdk8u-dev/blob/master/hotspot/src/os/linux/vm/os_linux.cpp#L4508-L4547
Essentially a fenced-write and a fenced-read on a boolean flag on the thread. So yeah the target thread won't notice this until it proactively checks the isInterrupted
flag and does something about it.
from ammonite.
A problem here, IIUC, is that there's no real substitute for Thread.stop
when users want to stop code like while (true) {}
(or any code that keeps the CPU busy doing computation, rather than waiting for I/O and the like).
from ammonite.
I suspect it might be possible to re implement this using JNI, but I'm not familiar enough with the JVM C API to know for sure
from ammonite.
We don't actually have full control over the compiler due to Scala's binary dependencies; people pull in all sorts of Java/Scala jars from maven central or other projects those come pre-compiled.
We could do a bytecode rewrite on load using a JVM agent. That's pretty invasive, and may hurt performance, but I've done it before in https://github.com/lihaoyi/6858
from ammonite.
...SecurityManager is also on track for removal https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/lang/SecurityManager.html
from ammonite.
...SecurityManager is also on track for removal https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/lang/SecurityManager.html
Looks like a secret conspiracy to make threads immortal. 🤣
from ammonite.
Related Issues (20)
- Publish for Scala 2.12.18 and 2.13.11, please? HOT 4
- Scala 2.13 in Scripts by default HOT 2
- Run ut using Scala 2.13.10 on MacOS/Apple Silicon failed
- ammonite.session.ProjectTests.deeplearning should skip on `MacOS/Apple Silicon`
- Error loading ortools native library
- [bug] underscore import for a single `$ivy` dependncy fails (exact import works)
- Please publish for Scala 2.13.12 HOT 12
- Latest CI fails while releasing amm for Scala 2.13 HOT 5
- Ammonite REPL cannot run on Java 21 HOT 2
- running tests failed unable to find utest
- not working in Windows, but found a workaround
- upickle.default.macroRW not working in Ammonite Repl 2.5.11 (Scala 3.2.2 Java 17.0.8.1)
- varargs in main causes errors
- unable to access package-private symbols from .sc files HOT 1
- os.proc.pipeTo() is not available HOT 1
- Deprecate `object $` to avoid unsoundess
- Please publish for Scala 2.12.19 and 2.13.13 HOT 1
- Publish for Scala 3.3.2, 3.3.3 & 3.4.0 HOT 1
- scala.reflect.internal.FatalError: bad constant pool index: 0 at pos HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ammonite.