Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in DefinitionNameUtils.toExportQualifiedName() when compiling global functions #184

Open
doublefx opened this issue Aug 28, 2013 · 3 comments
Assignees

Comments

@doublefx
Copy link
Member

/*noop.as*/
package util {

public function noop():Function {
    return _noop;
}
}

internal var _noop:Function = new Function();

NPE in DefinitionNameUtils.toExportQualifiedName(DefinitionNameUtils.java:56):

Problem SourcePath does not exist for java.lang.NullPointerException
    at randori.compiler.internal.utils.DefinitionNameUtils.toExportQualifiedName(DefinitionNameUtils.java:56)
    at randori.compiler.internal.codegen.js.emitter.BinaryOperatorEmitter.emit(BinaryOperatorEmitter.java:109)
    at randori.compiler.internal.codegen.js.RandoriEmitter.emitBinaryOperator(RandoriEmitter.java:528)
    at randori.compiler.internal.codegen.as.ASBlockWalker.visitBinaryOperator(ASBlockWalker.java:515)
    at randori.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:323)
    at randori.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:86)
    at randori.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:111)
    at randori.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:158)
    at randori.compiler.internal.codegen.js.emitter.BinaryOperatorEmitter.emit(BinaryOperatorEmitter.java:153)
    at randori.compiler.internal.codegen.js.RandoriEmitter.emitBinaryOperator(RandoriEmitter.java:528)
    at randori.compiler.internal.codegen.as.ASBlockWalker.visitBinaryOperator(ASBlockWalker.java:515)
    at randori.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:323)
    at randori.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:86)
    at randori.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:111)
    at randori.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:158)
    at randori.compiler.internal.codegen.as.ASEmitter.emitStatement(ASEmitter.java:792)
    at randori.compiler.internal.codegen.as.ASBlockWalker.visitBlock(ASBlockWalker.java:325)
    at randori.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:257)
    at randori.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:86)
    at randori.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:111)
    at randori.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:158)
    at randori.compiler.internal.codegen.js.RandoriEmitter.emitMethodScope(RandoriEmitter.java:393)
    at randori.compiler.internal.codegen.js.RandoriEmitter.emitMethodScope(RandoriEmitter.java:639)
    at randori.compiler.internal.codegen.js.emitter.MethodEmitter.emit(MethodEmitter.java:120)
    at randori.compiler.internal.codegen.js.RandoriEmitter.emitMethod(RandoriEmitter.java:385)
    at randori.compiler.internal.codegen.as.ASBlockWalker.visitFunction(ASBlockWalker.java:264)
    at randori.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:131)
    at randori.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:86)
    at randori.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:111)
    at randori.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:158)
    at randori.compiler.internal.codegen.js.RandoriEmitter.emitClass(RandoriEmitter.java:311)
    at randori.compiler.internal.codegen.as.ASBlockWalker.visitClass(ASBlockWalker.java:234)
    at randori.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:115)
    at randori.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:86)
    at randori.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:111)
    at randori.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:158)
    at randori.compiler.internal.codegen.js.RandoriEmitter.emitPackageContents(RandoriEmitter.java:212)
    at randori.compiler.internal.codegen.as.ASBlockWalker.visitPackage(ASBlockWalker.java:222)
    at randori.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:111)
    at randori.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:86)
    at randori.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:111)
    at randori.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:158)
    at randori.compiler.internal.codegen.as.ASBlockWalker.visitFile(ASBlockWalker.java:185)
    at randori.compiler.internal.driver.model.BaseCompilationSet.writeClass(BaseCompilationSet.java:268)
    at randori.compiler.internal.driver.model.BaseCompilationSet.walkClass(BaseCompilationSet.java:230)
    at randori.compiler.internal.driver.model.BaseCompilationSet.walkClass(BaseCompilationSet.java:236)
    at randori.compiler.internal.driver.model.BaseCompilationSet.walkClass(BaseCompilationSet.java:236)
    at randori.compiler.internal.driver.model.BaseCompilationSet.writeFull(BaseCompilationSet.java:379)
    at randori.compiler.internal.driver.model.ApplicationModel.generate(ApplicationModel.java:153)
    at randori.compiler.internal.driver.RandoriApplication.generate(RandoriApplication.java:189)
    at randori.compiler.internal.driver.RandoriApplication.compile(RandoriApplication.java:97)
    at randori.compiler.internal.projects.RandoriApplicationProject.buildTarget(RandoriApplicationProject.java:116)
    at randori.compiler.internal.projects.RandoriApplicationProject.startCompile(RandoriApplicationProject.java:97)
    at randori.compiler.internal.projects.RandoriProject.compile(RandoriProject.java:237)
    at randori.compiler.clients.Randori.compile(Randori.java:206)
    at randori.compiler.clients.Randori.startCompile(Randori.java:128)
    at randori.compiler.clients.Randori.mainNoExit(Randori.java:92)
    at randori.compiler.clients.Randori.mainNoExit(Randori.java:81)
    at randori.compiler.internal.projects.RandoriBundleProject.compileRandori(RandoriBundleProject.java:381)
    at randori.compiler.internal.projects.RandoriBundleProject.startCompile(RandoriBundleProject.java:297)
    at randori.compiler.internal.projects.RandoriProject.compile(RandoriProject.java:237)
    at randori.plugin.compiler.RandoriCompilerSession.build(RandoriCompilerSession.java:164)
    at randori.plugin.compiler.RandoriCompilerSession.make(RandoriCompilerSession.java:126)
    at randori.plugin.compiler.RandoriCompiler.compile(RandoriCompiler.java:97)
    at com.intellij.compiler.impl.CompileDriver.a(CompileDriver.java:2044)
    at com.intellij.compiler.impl.CompileDriver.a(CompileDriver.java:1367)
    at com.intellij.compiler.impl.CompileDriver.a(CompileDriver.java:1073)
    at com.intellij.compiler.impl.CompileDriver.a(CompileDriver.java:799)
    at com.intellij.compiler.impl.CompileDriver.access$1100(CompileDriver.java:111)
    at com.intellij.compiler.impl.CompileDriver$9.run(CompileDriver.java:747)
    at com.intellij.compiler.progress.CompilerTask.run(CompilerTask.java:167)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:495)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$8.run(ProgressManagerImpl.java:400)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:454)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)java.lang.Throwable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:54)
    at randori.plugin.service.ProblemsService.addProblem(ProblemsService.java:106)
    at randori.plugin.service.ProblemsService.addAll(ProblemsService.java:84)
    at randori.plugin.compiler.RandoriCompilerSession$ProblemBuildRunnable.run(RandoriCompilerSession.java:395)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:343)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:682)
    at java.awt.EventQueue$3.run(EventQueue.java:680)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
    at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:700)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:525)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

I quickly fixed it:

        String qualifiedName = typeNode != null ?
                MetaDataUtils.getExportQualifiedName(typeNode.getDefinition()) :
                "";

It generates:

/** Compiled by the Randori compiler v0.2.6.2 on Wed Aug 28 16:10:20 CEST 2013 */

if (typeof util == "undefined")
    var util = {};

util.noop = function() {
    return _noop;
}

util.noop.className = "util.noop";

util.noop.getRuntimeDependencies = function(t) {
    var p;
    return [];
};

util.noop.getStaticDependencies = function(t) {
    var p;
    return [];
};

util.noop.injectionPoints = function(t) {
    return [];
};
@ghost ghost assigned teotigraphix Aug 28, 2013
@doublefx
Copy link
Member Author

Well, after my change, it compiles but internal var _noop:Function = new Function(); is never generated :P

@doublefx
Copy link
Member Author

Same with or without [JavaScript(mode="global")]

@doublefx
Copy link
Member Author

It seems to be an issue with the internal NS, I just tried this:

package util {

public class InternalTest {

    internal var internalVar:InternalClass = _internalVar;

    public function InternalTest() {
        var classVar:InternalClass = new InternalClass();
        var defaultError:Function = _defaultError;
    }
}
}

internal class InternalClass {
}

internal class InternalClassWithBody {
    public function toString():String {
        return "InternalClassWithBody";
    }
}

internal function _defaultError():void {
    throw new Error("Not Specified");
}

internal var _internalVar = new InternalClass();

and had only the InternalClassWithBody generated:

/** Compiled by the Randori compiler v0.2.6.2 on Wed Aug 28 16:56:29 CEST 2013 */

if (typeof util == "undefined")
    var util = {};

util.InternalTest = function() {
    var classVar = new util.InternalTest$InternalClass();
    var defaultError = _defaultError;
};

util.InternalTest.className = "util.InternalTest";

util.InternalTest.getRuntimeDependencies = function(t) {
    var p;
    return [];
};

util.InternalTest.getStaticDependencies = function(t) {
    var p;
    return [];
};

util.InternalTest.injectionPoints = function(t) {
    return [];
};
util.InternalTest$InternalClassWithBody = function() {

};

util.InternalTest$InternalClassWithBody.prototype.toString = function() {
    return "InternalClassWithBody";
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants