Community
Participate
Working Groups
class Foo implements AutoCloseable { static void foo(Foo foo) { foo.method(); } // warning here static void bar(java.io.PrintWriter pw) { pw.append('x'); } // no warning here, even though append returns this private Foo method() { return this; } @Override public void close() { /**/ } } Invoking a method on a resource may generate a warning or not if the method returns a reference to the resource itself. It depends. In the example above, the compiler generates no warning for the class java.io.PrintWriter but generates a warning for the class Foo. Which behavior is "correct" might be a matter of taste (I'd prefer no warning in this case), but both cannot be correct simultaneously.
This affects many "builder" classes which are closable and always return "this" to allow method chaining. The following line produces 3 separate warnings (!) : builder.startObject().value("hello").endObject();
bulk move out of 4.19 - flagging as helpwanted but keeping in radar for 4.20
Bulk move out of 4.20
Bulk Move out of 4.21
Bulk move out of 4.22. If this is going to make it to 4.22, feel free to set the target back.
Bulk move out of 4.23