Chat Logs

  1. * nevet joined #java
  2. * 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.
  3. * Aedil joined #java
  4. pr3d4t0r:: yawn ::
  5. pr3d4t0rGood morning.
  6. pr3d4t0rdreamreal!! Come to #cime or the other channel when you have a moment?
  7. * metalmaniac joined #java
  8. * B_fd joined #java
  9. * zorone joined #java
  10. * rvalue joined #java
  11. * Aedil joined #java
  12. * marcel joined #java
  13. * kusanagi joined #java
  14. * B_fd joined #java
  15. * kusanagi joined #java
  16. * sa02irc joined #java
  17. * ferdna joined #java
  18. * stfstfm joined #java
  19. * sponkz joined #java
  20. * B_fd joined #java
  21. * Ragnor joined #java
  22. * Nemu64 joined #java
  23. * ForeverDreaming joined #java
  24. * LFK joined #java
  25. * agnivn joined #java
  26. * stewi joined #java
  27. * MikeBux joined #java
  28. * tabmow joined #java
  29. * Square2 joined #java
  30. * kathadris joined #java
  31. * mwnaylor joined #java
  32. * kcomhnal2 joined #java
  33. * polarian joined #java
  34. * agnivn joined #java
  35. * agnivn joined #java
  36. * xeno joined #java
  37. * tabmow joined #java
  38. * tabmow joined #java
  39. * domicron joined #java
  40. * stfstfm_ joined #java
  41. * stfstfm joined #java
  42. * nevet joined #java
  43. * 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.
  44. * stfstfm_ joined #java
  45. * sa02irc joined #java
  46. * GreenResponse joined #java
  47. * nevet joined #java
  48. * 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.
  49. * kcomhnall joined #java
  50. * MonsterAbyss joined #java
  51. * szkl joined #java
  52. * jamezp joined #java
  53. dreamrealaaaaand nevet should be back. Still finding transaction leaks. :/
  54. dreamrealstill muted HERE, though. :D
  55. * linuxthebaddev1 joined #java
  56. * kcomhnal2 joined #java
  57. * P1RATEZ joined #java
  58. * agnivn joined #java
  59. * tronexte joined #java
  60. * agnivn joined #java
  61. * candinsky joined #java
  62. * waznot joined #java
  63. * stfstfm joined #java
  64. * magla joined #java
  65. * sa02irc joined #java
  66. * B_fd joined #java
  67. * phlox joined #java
  68. * candinsky left #java (Leaving)
  69. * phlox joined #java
  70. * stfstfm_ joined #java
  71. * kcomhnall joined #java
  72. * jamezp joined #java
  73. * B_fd joined #java
  74. * m joined #java
  75. dreamrealhttps://bytecode.news/posts/2026/04/boilerplate-three-ways
  76. javabotdreamreal's title: "Boilerplate Three Ways | bytecode.news"
  77. * Square2 joined #java
  78. * sponkz joined #java
  79. * jbosmans joined #java
  80. * B_fd joined #java
  81. * mawk joined #java
  82. mawkhi
  83. mawkis this calling 'new' under the hood? byte[] a = {1, 2, 3};
  84. mawki.e. is this equivalent to byte[] a = new byte[3]; a[0] = 1; a[1] = 2; a[2] = 3;
  85. DoofusCanadensisdoubt it
  86. * stfstfm joined #java
  87. DoofusCanadensisbyte != Byte
  88. mawkI'm writing JavaCard and need to avoid 'new' as much as possible
  89. * JazzJackalope joined #java
  90. 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)
  91. * raj joined #java
  92. jbosmanswhich i never do because i don't work at that level of detail
  93. Chronosmawk: Yes, as far as I know, it's identical to: byte[] a = new byte[]{1, 2, 3};
  94. ChronosSo I believe it does indeed call "new".
  95. Chronos(Corrections welcome.)
  96. ernimrilChronos, compile it and then check with javap
  97. ChronosIn Java, every array is a full-fledged object.
  98. mawkhmmm
  99. jbosmanswhat ernimril said
  100. mawkthanks
  101. sonOfRamawk: byte[] a = {1, 2, 3};
  102. sonOfRaoops
  103. sonOfRamawk: https://javap.yawk.at/#lnBjVV
  104. nevetjavap pastebin
  105. jbosmansalso, https://godbolt.org ftw
  106. nevetCompiler Explorer
  107. sonOfRatrue, but javap.yawk.at is made by (former) channel regular yawkat!
  108. jbosmanskudos for that ^
  109. mawkah yes indeed sonOfRa , thanks!
  110. jbosmansas far as i can see creating a new array doesn't create a new object
  111. jbosmansstatic int[] square() { return new int[]{9999}; }
  112. ernimriljbosmans, what about the newarray ?
  113. jbosmans 0: iconst_1
  114. jbosmans 1: newarray int
  115. jbosmans 3: dup
  116. jbosmans 4: iconst_0
  117. jbosmans 5: sipush 9999
  118. mawkwell it calls "newarray byte" so it must be allocating it on the heap
  119. mawkso I should do that only in the constructor of my applet so it's only called once
  120. mawkI can technically trigger the garbage collector but it has to be done manually and it's not portable, not every card has it
  121. jbosmansthanks for unbanning :)
  122. jbosmansmawk, there's the epsilon gc which doesn't do anything iirc, might be useful for measuring/.. to accomplish your goals
  123. mawkah yeah, I can run this on a simulator on a pc
  124. jbosmansshould you want to invest in that approach
  125. mawkthanks
  126. 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)
  127. jbosmansoverlapping msgs:)
  128. * jreicher joined #java
  129. jreichermawk: are you really assigning the byte array something known at compile time? Or is that just how you wrote the example?
  130. * domicron4 joined #java
  131. mawkyes it's known at compile time
  132. mawkmaybe if I set it as "final" it won't make an allocation
  133. jbosmansafaik object instantiations are extremely cheap on jvm
  134. ernimrilit is on all modern jvms, yes, has been so for a long time. Also constants are quite often inlined by the compiler
  135. jbosmans~jep 519
  136. javabot'JEP 519: Compact Object Headers' can be found at http://openjdk.java.net/jeps/519
  137. nevetJEP 519: Compact Object Headers
  138. jbosmansalso, it was pretty cheap before, too
  139. * mindCrime joined #java
  140. jbosmans(before java 25)
  141. jbosmansalso, up to recently, i compiled some tools using docker to an ubuntu 18/debian 10 compatible binary
  142. jbosmanswhich really made a difference for cmdline tools
  143. jbosmansfwiw it was compatible by compiling in dedicated docker containers, i just upgraded the container OS versions
  144. jbosmansiirc i got java+spring+jdbc+postgres+code down to ~60mb, which was nice
  145. 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.
  146. jbosmansUPX compression could drive that down substantially, but that would take longer to execute (because of decompression)
  147. jreicherA good rule of thumb IMO is to always tell the compiler everything you know.
  148. mawkjbosmans: this is running on a smartcard, it's a a very small and slow microcontroller
  149. mawkwith just a couple hundred bytes of RAM to spare, maybe a thousand
  150. jbosmansmawk, great to be working on that :-)
  151. jbosmansi actually recognized JavaCard
  152. jreicherIs it possible Java is not the best language for that kind of target? (Honest question; I have no experience in this area)
  153. mawkwell there's no choice, java is all they run; in your credit card, your epassport, your SIM card
  154. mawkyou can sometimes run C but you need to sell your soul for a NDA
  155. jbosmansmawk, which context? eid or alike?
  156. mawkI'm working on a PKI smartcard
  157. jbosmanssweet, iirc our eid runs JavaCard too
  158. 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
  159. jbosmanscrazy stuff
  160. 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
  161. jbosmansmawk, what jdk version are you working in?
  162. * kathadris joined #java
  163. mawkit's javacard 3.0.5
  164. mawkcompiling with jdk 17
  165. jbosmansthat's not too bad for such a restricted context
  166. jbosmansiirc records are already supported
  167. jbosmansbest use those wherever they make sense
  168. jbosmansbecause both the compiler and jvm will know they're mean to be (shallowly) immutable
  169. jbosmansalas way post midnight, sweet dreams
  170. * zorone joined #java
  171. * zorone joined #java
  172. * ChaiTRex joined #java
  173. * Square2 joined #java
  174. * ChaiTRex joined #java
  175. dreamrealfor javacard, eh
  176. dreamrealThat's a little surprising
  177. mawkwhy?
  178. dreamrealjavacard's not very common in the wild. What are you deploying it to?
  179. * zorone_ joined #java
  180. * kcomhnal2 joined #java
  181. * kcomhnal2 left #java
  182. mawkI'm currently trying to add remote management capabilities with public key crypto
  183. mawklike SIM cards have
  184. mawkthen you can open a secure channel with the card even through an untrusted network
  185. mawkthen the card will serve as a secure element to hold keys for mTLS or other things, in an embedded product, in SIM format
  186. * ChaiTRex joined #java
  187. mawkand it's running on a JCOP 4 smartcard from NXP
  188. dreamreal*nod* nice!
  189. 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
  190. mawkbut now I need to wrap the AES keys with a public key instead of transmitting them in cleartext
  191. 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
  192. mawkyeah indeed
  193. dreamrealIt's like you're writing in MUMPS except with java syntax, wooo
  194. 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)
  195. mawkbut then it's not with new
  196. dreamrealI don't know if there's a GC on that profile at all: you'd want to allocate and preserve
  197. dreamrealunless things have changed! Like I said, I've got VERY little experience here, like "ooo I tried it once"
  198. mawkyeah some cards do have a GC but not all of them
  199. mawksome cards even have ints and not just bytes and shorts
  200. mawkluxurious
  201. mawkand you need to invoke the GC manually, and it will maybe run next time a command is received
  202. dreamrealI think I last did javacard on a lark for javaone 2007? maybe 2008?
  203. mawkah yeah the standards were quite different then
  204. mawkI think the standard was still to use the VISA platform manager instead of being the globalplatform thing of now
  205. 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
  206. dreamrealI remember having a GPS available, which I thought was going to be great for basically building the apple tags using java
  207. dreamreallike how train car locators work: when connected to an open network, send an identifier ("package XYZ is at X:Y at 23:01")