Microsoft KB Archive/821176

= BUG: Cannot Override Abstract Class Member When You Convert Your Code to C# =

Article ID: 821176

Article Last Modified on 8/15/2005

-

APPLIES TO


 * Microsoft Visual J++ 1.0 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-



SYMPTOMS
You can use the Java Language Conversion Assistant (JLCA) to convert a project that is written in the Java programming language or the Visual J++ programming language to the C# programming language. However, when you convert Java code that has an abstract method that is defined in an abstract class, and this method is overridden in a derived class, you may receive the following error message when you compile the C# code:

Cannot change access modifiers when overriding 'internal' inherited member



CAUSE
This problem occurs because the JLCA adds an internal modifier for the abstract method in the abstract class when JCLA converts the Java code.



RESOLUTION
To resolve this problem, edit the C# code that the JLCA generates. Replace the internal modifier with a public modifier. The following is the modified code: abstract class Bird {   public abstract void  Wings; }

class Robin:Bird {   public override void  Wings {       System.Console.Out.WriteLine(&quot;Robin&quot;); } }



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
  Start a text editor such as Notepad, and then paste the following code in a new document: abstract class Bird { abstract void Wings; }

class Robin extends Bird { public void Wings { System.out.println(&quot;Robin&quot;); } }  Save the file as c:\Sample.java, and then quit the text editor. At a command prompt, type the following command, and then press ENTER:

\JavaLanguageConversionAssistantJConvert C:\Sample.java

The Sample.cs file and other project files are created. In Visual Studio .NET, open the project that you created in steps 1 through 3. On the Build menu, click Build Solution.</ol>

Keywords: kbbug kbjava kbcodegen kbpending KB821176

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.