* CodeGeek!~codegeek@about/java/CodeGeek changed the topic to: Welcome! || Read Channel Rules at https://javachannel.org/ before participating. || Paste limit is two lines; ~pastebin lists options. || No applets, please. || Minecraft, Android, and Javascript all have their own channel. || You are being logged.
* Aedil joined #java
pr3d4t0r:: yawn ::
pr3d4t0rGood morning.
pr3d4t0rdreamreal!! Come to #cime or the other channel when you have a moment?
* metalmaniac joined #java
* B_fd joined #java
* zorone joined #java
* rvalue joined #java
* Aedil joined #java
* marcel joined #java
* kusanagi joined #java
* B_fd joined #java
* kusanagi joined #java
* sa02irc joined #java
* ferdna joined #java
* stfstfm joined #java
* sponkz joined #java
* B_fd joined #java
* Ragnor joined #java
* Nemu64 joined #java
* ForeverDreaming joined #java
* LFK joined #java
* agnivn joined #java
* stewi joined #java
* MikeBux joined #java
* tabmow joined #java
* Square2 joined #java
* kathadris joined #java
* mwnaylor joined #java
* kcomhnal2 joined #java
* polarian joined #java
* agnivn joined #java
* agnivn joined #java
* xeno joined #java
* tabmow joined #java
* tabmow joined #java
* domicron joined #java
* stfstfm_ joined #java
* stfstfm joined #java
* nevet joined #java
* CodeGeek!~codegeek@about/java/CodeGeek changed the topic to: Welcome! || Read Channel Rules at https://javachannel.org/ before participating. || Paste limit is two lines; ~pastebin lists options. || No applets, please. || Minecraft, Android, and Javascript all have their own channel. || You are being logged.
* stfstfm_ joined #java
* sa02irc joined #java
* GreenResponse joined #java
* nevet joined #java
* CodeGeek!~codegeek@about/java/CodeGeek changed the topic to: Welcome! || Read Channel Rules at https://javachannel.org/ before participating. || Paste limit is two lines; ~pastebin lists options. || No applets, please. || Minecraft, Android, and Javascript all have their own channel. || You are being logged.
* kcomhnall joined #java
* MonsterAbyss joined #java
* szkl joined #java
* jamezp joined #java
dreamrealaaaaand nevet should be back. Still finding transaction leaks. :/
javabotdreamreal's title: "Boilerplate Three Ways | bytecode.news"
* Square2 joined #java
* sponkz joined #java
* jbosmans joined #java
* B_fd joined #java
* mawk joined #java
mawkhi
mawkis this calling 'new' under the hood? byte[] a = {1, 2, 3};
mawki.e. is this equivalent to byte[] a = new byte[3]; a[0] = 1; a[1] = 2; a[2] = 3;
DoofusCanadensisdoubt it
* stfstfm joined #java
DoofusCanadensisbyte != Byte
mawkI'm writing JavaCard and need to avoid 'new' as much as possible
* JazzJackalope joined #java
jbosmansif implementation details like that matter a lot i'd suggest investigating how to validate answers to such questions, i'm thinking it'll lead to reading bytecode (aka jvm assembly)
* raj joined #java
jbosmanswhich i never do because i don't work at that level of detail
Chronosmawk: Yes, as far as I know, it's identical to: byte[] a = new byte[]{1, 2, 3};
ChronosSo I believe it does indeed call "new".
Chronos(Corrections welcome.)
ernimrilChronos, compile it and then check with javap
ChronosIn Java, every array is a full-fledged object.
sonOfRatrue, but javap.yawk.at is made by (former) channel regular yawkat!
jbosmanskudos for that ^
mawkah yes indeed sonOfRa , thanks!
jbosmansas far as i can see creating a new array doesn't create a new object
jbosmansstatic int[] square() { return new int[]{9999}; }
ernimriljbosmans, what about the newarray ?
jbosmans 0: iconst_1
jbosmans 1: newarray int
jbosmans 3: dup
jbosmans 4: iconst_0
jbosmans 5: sipush 9999
mawkwell it calls "newarray byte" so it must be allocating it on the heap
mawkso I should do that only in the constructor of my applet so it's only called once
mawkI can technically trigger the garbage collector but it has to be done manually and it's not portable, not every card has it
jbosmansthanks for unbanning :)
jbosmansmawk, there's the epsilon gc which doesn't do anything iirc, might be useful for measuring/.. to accomplish your goals
mawkah yeah, I can run this on a simulator on a pc
jbosmansshould you want to invest in that approach
mawkthanks
jbosmansmawk, assuming sarcasm, understand what you mean (i think). You could make it runnable on a pc if you can separate the dependencies from the code that's actually doing the work (or the work you care about)
jbosmansoverlapping msgs:)
* jreicher joined #java
jreichermawk: are you really assigning the byte array something known at compile time? Or is that just how you wrote the example?
* domicron4 joined #java
mawkyes it's known at compile time
mawkmaybe if I set it as "final" it won't make an allocation
jbosmansafaik object instantiations are extremely cheap on jvm
ernimrilit is on all modern jvms, yes, has been so for a long time. Also constants are quite often inlined by the compiler
jbosmansalso, up to recently, i compiled some tools using docker to an ubuntu 18/debian 10 compatible binary
jbosmanswhich really made a difference for cmdline tools
jbosmansfwiw it was compatible by compiling in dedicated docker containers, i just upgraded the container OS versions
jbosmansiirc i got java+spring+jdbc+postgres+code down to ~60mb, which was nice
jreichermawk: if it's known at compile time then declare it static and don't worry about the new. At worst it will only be done once, but perhaps not at all.
jbosmansUPX compression could drive that down substantially, but that would take longer to execute (because of decompression)
jreicherA good rule of thumb IMO is to always tell the compiler everything you know.
mawkjbosmans: this is running on a smartcard, it's a a very small and slow microcontroller
mawkwith just a couple hundred bytes of RAM to spare, maybe a thousand
jbosmansmawk, great to be working on that :-)
jbosmansi actually recognized JavaCard
jreicherIs it possible Java is not the best language for that kind of target? (Honest question; I have no experience in this area)
mawkwell there's no choice, java is all they run; in your credit card, your epassport, your SIM card
mawkyou can sometimes run C but you need to sell your soul for a NDA
jbosmansmawk, which context? eid or alike?
mawkI'm working on a PKI smartcard
jbosmanssweet, iirc our eid runs JavaCard too
mawkjava is actually a sane choice for the application, the JVM is fully controlled by the OS and can apply all the static checks and security mitigations they want
jbosmanscrazy stuff
mawkthey can do stuff like rolling back transactions in case of tearing, skewing the clock inbetween instructions or running instructions several times to throw off side channel attacks; and also exceptions are an integral part of how the card communicates with the reader, that's how you set the APDU status codes
jbosmansmawk, what jdk version are you working in?
* kathadris joined #java
mawkit's javacard 3.0.5
mawkcompiling with jdk 17
jbosmansthat's not too bad for such a restricted context
jbosmansiirc records are already supported
jbosmansbest use those wherever they make sense
jbosmansbecause both the compiler and jvm will know they're mean to be (shallowly) immutable
jbosmansalas way post midnight, sweet dreams
* zorone joined #java
* zorone joined #java
* ChaiTRex joined #java
* Square2 joined #java
* ChaiTRex joined #java
dreamrealfor javacard, eh
dreamrealThat's a little surprising
mawkwhy?
dreamrealjavacard's not very common in the wild. What are you deploying it to?
* zorone_ joined #java
* kcomhnal2 joined #java
* kcomhnal2 left #java
mawkI'm currently trying to add remote management capabilities with public key crypto
mawklike SIM cards have
mawkthen you can open a secure channel with the card even through an untrusted network
mawkthen the card will serve as a secure element to hold keys for mTLS or other things, in an embedded product, in SIM format
* ChaiTRex joined #java
mawkand it's running on a JCOP 4 smartcard from NXP
dreamreal*nod* nice!
mawkI have half of the secure channel thing working, I can request AES session keys from the card and then continue with AES and CMAC
mawkbut now I need to wrap the AES keys with a public key instead of transmitting them in cleartext
dreamrealso I have VERY VERY VERY little experience with that profile, but in general you avoid allocations like the plague: new is fine *but* you reuse *everything* you can, so if you allocate an array, you reuse that array for the lifetime of the application
mawkyeah indeed
dreamrealIt's like you're writing in MUMPS except with java syntax, wooo
mawkI can request transient arrays which get cleared either on deselect or on reset (like if the application is selected several times on different logical channels or different interfaces like contact vs contactless)
mawkbut then it's not with new
dreamrealI don't know if there's a GC on that profile at all: you'd want to allocate and preserve
dreamrealunless things have changed! Like I said, I've got VERY little experience here, like "ooo I tried it once"
mawkyeah some cards do have a GC but not all of them
mawksome cards even have ints and not just bytes and shorts
mawkluxurious
mawkand you need to invoke the GC manually, and it will maybe run next time a command is received
dreamrealI think I last did javacard on a lark for javaone 2007? maybe 2008?
mawkah yeah the standards were quite different then
mawkI think the standard was still to use the VISA platform manager instead of being the globalplatform thing of now
dreamrealGosh, I don't remember that at all - we had this physical connection to the board, I don't even remember what it was called to install the application
dreamrealI remember having a GPS available, which I thought was going to be great for basically building the apple tags using java
dreamreallike how train car locators work: when connected to an open network, send an identifier ("package XYZ is at X:Y at 23:01")