Parsing Java Bytecode with Python (JelloVM Ep.01)

  Рет қаралды 61,023

Tsoding Daily

2 жыл бұрын

References:
- Specs: docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html
- WASM Learning Website: kolumb.github.io/learning-wasm/inspector/
- Source Code: github.com/tsoding/pjython

Пікірлер: 149
@vivekascoder
@vivekascoder 2 жыл бұрын
"Money is not the most important thing in your life, what's important is knowing how to parse JVM" -Tsoding
@TenderBug
@TenderBug 2 жыл бұрын
Take that Larry Elison
@milan1039
@milan1039 2 жыл бұрын
13:10
@L0wPressure
@L0wPressure 2 жыл бұрын
That's some wisdom for you folks! XD
@satyajeetkumarjha1482
@satyajeetkumarjha1482 Жыл бұрын
13:15
@paulzupan3732
@paulzupan3732 11 ай бұрын
Actually very true, create a language, target the JVM and you're good to go
@calebharper9567
@calebharper9567 2 жыл бұрын
I like how he reflexively keeps typing semicolons at the end of lines and correcting it
@EDFHLFLFF
@EDFHLFLFF 2 жыл бұрын
I always do that in matlab too, mostly because sometimes you're meant to and sometimes not 🤷
@raidensama1511
@raidensama1511 Жыл бұрын
He could leave them in, it would still work.
@desertfish74
@desertfish74 2 жыл бұрын
We had Jython in the past (java running python programs) now Pava (?) Python running Java. Letsgoo
@reinhold1616
@reinhold1616 2 жыл бұрын
java running python running java running python running java when?
@ndrechtseiter
@ndrechtseiter Жыл бұрын
@@reinhold1616 milk inside a bag of milk inside a bag of milk
@ratofthecity6351
@ratofthecity6351 9 ай бұрын
​@@ndrechtseiterREAL
@ratofthecity6351
@ratofthecity6351 7 ай бұрын
​@@ndrechtseiterholy shit milk game
@angelcaru
@angelcaru 7 ай бұрын
milk mentioned@@ratofthecity6351
@mandrak87
@mandrak87 2 жыл бұрын
I just wanted to say how much I enjoy watching your videos. It is the perfect balance between top quality educational content and really funny/entertaining jokes mixed in. You truly are a one of a kind engineer. Keep up the fantastic work and I hope things are not too bad for you in Russia. Tsoding rocks 👍
@craigcraig6248
@craigcraig6248 2 жыл бұрын
Yeah this is a really underrated channel for a cs nerd like me
@simonetii
@simonetii 2 жыл бұрын
in python3 with f strings you can do foo = "a" print(f"{foo=}) which will print foo = "a" basically if you put an equal sign at the end of the block it will evaluate the expression and return its value and the expression itself as string great video as always bro
@NathanChambers
@NathanChambers Жыл бұрын
wrong, print(f"{foo=}) will print foo="a" if you want the spaces for example print(f"{foo= }) would print foo= "a". Point being, it doesn't automatically add a space before and after the = like your example :)
@smergibblegibberish
@smergibblegibberish 2 жыл бұрын
He hadn't uploaded since the Russian mobilization started. I had started to worry for him. Glad to see he is alright.
@1vader
@1vader 2 жыл бұрын
Some reasons why the binaries contain the class names: - debugging output, e.g. exception stacktraces - reflection - methods that print the class name, including default toString implementations and getClass().getName()
@DeathSugar
@DeathSugar 2 жыл бұрын
is there a way to strip them? or the only way to do it is via JIT/AOT?
@laurensweyn
@laurensweyn 2 жыл бұрын
@@DeathSugar You can strip class names via an obfuscator. This effectively renames all your classes to 'A', 'B', 'C'... 'AA', 'AB' and so on. Great if you want to avoid reverse engineering, not so great if you want to understand a stack trace or any errors/debug output
@DeathSugar
@DeathSugar 2 жыл бұрын
@@laurensweyn is it built-in thing in java? Can this data be moved in some dsym file, like CXX does?
@SnackLive
@SnackLive 2 жыл бұрын
@@DeathSugar Dont remember if is actually build in the compilator but theres a lot of tooling dedicated to obfuscation and code reduction
@pozdroszejset4460
@pozdroszejset4460 2 жыл бұрын
@@DeathSugar proguard is a popular one
@jozef_kascak
@jozef_kascak 2 жыл бұрын
Glad to see you back. I hope you are safe from everything.
@jasonkary8431
@jasonkary8431 10 ай бұрын
Being an old guy, I know why there are and ... It's from the teletype machine days. is a carriage return where the print head is physically returned to the start of the line. is a line feed where physically scrolled the paper up one line. No collusion involved. ;)
@VojtěchJavora
@VojtěchJavora 9 ай бұрын
Right, but once nobody used teletypes, why did each of them choose different line ending.
@mattcoley
@mattcoley 2 жыл бұрын
35:00 - Lol welcome to the spec. It literally says in that page they regret some of these decisions. But yeah, its not a horribly complicated spec, just got some quirks. 43:30 - Arrays of 'constants' of each type would actually be kinda cool.
@eboubaker3722
@eboubaker3722 2 жыл бұрын
Ooh man my favorite channel makes a video about my favorite language java best day ever
@Fikerus2
@Fikerus2 2 жыл бұрын
2:52 He checked the date to say what year it is
@spermakonya
@spermakonya 2 жыл бұрын
😂
@alphad.lawless3980
@alphad.lawless3980 2 жыл бұрын
That's because your mind is light years ahead
@LordMardur
@LordMardur 2 жыл бұрын
18:30 I think the "intention" of Windows (or DOS) having both line feed and carriage return together is a simpler printer driver, and laziness. Early matrix printers had different commands for line feed (moving the paper) and carriage return (returning the print head to the home position, this is where the name comes from). With having both commands directly in the text document, a printer driver can simply send the file byte by byte to the printer and it does the right thing. Unix and Mac preferred a single command inside text files, since in a text document there is not really a concept of carriage return or line feed, just new line. For parsing binary data from bytes, I recommend struct.unpack. It is a standard package, which allows for easier reading (and writing) of entire structures and can handle endianness as well.
@5omebody
@5omebody 2 жыл бұрын
i feel like it's less laziness, and more... DOS probably cared more about compatibility with existing standards, whereas unix and max (also unix) *probably* just figured, you're probably not printing your text files, let alone your code, so why not keep it simple
@accountname1047
@accountname1047 2 жыл бұрын
You are a wizard, love watching you work
@filipmajetic1174
@filipmajetic1174 2 жыл бұрын
Such a shame we had to give up Turing completenss to get Unicode in python 3... Btw, Java 18 or 19 finally got "script" files, where you can just start writing code without a public static void main and it just works™
@Rene-tu3fc
@Rene-tu3fc 2 жыл бұрын
maybe by java 23443 we'll have static function files, where we don't need to encapsulate public static functions within classes
@sagnikc4
@sagnikc4 2 жыл бұрын
jshell ?
@keineangabe8993
@keineangabe8993 2 жыл бұрын
@@Rene-tu3fc I actually dont have a problem with that, we need some way of accessing functions like that anyway, I see utility classes as some kind of namespace.
@orizach01
@orizach01 2 жыл бұрын
JavaScript in real life
@mrmaniac9905
@mrmaniac9905 2 жыл бұрын
Glad to see you back keep up the content, I love watching it in the background at work!
@rogo7330
@rogo7330 2 жыл бұрын
By the way, try to disable "Turbo" (also called p-state). You can do that with `echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo`. This will disable your CPU from running on extra sShpPpiIieeed and will no longer give you a heatstroke while you using your computer.
@JanBebendorf
@JanBebendorf Жыл бұрын
We built a transpiler that can target multiple languages instead (we made backends for lua and php but built it to be extensible). The subset of the stdlib that we implemented is very small as it stands but also built to be extended using Java classes with native methods and annotations that provide the code for the different languages. The produced code also doesn't look great because it replicates the behavior instruction by instruction but it actually works quite good.
@salamemilano
@salamemilano 2 жыл бұрын
1:23:11 the best part of the entire live
@paulfragemann3333
@paulfragemann3333 2 жыл бұрын
There is a lot more incompatible change in Python 2 vs 3 but the print is the most noticable syntactically. The way strings work completely changed, splitting the str type of Python 2 that was basically just a list of bytes into 3 different type: str (unicode string), bytes (immutable list of bytes), bytearray (mutable list of bytes), breaking a lot of programms messing around with binary files. And a lot more stuffs even less noticeable than that.
@laurensweyn
@laurensweyn 2 жыл бұрын
Exactly, the differences are far bigger than print() -- most libraries wouldn't take nearly so long to port to Python 3 if that was the only change, especially since most use proper logging instead of prints which were unchanged. The division operator '/' always returning a floating point number in Python 3 instead of also doing integer division like in Python 2 (which is now '//') is a particularly nasty one I remember for example.
@CraftMine1000
@CraftMine1000 2 жыл бұрын
Let's not forget import pathing changed slightly from 2 to 3 also
@TsodingDaily
@TsodingDaily 2 жыл бұрын
@Elsevar Asadov I mean, to realize that this was a joke you need to watch that bit until the end. You can't expect such a huge attention span from an average KZbin commenter especially after introduction of KZbin Shorts.
@laurensweyn
@laurensweyn 2 жыл бұрын
@@TsodingDaily I had this 2.5 hour video in my recommendations, never seen this channel before, and first impressions matter. I got the impression you didn't know what you were talking about (and I've heard plenty of beginners complain about this very thing during early Python 3 days), and if that were a sign of what's to come for the rest of the video, I'm not sitting through 2.5 hours of this, especially if I have many more creators to choose from. I'm sorry my judgement was incorrect, but I'm sure I wasn't the only one to come to this conclusion. Maybe something to consider for future videos. Or don't, I won't stop you.
@sandworm9528
@sandworm9528 Жыл бұрын
@@laurensweyn you only have to watch 4m 15s to hear him say he's joking. But go ahead and explain how valuable your opinions are
@alpers.2123
@alpers.2123 2 жыл бұрын
def pprint(obj): print(json.dumps(obj, indent=4, sort_keys=False))
@DanCojocaru2000
@DanCojocaru2000 2 жыл бұрын
obj is not JSON serializable
@lucifer-5ybtn
@lucifer-5ybtn 2 жыл бұрын
good to see you’re back🎉
@rafagd
@rafagd 2 жыл бұрын
I know it's too late to sugest a name, but if Jython is Python on JVM, JVM in Python needs to be Pava or PVM
@BulletHeadPL
@BulletHeadPL 2 жыл бұрын
im so happy i can listen to u again
@claudiusraphael9423
@claudiusraphael9423 11 ай бұрын
Just "reading" that title alone made me want to comment: You really are the Sado-Masochistic Dominatrix of Programming. G-sus Krajst: This is the epitome of perversion, lol - and i thought generating 6502-assembly from inside a BASIC V2 program and poking it live to replace the running kernel by triggering a soft-reset would be nasty - this is a whole nother level of dark-arts. Razpackt!
@ecampo123
@ecampo123 Жыл бұрын
The real OOP were the friends we made along the way
@jonasls
@jonasls 2 жыл бұрын
Super cool, can't wait for more! Maybe an interpreter?
@morgengabe1
@morgengabe1 2 жыл бұрын
dude, great to see you're safe! was worried when you went quiet after the draft was announced!
@BalintCsala
@BalintCsala 2 жыл бұрын
I admittedly haven't watched through the whole video, but since you are using python 3 I recommend using format strings in prints, you can do a lot of the stuff you did effortlessly e.g. print(f"{foo = }") results in "foo = "
@zohnannor
@zohnannor 2 жыл бұрын
but without pretty-printing, although he could've used `pprint.pformat`.
@BalintCsala
@BalintCsala 2 жыл бұрын
@@zohnannor I was mostly talking about stuff around 20 minutes Also, for pretty printing as others mentioned json _is_ better
@zohnannor
@zohnannor 2 жыл бұрын
@@BalintCsala yes i laughed when he tried `json.dump` without `indent` parameter, saw that it didn't print like he thought and immediately threw that code away xD so close yet so far
Жыл бұрын
I love that there is the development process captured in this! Building custom JVM is cool, but I like to see you adding new features and suddenly saying "this can go to a separate function". It is such a great learning material! I wish something like this was done 15 years ago when I started to code :)
@thegate8985
@thegate8985 2 жыл бұрын
Hi (or privet, as a Russian I hear russian accent in your speech :D)! Thanks for the video :)
@Yash42189
@Yash42189 2 жыл бұрын
ure the best programming related youtube content creator. keep up the good work
@TenderBug
@TenderBug 2 жыл бұрын
Someone is overly funny and sarcastic than usual in this stream 🤣 Nice vid Tsoding. Learned lot.
@TheBigLou13
@TheBigLou13 2 жыл бұрын
This was interesting to watch and I learned a lot. Thank you! :) You're clever and a quick thinker.
@ShotgunLlama
@ShotgunLlama Жыл бұрын
Well this definitely got me down a deep rabbit hole
@L0wPressure
@L0wPressure 2 жыл бұрын
My man, every time i watch your videos i feel stupid, but at the same time i always learn something new :) Let's hope all that shit ends soon, i wish us all peace.
@bassguitarbill
@bassguitarbill 2 жыл бұрын
Really entertaining video, looking forward to the rest of this!
Жыл бұрын
1:47:28 When you said "holy fucken shit"... I felt it in my bones.
@samholland209
@samholland209 4 ай бұрын
Since you did this, why not also write a program in Python that can decompile Java bytecode?
@annybodykila
@annybodykila 8 ай бұрын
Knowledge of reflection and injection would be helpful for a project like this 😉
@1495978707
@1495978707 2 жыл бұрын
6:00 for the thing about open source as a means to exploit young enthusiastic programmers
@coder4937
@coder4937 2 жыл бұрын
I was waiting for your video
@kossboss
@kossboss 6 күн бұрын
smart :) learned a trick [main] = thing_that_returns_single_item # wins [main] = thing_that_returns_array_or_tuple # fails
@remrevo3944
@remrevo3944 2 жыл бұрын
Javas interpretation of UTF-8 is going to be a pain. Because if you start using emojis in the java strings there are going to be problems.
@devqbasic2384
@devqbasic2384 2 жыл бұрын
can you write assembly on an os level ? It's fun and easy if you stay 16bit because you still have the bios.
@marceloxsweet1358
@marceloxsweet1358 Жыл бұрын
Jython, perfect name dude ❤
@kvikende
@kvikende Жыл бұрын
Tsoding adding all those parantheses might be his unconcious telling him to learn LISP
@rogo7330
@rogo7330 2 жыл бұрын
How on the Earth Java compiles simple write to stdout so long?
@white_145
@white_145 11 ай бұрын
2:08:58 could use the ,= operator (which is just weird tuple syntax)
@superscatboy
@superscatboy 2 жыл бұрын
You're a lunatic, man. Never change :)
Жыл бұрын
2:03:50 Yes! This is me programming in PHP 15 years ago. "Why does the function return allways null? Ah, because I haven't included `return result` at the end..."
@hwstar9416
@hwstar9416 2 жыл бұрын
I think this is the third time you've changed the thumbnail now 😂
@jerssh
@jerssh 2 жыл бұрын
19:35 Once a bunch of files i was reading in were getting cut of at random points, ends up the binary info contained EOF markers coincidentally, and reading it in non-binary mode would just make it quit reading the file when it ran into them.
@fullstack_journey
@fullstack_journey 2 жыл бұрын
Oh the inexplicably fantastic horror. I cannot look at it but i cannot look away from it
@brvtalcake
@brvtalcake Жыл бұрын
I really like your spying videos
@berndeckenfels
@berndeckenfels 6 ай бұрын
1:38:10 Descriptor is the ()V (void) return signature with no args
@aciddev_
@aciddev_ Жыл бұрын
imagine running this through jython
@replikvltyoutube3727
@replikvltyoutube3727 2 жыл бұрын
Make porth compile to jvm
@ErikOrjehag
@ErikOrjehag 2 жыл бұрын
Did you move apartment?
@mbarrio
@mbarrio 2 жыл бұрын
Maybe he got back to parents house, Kemerovo, or Novokuznetsk.
@arthurlokhov6856
@arthurlokhov6856 2 жыл бұрын
what font are you using?
@thirtysixnanoseconds1086
@thirtysixnanoseconds1086 2 жыл бұрын
ioevska
Жыл бұрын
1:23:10 As a CS graduate, I confirm.
@Lars-ce4rd
@Lars-ce4rd 5 ай бұрын
I guess tsoding was so afraid of enabling JVM developers that he decided to use python for this task.
@alexandrohdez3982
@alexandrohdez3982 2 жыл бұрын
Again GREAT VIDEO 👏👏👏👏
@theodorealenas3171
@theodorealenas3171 6 ай бұрын
1:04:00 it's hard to convince my peers to do this versus blop chunks of code and debug little by little
@CarterColeisInfamous
@CarterColeisInfamous Жыл бұрын
3:26 that is correct
@TheBasyx
@TheBasyx 2 жыл бұрын
print without () had security issues
@i007c
@i007c Жыл бұрын
python struct module is also a good option
@meaningfulname9437
@meaningfulname9437 Жыл бұрын
So you were in Russia that time?😀
@cycomkid
@cycomkid Жыл бұрын
I liked the video but dislike the fact that you are not getting the money, if there is anything i can do let me know, i will be happy to support. I am from india and Russia is a good friend of India
@hatkidchan_
@hatkidchan_ 2 жыл бұрын
Hehe... Пива... Ehehehhehhehhh...
@donovanvanderlinde3478
@donovanvanderlinde3478 2 жыл бұрын
Hmm Feels like Porth all over again You say it’s just for hello world but I bet this will end up being a lot more 😂😂
@l.iwakura6553
@l.iwakura6553 2 жыл бұрын
sorry, but how doesnt you back hurt when you stay sit for quite a time?
@Akhulud
@Akhulud 2 жыл бұрын
21:10 it's because return is a keyword and print is a function but was a keyword in py2
@D0Samp
@D0Samp 2 жыл бұрын
Next step, writing a Java library to parse CPython byte code.
@joaomendoncayt
@joaomendoncayt 2 жыл бұрын
are we not going to talk about 2:52? Edit: Ok, I should've just kept watching...
@akam9919
@akam9919 Жыл бұрын
My insides feel weird reading the title.
@frechjo
@frechjo Жыл бұрын
Mi vidas komentojn en la angla, mi vidas komentojn en la rusa, sed kie estas la komentoj en la plej bona lingvo? Ŝajnas ke mi mem devas zorgi pri tio! Ankaŭ, algoritma engaĝiĝo.
@Un0rdin4rYPr0gr4mmeR
@Un0rdin4rYPr0gr4mmeR 2 жыл бұрын
Has nobody commented on "P0rn folder size at 14:45" - Too smol PepeHands :D
@ilikegeorgiabutiveonlybeen6705
@ilikegeorgiabutiveonlybeen6705 6 ай бұрын
гагага пива
@valshaped
@valshaped 2 жыл бұрын
The most important thing we can do to combat AI code generator agents is write massive piles of the sh*ttiest code on the planet, like bash scripts that generate bash scripts
@TheGamer2024Short
@TheGamer2024Short 2 ай бұрын
Now i need to delete my npm and github repos 😢
@MrOboema
@MrOboema 2 жыл бұрын
Java Bytecode in Python. Wow. How's the performance? 🤣
@objectobject5889
@objectobject5889 2 жыл бұрын
3x faster. In the development time domain ;)
@MrOboema
@MrOboema 2 жыл бұрын
@@objectobject5889 but 10x slower in execution and the next Python version wont be able to run it without major changes. Got it, like usual Python code...got it 😁
@Richarddesk
@Richarddesk 2 жыл бұрын
oracle jdk😄
@skeleton_craftGaming
@skeleton_craftGaming 2 жыл бұрын
Yeah, the whole point of Java is that you don't need to know how Java works internally.
@gargleblasta
@gargleblasta Жыл бұрын
I want to code something simple today he says 😂
@replikvltyoutube3727
@replikvltyoutube3727 2 жыл бұрын
Maybe yer laptop needs to be cleaned from dust ?
@pishax3056
@pishax3056 2 жыл бұрын
пива))
@skr-kute1677
@skr-kute1677 2 жыл бұрын
i love the jokes here n there
@skr-kute1677
@skr-kute1677 2 жыл бұрын
bruh, like really as im watchin the vid, it do be extra funny and interesting to watch
@ThePoke151
@ThePoke151 2 жыл бұрын
23:45 I came, but only because I like pain or something
@rodelias9378
@rodelias9378 2 жыл бұрын
"It's doable"
@MultiSuperUnicorn
@MultiSuperUnicorn 2 жыл бұрын
open source and hackathons are one and the same :D
@replikvltyoutube3727
@replikvltyoutube3727 2 жыл бұрын
It would be rly cool if you could help free pascal with jvm backend
@superscatboy
@superscatboy 2 жыл бұрын
I think Free Pascal can already target the JVM.
@replikvltyoutube3727
@replikvltyoutube3727 2 жыл бұрын
@@superscatboy it does but is not upstream last time I checked and it is based on really old Jasmin library
@superscatboy
@superscatboy 2 жыл бұрын
@@replikvltyoutube3727 Fair enough, I just remember hearing that it was a thing it could do.
@thehackr258
@thehackr258 6 ай бұрын
14:07 is really hot 🔥 😂😂😂!! in Russia 😂
@jebarchives
@jebarchives 2 жыл бұрын
:D
@zgliu8018
@zgliu8018 Жыл бұрын
Un-staticize your interpreted language 😈
@nibrobb
@nibrobb Жыл бұрын
1:41:00 incoming call
@sossupummi
@sossupummi 2 жыл бұрын
first!
@aciddev_
@aciddev_ Жыл бұрын
может тебе создать русский канал? и заливать туда озвучки, на русском, или сюда добавить субтитры?
@aqqq4097
@aqqq4097 Жыл бұрын
Whyyyyy? Just whyyy
@toastedgralic4868
@toastedgralic4868 7 ай бұрын
8:50 en.wikipedia.org/wiki/Java_class_file#:~:text=the%20sourcefile%2C%20etc.)-,Magic%20Number,-%5Bedit%5D
😜 #aminkavitaminka #aminokka #аминкавитаминка
00:14
Аминка Витаминка
Рет қаралды 822 М.
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 7 МЛН
1 сквиш тебе или 2 другому? 😌 #шортс #виола
00:36
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,3 МЛН
Bu telefonda oyun oynamak ister misiniz?
0:15
Hakkı Alkan
Рет қаралды 5 МЛН
Nokia 33-10 ☠️ #shorts
0:33
Apollon 🗿
Рет қаралды 347 М.
iphone designer studio📱🤣🤣
0:16
티곰
Рет қаралды 2,7 МЛН
iPhone or Samsung?
0:28
Kan Andrey
Рет қаралды 3,1 МЛН