[Mono-bugs] [Bug 29590][Nor] New - Access of private constructor possible

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
28 Aug 2002 21:11:39 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ritterfelix@web.de.

http://bugzilla.ximian.com/show_bug.cgi?id=29590

--- shadow/29590	Wed Aug 28 17:11:39 2002
+++ shadow/29590.tmp.20415	Wed Aug 28 17:11:39 2002
@@ -0,0 +1,35 @@
+Bug#: 29590
+Product: Mono/MCS
+Version: unspecified
+OS: SuSE 8.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ritterfelix@web.de               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Access of private constructor possible
+
+It is possible to create an object using "new" if the constructor is 
+private.
+Example:
+
+class Singleton
+{
+  public static Singleton instance=null;
+  private Singleton() {
+  }
+  public static Singleton getInstance() {
+    if (instance==null) instance = new Singleton();
+    return instance;
+  }
+}
+
+...
+Singleton a = new Singleton(); // it works, but it should not