Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2503 MOP 2.0 design inflluencing issues
  3. GROOVY-5013

Instantioantion object of class with private constructor

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Information Provided
    • 1.8.2
    • None
    • groovy-jdk
    • None

    Description

      I have try use standard Singleton pattern in groovy script:

      public class SingleTest {
      	private static final Instance = new SingleTest();
      
      	private SingleTest(){ }
      
      	public SingleTest getInstance(){
      		return Instance;
      	}
      
      	void test(){
      		println 'test';
      	}
      }
      
      SingleTest test = new SingleTest();
      test.test();
      

      But groovy instantiate object even if constructor marked as private:

      D:\imus\IdeaProjects\imus\instup\src\main\java\test-private-constructor>groovy test.groovy
      test
      

      P.S. Sorry for noise with http://jira.codehaus.org/browse/GROOVY-5012 I'd expect what in cloning process I can be able change description of bug.

      Attachments

        Activity

          People

            Unassigned Unassigned
            hubbitus Pavel Alexeev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: