Parameter definitionName must be non-null.
I'm trying to inject a Date when I get this error. My context class has:-
injector.mapSingleton(Date);
and my mediator has:-
[Inject]
public var calendarCurrentDate:Date
What am I missing here?
I am using RLv1.5.2 with Signals and the trace stack is:-
TypeError: Error #2007: Parameter definitionName must be non-null.
at flash.system::ApplicationDomain/getDefinition()
at org.swiftsuspenders.injectionpoints::MethodInjectionPoint/gatherParameterValues()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionpoints/MethodInjectionPoint.as:98]
at org.swiftsuspenders.injectionpoints::ConstructorInjectionPoint/applyInjection()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionpoints/ConstructorInjectionPoint.as:37]
at org.swiftsuspenders::Injector/instantiate()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/Injector.as:138]
at org.swiftsuspenders.injectionresults::InjectSingletonResult/createResponse()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionresults/InjectSingletonResult.as:40]
at org.swiftsuspenders.injectionresults::InjectSingletonResult/getResponse()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionresults/InjectSingletonResult.as:31]
at org.swiftsuspenders::InjectionConfig/getResponse()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/InjectionConfig.as:43]
at org.swiftsuspenders::InjectionConfig/getResponse()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/InjectionConfig.as:49]
at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint/applyInjection()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:36]
at org.swiftsuspenders::Injector/injectInto()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/Injector.as:125]
at org.swiftsuspenders::Injector/instantiate()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/Injector.as:139]
at org.robotlegs.base::MediatorMap/createMediatorUsing()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/MediatorMap.as:297]
at org.robotlegs.base::MediatorMap/onViewAdded()[/Development/Projects/Robotlegs/robotlegs-framework/src/org/robotlegs/base/MediatorMap.as:278]
at flash.display::DisplayObjectContainer/addChildAt()
...
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Till Schneidere... on 10 Oct, 2012 08:11 AM
Looks like something's going wrong with the Date object's creation.
Date is a pretty, well, "special" class, and it doesn't surprise me
too much that Swiftsuspenders doesn't handle its creation too well.
If your use-case allows that, try changing the mapping to
`injector.mapValue(new Date());
that should do the trick.
cheers,
till
Support Staff 2 Posted by Ondina D.F. on 10 Oct, 2012 09:37 AM
Hey Till and Chris,
I was curious why the Date Class behaves like this.
Could it be that the (dummy) constructor of the Date Class is the cause of the issue? The parameters have no type declaration.
http://hg.mozilla.org/tamarin-redux/file/f5191c18b0e4/core/Date.as
// Dummy constructor function - This is neccessary so the compiler can do arg # checking for the ctor in strict mode
// The code for the actual ctor is in DateClass::construct in the avmplus
I’ve created a custom class with a constructor like the one of the Date Class, and I got the same error (Parameter definitionName must be non-null.), if the parameters have no type declaration.
In SwifSuspenders, MethodInjectionPoint.gatherParameterValues. parameterConfig.typeName is null, therefore getDefinition() throws a reference error.
Of course that’s not a solution, but I just tried it out to see how it works, and it works:
Ondina
Support Staff 3 Posted by Till Schneidere... on 10 Oct, 2012 09:43 AM
Hey Ondina,
thanks for investigating! Looks like you're right: the missing types
are the problem. Without looking at the code, I don't really
understand (or remember) why Swiftsuspenders trips over that, as it
should theoretically just find out about the missing types and ignore
the arguments, creating a date without a parameter-less ctor. Maybe I
never actually tested with arguments that don't have any type
annotations, but only with ones that have "*" annotations?
This will certainly not be fixed in 1.5.x, but it's probably worth
doing so for 2.0.
Support Staff 4 Posted by Ondina D.F. on 10 Oct, 2012 09:55 AM
Thanks for the clarification, Till.
Cool. Looking forward to it :)
Support Staff 5 Posted by Ondina D.F. on 10 Oct, 2012 12:02 PM
@Chris & @all whom it may concern
It seems that Date is not the only class having a dummy constructor with no type declaration for params. I don’t know how many such classes there are, but Number, Boolean, Float, RegExp, String are some of them.
If you get an error like this:
TypeError: Error # 2007: Parameter definitionName must be non-null.
it probably means that the class you’re trying to map is one of the above mentioned or similar.
So, until Till fixes the issue in 2.0, and for versions under 2.0 the solution is the one Till mentioned, without the typo:
injector.mapValue(Date, new Date());
or
var myDate:Date=new Date();
injector.mapValue(Date, myDate);
The following mapping won’t work for the same reasons mentioned in the previous posts:
var myDate:Date=injector.instantiate(Date);
injector.mapValue(Date, myDate);
6 Posted by Chris on 12 Oct, 2012 02:47 AM
Using injector.mapValue s working for me.
Chris closed this discussion on 12 Oct, 2012 02:47 AM.