Re: Why does C# see protected java members as public?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Gia (gia_at_no.spam)
Date: 03/18/04


Date: Wed, 17 Mar 2004 16:38:40 -0800

I understand issues regarding java package scoping, but my original question
was about "protected" keyword. What is it in the java "protected" semantics
that makes it unmappable to .net "protected" access modifier?

thanks
-gia

"Michael Green" <mikegreonline@microsoft.com> wrote in message
news:KCbemEtBEHA.2340@cpmsftngxa06.phx.gbl...
> Scoping rules in Java language are different from those on .NET
>
> In order to preserve Java semantics on .NET, protected and package gets
> mapped to public scope in .NET. However, J# compiler maintains the scoping
> as defined by the Java language source using custom attributes. However
> other .NET languages do not understand Java language semantics and give
> public access to the member.
>
> To take a concrete example, a package scope member grants access to any
> class in the same package. No scoping semantic on .NET maps to this rule.
> However, to ensure that Java language developers get the same semantics
and
> the code works at runtime, it needs to be mapped to public.
>
> Having said this, we understand the need to support .NET semantics in a
> consistent manner for other languages and therefore provide the
> securescoping option in the compiler. Using this option, we can map
> directly to the underlying .NET semantics which are stricter than the
> default mapping semantics.
>
> Under the secure scoping option, package gets mapped to assembly while
> protected gets mapped to family or assembly on .NET
>
> Hope that clarifies matters.
>
> Michael Green
> Microsoft Developer Support
>
>
> --------------------
> | From: "Gia" <gia@no.spam>
> | Subject: Why does C# see protected java members as public?
> | Date: Thu, 4 Mar 2004 17:11:19 -0800
> | Lines: 23
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.3790.0
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | Message-ID: <eTcEF7kAEHA.640@TK2MSFTNGP09.phx.gbl>
> | Newsgroups: microsoft.public.dotnet.vjsharp
> | NNTP-Posting-Host: ouroboros.siebel.com 206.154.118.2
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.vjsharp:5600
> | X-Tomcat-NG: microsoft.public.dotnet.vjsharp
> |
> | Basically J# doesn't allow access to protected members of other classes,
> but
> | C# does. ildasm shows that protected members are producing code like
this:
> |
> | .method public hidebysig strict virtual
> | instance long getX() cil managed
> | {
> | .custom instance void
> | [vjscor]com.ms.vjsharp.cor.JavaFlags::.ctor(int32) = ( 01 00 04 00 00 00
> 00
> | 00 )
> | ...
> |
> | Apparently in IL code method is still public, but J# compiler inserts
> | JavaFlags attribute that indicates the method should be protected. Since
> J#
> | compiler is the only one that knows how to look at this flag other
> compilers
> | will see the method just as it is - public.
> |
> | What was the motivation for this design decision, and is this going to
be
> | fixed?
> |
> | Thanks
> | -Gia
> |
> |
> |
>



Relevant Pages

  • RE: Why does C# see protected java members as public?
    ... Scoping rules in Java language are different from those on .NET ... In order to preserve Java semantics on .NET, protected and package gets ...
    (microsoft.public.dotnet.vjsharp)
  • Re: (OT) In search of a definition
    ... primarily works under Windows XP, I am in search of a "good ... a package was NOT part of the language. ... without looking for something to formulate a hostile response from. ... use in Java is the same as its use in C or other languages. ...
    (comp.lang.cobol)
  • Re: (OT) In search of a definition
    ... a package was NOT part of the language. ... without looking for something to formulate a hostile response from. ... use in Java is the same as its use in C or other languages. ...
    (comp.lang.cobol)
  • building java rpm
    ... I am trying to build a java rpm based on the nosrc.rpm from jpackage.org ... chmod -R u+w bin CHANGES COPYRIGHT javaws lib LICENSE man plugin ... This package contains source files for %. ...
    (Fedora)
  • Re: Ada hello world for Android; success!
    ... Here's the Ada 'main program': ... -- Prefix must match ../AndroidManifest.xml manifest | package ... pragma Export (Java, Hello, "net.example.helloada.hello"); ... Fixing the bugs in the GNAT tools was easy by comparison, ...
    (comp.lang.ada)