It's a bit different in that the AVM is strict about access modifiers; you 
cannot use reflection to call a private method from outside its class. However 
I know developers have wanted non-public constructors for a long time and most 
won't care if they're not enforced at runtime, so I don't object to the 
compiler enhancement. I just wanted to mention something that folks should be 
aware of.

Another thing to be aware of is that this mean there will be source code that 
compiles under a Falcon that doesn't compile under the old compiler. Would we 
change the old compiler as we'll or not bother? I'd say don't bother.

- Gordon

> On Oct 5, 2014, at 8:09 AM, "Christofer Dutz" <christofer.d...@c-ware.de> 
> wrote:
> 
> But in java this is not much different. Unless you explicitly tell your Java 
> VM to be strict, you can get a private constructor via Reflection, make this 
> accesslible at runtime and instantiate it, no matter what the source-code 
> says. Same with the type of generics. 
> 
> So I guess it would be a great addition to Flex to at least have features 
> checked by the compiler, even if the runtime doesn't enforce it.
> 
> Chris
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Gordon Smith [mailto:gsmit...@hotmail.com] 
> Gesendet: Sonntag, 5. Oktober 2014 04:36
> An: dev@flex.apache.org
> Betreff: Re: [Falcon] Constructor NS (was: [Falcon] starting up)
> 
> In general the ActionScript Virtual Machine enforces access modifiers (so 
> that, for example, something marked private is truly inaccessible by any 
> means outside the class) but I don't think the AVM enforces non-public 
> constructors. I'm guessing that a constructor in the ABC is public regardless 
> of what the source code says, which would mean that the constructor could be 
> invoked by any code via reflection. If this is the case, I'm not convinced we 
> should pretend that constructors can be non-public.
> 
> - Gordon
> 
> Sent from my iPad
> 
>>> On Oct 4, 2014, at 4:14 PM, "OmPrakash Muppirala" <bigosma...@gmail.com> 
>>> wrote:
>>> 
>>> On Oct 4, 2014 12:55 PM, "Frédéric THOMAS" <webdoubl...@hotmail.com> wrote:
>>> 
>>> Hi,
>>> 
>>> I started to check if it was possible to have private and protected
>> constructor in Falcon and I have to admit it was tricky especially 
>> because I never seen a compiler from inside before but it is 
>> apparently possible, I've been able to compile successfully:
>>> package myLib {
>>> public class CTORTest {
>>>   private var _p:int;
>>> 
>>>   private function CTORTest(p:int) {
>>>       _p = p;
>>>   }
>>> 
>>>   private function anotherFct():CTORTest {
>>>       return new CTORTest(10);
>>>   }
>>> }
>>> }
>>> and using the compiled lib:
>>> 
>>> <?xml version="1.0"?>
>>> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
>> xmlns:s="library://ns.adobe.com/flex/spark"
>> creationComplete="creationCompleteHandler(event)">
>>>   <fx:Script><![CDATA[
>>>       import mx.events.FlexEvent;
>>> 
>>>       import myLib.CTORTest;
>>> 
>>>       private function creationCompleteHandler(event:FlexEvent):void {
>>>           var a:CTORTest = new CTORTest(1);
>>>       }
>>>       ]]></fx:Script>
>>> </s:Application>
>>> 
>>> gives:
>>> [Fault] exception, information=VerifyError: Error #1014: La classe
>> myLib:CTORTest::CTORTest est introuvable. (not found) with the legacy 
>> compiler
>>> and:
>>> F:\sources\falconTestDrive\shell\src\Main.mxml:9
>>> Erreur: Appel d'une méthode qui ne semble pas définie CTORTest. (Call 
>>> to
>> a undefined method)
>>>           var a:CTORTest = new CTORTest(1);
>>> 
>>> (I will customize the error message later)
>>> 
>>> I still need to check it works in the 3 possible ways to instantiate 
>>> a
>> Class [1] (at the moment it works only with 1st one), check that works 
>> with is  / instanceOf, revisit the cast function accordingly and maybe 
>> other things not yet in my mind and especially check FP won't complain using 
>> it.
>>> 
>>> /* expression = FunctionCallID(KeywordNewID(void), new_type_name,
>> ContainerID(expression*)) */
>>> /* expression = FunctionCallID(KeywordNewID(void), expression,
>> ContainerID(expression*)) */
>>> /* expression = FunctionCallID(KeywordNewID(void), vector_literal,
>> ContainerID(void)) */
>>> 
>>> In case all this works and I'm far to know it at the moment, I will 
>>> have
>> to think about implement "method overloading" otherwise I can't see 
>> any usage of a protected constructor and therefore will probably 
>> require some help for the best way to implement it.
>> 
>> Exciting to see these kind of experiments.  A really good usecase for 
>> private constructor would be to create a Singleton class, I.e a class  
>> that cannot be instantiated outside of itself.  Would that be 
>> something you can test for?
>> 
>> Thanks,
>> Om
>> 
>>> 
>>> Thanks,
>>> Frédéric THOMAS
>>> 
>>>> From: webdoubl...@hotmail.com
>>>> To: dev@flex.apache.org
>>>> Subject: RE: [Falcon] starting up
>>>> Date: Wed, 1 Oct 2014 16:57:28 +0100
>>>> 
>>>> Ah ok, thanks Gordon, I was tearing my hair out :-)
>>>> 
>>>> Frédéric THOMAS
>>>> 
>>>>> Subject: Re: [Falcon] starting up
>>>>> From: gsmit...@hotmail.com
>>>>> Date: Wed, 1 Oct 2014 08:51:16 -0700
>>>>> To: dev@flex.apache.org
>>>>> 
>>>>> That comment is out of date. Code Model was the part of pre-Falcon
>> Flash Builder that built an abstract syntax tree to support 
>> intelligent editing. We used it as the beginning of Falcon's lexer and 
>> parser. The code is just looking at the AST to see if the constructor 
>> has a non-public namespace.
>>>>> 
>>>>> - Gordon
>>>>> 
>>>>>> On Oct 1, 2014, at 8:33 AM, "Frédéric THOMAS" <
>> webdoubl...@hotmail.com> wrote:
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> I updated it to v17.0 and check in
>> falcon\compiler\generated\dist\sdk\lib\external, is there.
>>>>>> 
>>>>>> oops, looking better, it has both, just removed the bad one, it
>> runs.
>>>>>> 
>>>>>> Now, looking at internal\as\codegen\ClassDirectiveProcessor.java, 
>>>>>> I
>> see that:
>>>>>> 
>>>>>> // If a constructor has a namespace as part of it's declaration, 
>>>>>> it
>> must be declared public.
>>>>>> // It is ok to omit the namespace
>>>>>> // We must check the AST, as CM treats all ctors as public no
>> matter what the user typed in
>>>>>> // so the FunctionDefinition will always be in the public 
>>>>>> namespace if( node.getActualNamespaceNode() != null &&
>>>>>>      node.getActualNamespaceNode().getName() !=
>> IASKeywordConstants.PUBLIC)
>>>>>>  problems.add(new
>> ConstructorMustBePublicProblem(node.getActualNamespaceNode()));
>>>>>> 
>>>>>> What is the CM or Code Model ?
>>>>>> 
>>>>>> Thanks,
>>>>>> Frédéric THOMAS
>>>>>> 
>>>>>>> From: aha...@adobe.com
>>>>>>> To: dev@flex.apache.org
>>>>>>> Subject: Re: [Falcon] starting up
>>>>>>> Date: Wed, 1 Oct 2014 13:36:50 +0000
>>>>>>> 
>>>>>>> Could you have an old guava.jar?
>>>>>>> 
>>>>>>>> On 10/1/14 4:32 AM, "Frédéric THOMAS" <webdoubl...@hotmail.com>
>> wrote:
>>>>>>>> 
>>>>>>>> Hi,
>>>>>>>> 
>>>>>>>> I built it with ANT an ran Falcon compc.bat from the
>> generated/dist/sdk,
>>>>>>>> does anyone knows why I get that ?
>>>>>>>> 
>>>>>>>> Exception in thread "main" java.lang.NoClassDefFoundError:
>>>>>>>> com/google/common/cache/CacheLoader
>>>>>>>> at 
>>>>>>>> org.apache.flex.compiler.clients.MXMLC.<init>(MXMLC.java:379)
>>>>>>>> at org.apache.flex.compiler.clients.COMPC.<init>(COMPC.java:54)
>>>>>>>> at
>> org.apache.flex.compiler.clients.COMPC.staticMainNoExit(COMPC.java:75)
>>>>>>>> at org.apache.flex.compiler.clients.COMPC.main(COMPC.java:63)
>>>>>>>> Caused by: java.lang.ClassNotFoundException:
>>>>>>>> com.google.common.cache.CacheLoader
>>>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
>>>>>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>>>>>>>> at java.security.AccessController.doPrivileged(Native Method)  
>>>>>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>>>>>>>> at 
>>>>>>>> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
>>>>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>>>>>>>> ... 4 more
>>>>>>>> 
>>>>>>>> Thanks,
>>>>>>>> Frédéric THOMAS
>>> 

Reply via email to