groovy

println invoked on a writer object still prints to System.out and not to the given writer

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-3
  • Fix Version/s: 1.5.2
  • Component/s: None
  • Labels:
    None
  • Environment:
    groovy jsr03, jdk 1.4.2_09
  • Testcase included:
    yes
  • Number of attachments :
    2

Description

println does not seem to be interpreted as just another method on an object even if it should, e.g.

mywriter.println("FOO")

still seems print to System.out and not invoke the println method on the mywriter object.

Please see the included test case.

  1. printlntest.groovy
    06/Sep/05 2:47 AM
    0.5 kB
    Antti Karanta
  2. printlntest.groovy
    06/Sep/05 2:31 AM
    0.5 kB
    Antti Karanta

Activity

Hide
Antti Karanta added a comment -

Woops, there is a bug in the test case. The line:

assertEquals(foo.join(""), writer.toString())

should be:

assertEquals(foo.join("\n"), writer.toString())

This does not change this being a bug, though. = )

Show
Antti Karanta added a comment - Woops, there is a bug in the test case. The line: assertEquals(foo.join(""), writer.toString()) should be: assertEquals(foo.join("\n"), writer.toString()) This does not change this being a bug, though. = )
Hide
Antti Karanta added a comment -

Corrected a bug in the test case. Actually the line I mentioned should be

assertEquals(foo.join("\n") + "\n", writer.toString())

This is corrected in the attached file.

Show
Antti Karanta added a comment - Corrected a bug in the test case. Actually the line I mentioned should be assertEquals(foo.join("\n") + "\n", writer.toString()) This is corrected in the attached file.
Hide
Antti Karanta added a comment -

Ah, this seems to be the same issue that made the mailing list today. println method is not actually defined in Writer, so the println that is added to Object class by Groovy is invoked.

I would propose that the added method Object.println be made protected thus making examples like the one I gave fail due to trying to access a method where it is not visible.

Show
Antti Karanta added a comment - Ah, this seems to be the same issue that made the mailing list today. println method is not actually defined in Writer, so the println that is added to Object class by Groovy is invoked. I would propose that the added method Object.println be made protected thus making examples like the one I gave fail due to trying to access a method where it is not visible.
Hide
Andres Almiray added a comment -

This one is still around, DGM does not have a Writer.println version so any calls route to Object.println, effectively printing to stdout instead.
Push it to 1.2?

Show
Andres Almiray added a comment - This one is still around, DGM does not have a Writer.println version so any calls route to Object.println, effectively printing to stdout instead. Push it to 1.2?
Hide
Paul King added a comment -

Now has special code to handle print and println for writers.

Show
Paul King added a comment - Now has special code to handle print and println for writers.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: