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

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            hubbitus Pavel Alexeev

            Dates

              Created:
              Updated:

              Slack

                Issue deployment