10
Grumpycat
242d

Fuck me. Upgraded a java project from java 11 to java 17 and now the shitload of power mockito tests are all failing because they locked down reflection. Now I have to upgrade to junit 5 and waste my life looking at these stupid unit tests. I sense a large purge approaching.

Comments
  • 5
    Unit tests with reflection?!
    Purge it is!
  • 0
    @Grumpycat

    Most likely you're just missing JVM args for the test runner, most likely add-opens .

    But... If you just upgrade on good luck between 11 and 17... Let me be crystal clear:

    BAD IDEA.

    Sure you can whack together a half assed solution that probably works, but you should better have a plan.

    And watch out for several dependencies, cause the sealing of internal APIs - which was an *excellent* job done by JDK - has other side effects in various libraries.
  • 2
    @Lensflare Every. Really every. Test framework uses reflection.

    It's not possible to do it otherwise.

    But good joke.
  • 1
    @IntrusionCM I mean the test code itself, not the test framework code.
  • 2
    @IntrusionCM I also doubt that every test framework uses reflection but I‘m not really sure.

    The usual way to write unit tests is to use your code as a library and call it as usual and verify if the result is what you expect. No reflection needed.
  • 1
    @Lensflare yes... And no...

    The fun thing about test frameworks is: You have to implement somehow a detection of what a test is.

    Most test frameworks utilize annotations or a specific function name pattern... That's where the reflection usually takes part.

    In the most simplistic form, one scans e.g. the class path / folder path, matches all file names, reflectively loads the classes and executes its functions.

    I had a lot of fun poking at several JUnit extensions, PyTest extensions and other stuff. It's reflection. Somewhere somewhere it's always there.

    Back to this topic...

    These should be the relevant JEPs.

    http://openjdk.java.net/jeps/403

    https://openjdk.java.net/jeps/411

    Both are long overdue and with the upcoming JDK 21 LTS release next month, there will be more removal of internal APIs.
  • 0
    How about a proper upgrade - to .NET?

    My hair loss stopped, I gained more friends, lower pulse and generally more sunshine when I left Java behind 15 years ago. 😉
  • 1
    @devdiddydog I don't think of .NET as an upgrade... Not after the last releases.
  • 0
    @IntrusionCM I just have PTSD from the god awful syntax of Java, which totally clouds my judgement and I am aware of it.

    It's a fanboi thing, thought I'd get some keyboard warriors going about which one is better. 🍿
  • 1
    @IntrusionCM what was in the last release that was bad?

    Honestly curious because I‘m not up to date with .Net anymore.
  • 2
    @Lensflare after the last LTS releases of JDK... my bad.

    Regarding C#... My last contact was 3-4 years ago I think.

    IMHO it's close regarding syntax and verbosity to Java. Though in Java, really a lot depends on what choices you make. As I've said before, I'm in love with Micronaut and annotations, I hate Spring passionately. Add Eclipse collections and you have a solid base.

    What I dislike in C#... Well. You can put lipstick on a pig, it's still a pig.

    I'm ***very*** concerned regarding Microsoft. It's not yet a closed garden, though a lot of the .NET ecosystem tries to create one. After all, Microsoft only makes money from the cloud, so it's logical they try everything they can to get people in it.

    Microsoft SQL (and thus LINQ) under Linux and other things are a pretty good example of that. Or the recent "we integrate Python into Excel, but you *must* use Azure Cloud to run the Python environment".

    IMHO a truly free OpenSource . NET does not exist. .NET core is more or less a decision that Microsoft *had* to make, as Windows is becoming increasingly unpopular - especially in the cloud. A "do or die" kind of decision.

    Though I appreciate the .NET core initiative, it's a rotten and poisoned apple to me.

    Java survived the Oracle Exodus, but just barely. The Java ecosystem is still in a state of mayhem, no need to sugarcoat it. Oracles decision led to a lot of scorched earth, but thx to OpenJDK and others it will remain free.

    I cannot say the same for MS or .NET. and imho - given the recent BPL migrations like in Terraform or similar issues - .NET Core is thus a very red herring to me.

    It's like a rehab center that has a nice cocktail bar with a happy hour and the lowest prices in the city - guaranteed
    ....

    Nuff said I guess.
  • 1
    @IntrusionCM that might be the best explanation of .NET vs Java that I've ever read.
    I totally agree .NET Core is a poisoned apple. Switched from C# .NET Core to Java development this year and I'm never going back.

    What Oracle decisions led to a lot of scorched earth? Why is the Java world in mayhem?
Add Comment