ByteCode.News
Submit RSS Atom Sign in

Back to the channels

#java

  1. deebo gah, yourkit can't properly correlate virtual thread events (jsp+sql+tcp write etc), are there any other options currently?
  2. deebo trying to figure out what is actually causing 10x response times on a cold instance, and if it could be improved a bit or warmed up for service
  3. [twisti] we are looking for a (cli, for CI) tool to help with our code style mess in our old java projects. we need these features: the tool should have a mode to automatically fix all found issues, the tool needs a mode to just throw errors when it would want to make any changes, and the tool obviously needs to be configurable as well as overridable per line. ideally, something that detects more than just syntax style issues like whitespace, and allows
  4. [twisti] rules such as 'always use yoda conditions'. any suggestions i should look at ?
  5. deebo have not run into a tool that would be as "standard" as prettier is for nodejs projects
  6. Para I've seen prettier being used for Java as well, but dunno how well it behaves.
  7. Para SonarQube reports is one thing as well, ArchUnit can handle some corners...but no, can't think of a single tool for all of it.
  8. deebo sonarqube requires a license post java8 or something, we had to abandon it ages ago even though it was really good
  9. deebo sonarlint is ok, not sure if it integrates to ci/cd better these days, it used to just be a custom maven/gradle plugin that errored the build if it ran into violations
  10. MikeBux I would look at A.I. to make the code prettier and refactor it.
  11. deebo we want formatted code, not yassified
  12. deebo "can you add a big pair of badonkers on IOStreamFactoryConnector.java"
  13. MikeBux deebo, then the formatting tools of the ide should work with the right settings
  14. [twisti] we have like seven different IDEs, good luck getting that to be 100% identical
  15. deebo problem there is that people use what they use, but for java projects there's (afaik) nothing as good as prettier to define encforced formatting styles
  16. [twisti] shame that todays php tooling is better than java, we live in the worst timeline
  17. MikeBux then you need a formatter or checker in the pre commit hook
  18. MikeBux the only way to ensure it is run every time somebody commits
  19. MikeBux there are some articles on that topic
  20. MikeBux [twisti], https://dev.to/itsjjpowell/we-have-code-quality-at-home-open-source-java-code-quality-tools-4i84
  21. [twisti] yes, thats what i want it for
  22. dreamreal [twisti]: spotless?
  23. dreamreal [twisti]: what we do is run spotless in our actual build phases *and* commit hooks - one applies, the other checks
  24. dreamreal and spotless can be pretty aggressive about checks, don't know if it'd be aggressive enough for you but may be an option or similar to what you want, what you want might be out there in different form
  25. MikeBux [twisti], I would recommend to use one IDE for the whole team, that way everybody knows the ide, too. Might be hard for some people, but best for avoiding issues in the furture
  26. dreamreal ew
  27. dreamreal I don't think that's good advice
  28. dreamreal there's definitely WORSE advice ("everyone should use netbeans!") but ... the ide shouldn't matter
  29. MikeBux well last company made me use VS-Code
  30. dreamreal okay?
  31. MikeBux while i prefer intelliJ idea
  32. * dreamreal is waiting
  33. dreamreal MikeBux: I mean, that sucks for you... but the IDE shouldn't be dictated, IMO. Use build tools to normalize the team's output, period. That way someone who thinks like kent beck can use eclipse, someone who likes suffering can use vscode, someone who REALLY likes working in 2010 can use netbeans, and good coders can use idea
  34. deebo forcing an ide on devs is like forcing dvorak on HR
  35. dreamreal except HR deserves it
  36. MikeBux dreamreal, well actually you are right, the advice is not really good. I used Netbeans, Eclipse, and some other ide's
  37. deebo at one job at a large enterprise client, they gave us laptops with no permissions to install jdk
  38. deebo got paid for a week without being able to do anything
  39. dreamreal MikeBux: I actually don't care which IDE someone uses - I know good coders who use each of those, the IDE is not very relevant to your work product
  40. deebo does spotless integrate to e.g. idea as a 'on save' action?
  41. dreamreal deebo: I have that problem TODAY. We actually can't access any of our corporate resources without going through a physical access chain of custody.
  42. dreamreal deebo: it can through the build, sure
  43. dreamreal there may be plugins to do it explicitly without the build
  44. deebo hmpf, i like how well prettier integrates into everything
  45. deebo seems there's a plugin at least, but prettier plugin is first party
  46. * dreamreal shrugs
  47. dreamreal do what works for you
  48. MikeBux well, the worst is that the team can't commit because the code is not formatted and the devs only want to review actual code changes and not the whole formatted class
  49. dreamreal MikeBux: that's why the build does it. You build it, you get formatted code on a consistent level.
  50. dreamreal If it's not formatted properly by the tool, then it wasn't compiled and should fail review right out of the gate.
  51. MikeBux yes
  52. dreamreal so what formatters/linters do you guys use?
  53. dreamreal I use spotless pretty much everywhere just out of convenience; I know it well, it suits what I need, but what do you prefer, why?
  54. MikeBux dreamreal, we used the one ide aproach in the last company
  55. MikeBux and in the one before, too
  56. dreamreal MikeBux: so you said. Did you also enforce the code formatting across the board? (And my goodness, that sounds horrible - TWO of those companies in a row?)
  57. MikeBux dreamreal, yes we had to make sure the formatting rules were the same in all ides, like 2 space indent and stuff like that
  58. MikeBux no precommit hooks and such things
  59. dreamreal You need to find better employers :D
  60. dreamreal Sorry, man.
  61. * dreamreal says that as his work is *just now* standardizing on a code formatter as part of the build: our deployment is pure hell and enforces a certain conservatism we're just fighting our way past
  62. deebo we just share an idea formatter profile and then nitpick in reviews, all nodejs projects use prettier
  63. dreamreal deebo: makes sense, but why not use the prettier mindset for java projects, too? I mean, that's the right way to do it, why not do it?
  64. deebo would be nice to have ide importable rules in the project, with sql formatting too
  65. * dreamreal bleahs
  66. deebo havent found a good solution yet, spotless is something to look at
  67. dreamreal My team has people who use vi, eclipse, idea, vscode... and one guy WANTS to use netbeans. IDE profiles are nice but rather isufficient.
  68. deebo there was also some gradle ide plugin that has generic settings to define and then it can generate it for any (most) ides
  69. dreamreal yeah, but... why? I use joe and vi and sublime text too
  70. dreamreal the *central* flow for every last bit of code is the build
  71. deebo when does the formatting actually happen for you?
  72. dreamreal every compilation.
  73. deebo for all or changed files?
  74. dreamreal I'm not sure if spotless checks the update times. But it gets applied to all files.
  75. dreamreal I routinely work on builds with thousands of source files; it's not a problem for us.
  76. deebo yeah we would want changed only, i guess compile works ok since most ides just call gradle
  77. dreamreal Why would it matter?
  78. deebo we try to avoid drive-by formatting/etc changes, it would balloon every change in review
  79. dreamreal I mean, if I have files j0-999.java that are unchanged, and j1001.java that IS (not real names, obv) - those 1000 files aren't going to get diffs
  80. dreamreal they'll always format the same. There's no DIFF. Only the j1001.java would get changed; and that'd be part of your review ANYWAY because you changed it.
  81. dreamreal That INITIAL commit would be a chonker. After that, nothing.
  82. deebo yeah that would really annoyingly break blames for a while
  83. deebo but have to see what kind of changes it would make
  84. dreamreal So you have a branch for "integrate spotless/whatever into the build" and ... use it. It formats every file and ONLY formats every file. rebase. Done.
  85. dreamreal Yes, it would annoyingly break blames for a while.
  86. dreamreal Which is why you do it early. :D Our project dates from 2007; it's not a minor cost. But should have been done years ago.
  87. dreamreal like I said, our environment has a certain conservatism in play.
  88. deebo could maybe sneak it in with spring boot 4 upgrades
  89. dreamreal You can, BTW, set formatting for spotless; if you have IDE formatting your team likes, you can get spotless to mirror it.
  90. dreamreal That may help with the blame problem, and also gives you a way to change formatting incrementally should you desire that.
  91. dreamreal dmlloyd: https://bytecode.news/posts/2026/04/methodhandles-why-you-actually-care
  92. dmlloyd nice!
  93. deebo is spotless + google style for example forcing a specific formatting? or does it "allow" or "deny" a formatting for something?
  94. dmlloyd nice writeup, thanks
  95. dreamreal PLEASE sanity-check it for me, dmlloyd
  96. dreamreal I tried to do well, but you're the expert here
  97. dmlloyd I did, it looks good
  98. dreamreal deebo: you can apply it or validate it
  99. dreamreal dmlloyd: *nod* thank you
  100. dreamreal and well done on your part
  101. deebo but with a valid java input formatted in multiple random ways, the output is always the same?
  102. dmlloyd thanks. with that kind of motivation, maybe I'll only wait 16 months for the next one
  103. dreamreal deebo: if you *apply* spotless, it will generate consistent output, yes
  104. dreamreal dmlloyd: I tried to explain what your purpose was in writing without being judgemental about it
  105. dmlloyd yeah that bit was fine
  106. dmlloyd honestly I feel a bit nihilistic when it comes to my blog so it's a lot more than I expected lol
  107. dreamreal my biggest concern there is that I don't want to be projecting AND BCN doesn't criticize if it can help it, ever
  108. dreamreal if something's worth damning I'd rather just not write about it
  109. [twisti] had to step out. spotless is on the list, thanks dreamreal. MikeBux: note that it is your LAST company; forcing tools on grown ass adults is a good way to have everyone who has options leave for less unpleasant leadership
  110. dreamreal [twisti]++
  111. nevet [twisti] now has karma of 2.
  112. Square3 I'm having problems with FunctionalInterfaces. At one place we have a "serializable suppplier" (B) converted to a functional interface A. When this whole thing is deserialized I get a ClassCastException from SerializedLamba to A. If I manually create a `record C(B supplier) implements A { get() {..} }` things work.
  113. Square3 By "converted" I mean A is inferred by a method reference to a no-arg method `anInstance::noArgMethod`
  114. dreamreal I'd want to see an actual test case
  115. Square3 I'll see if I can produce one. Worrisome thing is that seems a bit random.
  116. dreamreal ~jep 534
  117. javabot 'JEP 534: Compact Object Headers by Default' can be found at http://openjdk.java.net/jeps/534
  118. nevet JEP 534: Compact Object Headers by Default
  119. dmlloyd shrunken heads?
  120. DoofusCanadensis *snrk*