This post was brought to you by this PMD rule.

Transcription

Why do we have this stupid code analyzer rule enabled anyway? Nobody writes code like this…

After telling them the lore why it’s there:

You have seen such things before?

11 Times, as a matter of fact

  • DreamButt@lemmy.world
    link
    fedilink
    English
    arrow-up
    8
    ·
    5 months ago

    So I don’t java (or ms java either) anymore. Why can’t you just reference the class itself?

    • jbk@discuss.tchncs.de
      link
      fedilink
      arrow-up
      15
      ·
      5 months ago

      the 2nd does that already

      in the first you can’t, as getClass() is not a static method (wouldn’t even make sense if it was)

      • mmddmm@lemm.ee
        link
        fedilink
        arrow-up
        10
        ·
        5 months ago

        The GP is saying that String is a class already, you shouldn’t have to call String.class.

        Personally, I’m away from it for long enough that I don’t remember either.

          • DreamButt@lemmy.world
            link
            fedilink
            English
            arrow-up
            2
            ·
            5 months ago

            Is it simpler tho? You have to explain to someone that the Type is also an Object with the field .class on it. I feel like just saying it’s a Type and you can reference Types directly is simpler. Idk maybe I’ve been currupted by type theory too much lol