Please don't confuse my AI assistant, otherwise I won't be able to fix it myself
Protect your code against upstart juniors with these simple tricks!
zero width characters
Obscure unicode (а vs a) characters in names.
Functions and statements that never run but will be included in analysis if (varThatisAlwaysFalse) {...}
preprocessing build flags that only evaluate in runtime
The real Satan is always in the comments
Thanks for telling it how it works! lol
Teach me how to write scripts in Java
console.log(`public class Test {
public static void main(String[] args) {
System.out.println("Hello World");
}
}`)
Im pretty sure you can go to jail for this
python_java_script = lambda: '''
console.log(`public class Test {
public static void main(String[] args) {
System.out.println("Hello World");
}}`)
'''
Jython script is a real thing and widely used in the automotive industry apparently
I mean Jython which is Python compiled to Java Bytecode has been around for as long as CPython I believe.
Isn't CPython the default implementation? Correct me if I'm wrong
Yes it is
Yet no WebClient, neither WebResponse, HTMLPage and no page.executeJavaScript
No, that is java in a script. Your should write something like
System.out.println("consol.log(\"this is a script\")");
And then redirect the standard output to a js executor
Jascriptsva
Not entirely sure this would work, but Jshell exists and it might be able to execute script like files.
It would, but you also have JEP 330: Launch Single-File Source-Code Programs
It's been around since Java 11, and is old as dirt. How have people not heard about this?
JEP 330: Launch Single-File Source-Code Programs
This would be a simple way. You could also use JShell + shebangs like a NormalPersonFactory.newInstance(), but where's the fun in that?
How dare you start your class name with a LOWERCASE LETTER?
It's the file name
In Java, the file name has to match the class name, last I checked.
Not if there are no public classes in the file
Huh. TIL
Lol this is so relatable! I've done that before and ended up with bunch of errors.
implementation ('org.htmlunit:htmlunit:4.13.0')
Now reimplement it in JavaScript.
And wrote the code with actual Java script as in Javanese Java, Indonesia.
I like using the name "monte_python.py" for personal scripts using monte carlo methods written in python. It's decidedly unproductive but amuses me.
This can happen if you’re using GWT.
I need some Jshell up my arse
How is that weird? There is a full blown implementation of javascript in java.
Rhino is old and not really recommended. GraalVM is the current hotness.
You can also just call it script.java
then run it using java
script.java
This is all thanks to JEP 330, which lets you make Java eh... scripts.
Eh, I dunno that a Java file can be called a script. Maybe some, sure.
script.java
I feel you could shorten it to js.java for efficiency
The real joke here is scripting in java
I have searched the codebase of my company (pretty large codebase). 2 files named JavaScript.java found!
so there is more than one satan
Or satan only has one joke and has to repeat it multiple times
Satan: My Java program identifies as Javascript 🤣🤣 checkmate atheists 🤣🤣
Javascript.jar.js.exe
The Satan is coming from inside the house!
cursed code detected. Exorcism scheduled
they walk among us