I added some additional output:

System.out.println("resolved: " + 
flexJSProject.resolveQNameToCompilationUnit(usedName));

And in FlexJSProject.isExternalLinkage():

            for (String oneqname : qnames)
            {
                System.out.println(oneqname);
            }


     [java] resolved: SWC: [DefinitionPromise "XML", DefinitionPromise "QName", 
DefinitionPromise "XMLList"]
     [java] XML
     [java] QName
     [java] XMLList
 

So, it looks like the order of the classes are indeed XML, QName, XMLList.

Maybe, the cu should be trimmed to make QName the first one before being passed 
to FlexJSProject.isExternalLinkage().

> On Jan 31, 2017, at 1:03 AM, Harbs <harbs.li...@gmail.com> wrote:
> 
> To me, the problem looks like the output being fed into postProcess. There is 
> no goog.require in that string.
> 
> When the code loops through the lines, it does not find XML as a foundRequire 
> and it does not add it because there is no goog.require for the XML.
> 
> Interestingly, on systems which output goog.require (i.e. Yishay’s machine), 
> it’s getting two goog.requires instead of one.
> 
> 
> Anyway. I just did this:
>                    for (String usedName :usedNames) {
>                        System.out.println("usedName: " + usedName);
>                        if (!foundRequires.contains(usedName)) {
>                            System.out.println("usedName: " + usedName);
>                            System.out.println("getQualifiedName(): " + 
> classDefinition.getQualifiedName());
> 
>                            if 
> (usedName.equals(classDefinition.getQualifiedName())) continue;
>                            System.out.println("not qualified name");
>                            if (((JSFlexJSEmitter) 
> asEmitter).getModel().isInternalClass(usedName)) continue;
>                            System.out.println("not internal class");
>                            if (subDocumentNames.contains(usedName)) continue;
>                            System.out.println("not in subDocumentNames");
>                            if (flexJSProject != null && 
> flexJSProject.isExternalLinkage(flexJSProject.resolveQNameToCompilationUnit(usedName)))
>                               continue;
>                            System.out.println("not sure what this checked");
>                            namesToAdd.add(usedName);
>                        }
>                    }
> 
> and got this output:
> 
>   [java] usedName: org.apache.flex.core.View
>     [java] usedName: org.apache.flex.html.Label
>     [java] usedName: org.apache.flex.core.SimpleCSSValuesImpl
>     [java] usedName: test_project
>     [java] usedName: test_project
>     [java] getQualifiedName(): test_project
>     [java] usedName: org.apache.flex.core.Application
>     [java] usedName: org.apache.flex.events.Event
>     [java] usedName: test_project
>     [java] usedName: test_project
>     [java] getQualifiedName(): test_project
>     [java] usedName: XML
>     [java] usedName: XML
>     [java] getQualifiedName(): test_project
>     [java] not qualified name
>     [java] not internal class
>     [java] not in subDocumentNames
>     [java] line: 
> 
> So, the problem appears to be here:
>                            if (flexJSProject != null && 
> flexJSProject.isExternalLinkage(flexJSProject.resolveQNameToCompilationUnit(usedName)))
> 
> I have no idea what’s being checked there, and I’m done for the night...
> 
>> On Jan 31, 2017, at 12:17 AM, Alex Harui <aha...@adobe.com> wrote:
>> 
>> Hmm.  The one you sent is the same as the one I have.  Maybe I dreamt
>> about what I saw earlier.  Let's go back to verifying how the code works.
>> In MXMLFlexJSEmitter.java in postProcess(), there is a code block like
>> this:
>> 
>> for (String usedName :usedNames) {
>> if (!foundRequires.contains(usedName)) {
>>   if (usedName.equals(classDefinition.getQualifiedName())) continue;
>>   if (((JSFlexJSEmitter)
>> asEmitter).getModel().isInternalClass(usedName)) continue;
>>   if (subDocumentNames.contains(usedName)) continue;
>>   if (flexJSProject != null &&
>> flexJSProject.isExternalLinkage(flexJSProject.resolveQNameToCompilationUnit
>> (usedName)))
>>     continue;
>>   namesToAdd.add(usedName);
>> }
>>                   }
>> 
>> For me, when usedName is XML, I end up calling isExternalLinkage and it
>> returns false and thus namesToAdd ends up with XML in it.  See if you can
>> add more System.out calls to determine if isExternalLinkage is getting
>> called for XML and returning true.
>> 
>> 
>> Then the puzzle is to see why isExternalLinkage returns true.  There is a
>> special case in isExternalLinkage in FlexJSProject.java.  There is code
>> that looks like this:
>> 
>> List<String> qnames;
>>       try {
>> qnames = cu.getQualifiedNames();
>> String qname = qnames.get(0);
>> if (qname.equals("QName"))
>>   return false;
>> 
>> For me, the cu for XML contains QName, XML and XMLList and QName is first
>> so this test returns false.  I thought I saw a case where a
>> playerglobal.swc had a different set of classes in the cu for XML.  Maybe
>> in your case, XML is being defined in some other cu.  You can output
>> cu.getAbsoluteFilename().
>> 
>> We could just change the test to test if qnames.contains("XML"), but that
>> is potentially a lot slower.  We should verify exactly what is going on
>> before making such a change.
>> 
>> Thanks,
>> -Alex 
>> 
> 

Reply via email to