Anyone know where Twiddle's real documentation is? Nothing is appearing online for how to construct objects in the command line and then pass them as a parameter to an MBean operation invocation. Not sure why JBoss released software without documentation.
I can invoke MBean operations with string parameters, but any other type of object besides string seems to be undocumented.
Thanks!
Related
From ExecutableType we can inspect the types of parameters using getParameterTypes(). However, I cannot find a mechanism to inspect the parameter names.
I understand that in <= Java 7 the parameter names are not retained in the bytecode. However, I would still expect to be able to access the argument names arg0, arg1.
If the compiler is a Java 8 compiler running with the -parameters flag I would expect to get the original parameter names from the source code.
Is there a mechanism that I am overlooking? It seems strange that we are able to query this using the reflection API using Parameter.getName() if we are not capable of retrieving this information whilst annotation processing.
Instead of ExecutableType, use ExecutableElement. From this you can get it's parameters which should all have names. You can convert using Types.asElement.
Looking for ideas of how to disable a uvm_warning that occurs in the `uvm_object_utils macro.
UVM_WARNING #0: reporter [TPRGED] Type name 'xxx_packet' already registered with factory. No string-based lookup support for multiple types with the same type name.
I don't care about string-based lookup and I'd like to be able to use the same class name in multiple tests (I'm using per-test packages to make this work). So I'd really like to disable this warning. However, even the command the command line disable doesn't seem to help.
I tried:
+uvm_set_action=*,TPRGED,UVM_WARNING,UVM_NO_ACTION
This works for other warnings, but in this case the warning seems to occur even before command line arguments are processed.
These messages come because of static initializations, you will not be able to turn them off.
If you don't want register string names with the factory, use the `uvm_object_param_utils macro instead of the `uvm_object_utils The only difference that is does not register a string with the factory. See http://go.mentor.com/mcem for more information.
I'm trying to use PowerShell to call some F# code which uses Akka.Net actors.
The F# code works fine in unit testing and when run from the F# interpreter, but when I call the same code from a PowerShell cmdlet I get the following exception:
System.MissingMethodException: Method not found: 'Void Nessos.FsPickler.BinarySerializer..ctor(Microsoft.FSharp.Core.FSharpOption`1<Boolean>,
Microsoft.FSharp.Core.FSharpOption`1<Nessos.FsPickler.ITypeNameConverter>)'.
at Akka.FSharp.Serialization.ExprSerializer..ctor(ExtendedActorSystem system)
at Akka.FSharp.Serialization.exprSerializationSupport(ActorSystem system)
at Namespace.NewActorCmdlet..ctor(Host hostA, Host hostB, Boolean option, UserDetails user) in
E:\Projects\Namespace\NewActorCommand.fs:line 24
at Namespace.StartNewActorCommand.ProcessRecord() in
E:\Projects\Namespace\StartNewActor.fs:line 67
at System.Management.Automation.CommandProcessor.ProcessRecord()
I tried running [Nessos.FsPickler.BinarySerializer]::new.OverloadDefinitions in that PowerShell session to check what methods PS though was available and I get:
Nessos.FsPickler.BinarySerializer new(Microsoft.FSharp.Core.FSharpOption[bool] forceLittleEndian, Microsoft.FSharp.Core.FSharpOption[Nessos.FsPickler.ITypeNameConverter] typeConverter)
First thing I noticed was that the version shown by PowerShell takes an FSharpOption[bool] instead of FSharpOption[Boolean]. I tried modifying the Akka.FSharp code to explcitly pass an Option, but that didn't seem to help.
I'm using FSharp.Core 4.0.0.1 (other links suggested 3.0 had problems).
Has anyone seen anything similar?
Even suggestions about where to look for the problem would be helpful, I'm not sure if the issue is with PowerShell, F# or Akka.Net.
Powershell can be difficult when it comes to matching methods based on parameter types. I've found that sometimes i have to "trick" PS by passing an expression to a method rather than a PS variable. For example $object.method($something.property) instead of $prop = $something.property; $object.method($prop) has worked for me.
In the case of overloaded methods another thing you can do is use Reflection to make sure you've got the method with the right signature. For example:
$mi=$object.gettype().getmethod('TheMethod',#([typeParm1],[typeParm2]))
$mi.invoke($object, #($arg1,$arg2))
And sometimes casting helps: $object.method([typeToMatchMethodSig]$arg1) or maybe even a double cast:$object.method([bool][int]$arg1) In both cases I think you'll have more luck if you pass the cast expression as an argument, rather than assign it to a variable and pass the variable.
I doubt this is the case in the OP, but using [activator]::createinstance(...) can be used with a private constructor.
I usually muck around with it till either something works or I give up.
BTW, you can turn on PS tracing for parameter binding and get a lot of info, which may or may not be useful.
I'm using eclipse and want to have a "macro" that the preprocessor will replace with the name of the current method before compiling it.
I have an error reporting function, that is called as: reportthis(String errormessage) - different functions throughout the application have try/catch blocks, that call reportthis(...) from the catch block upon errors.
I'd like to be able to specify something like reportthis(MACRO_CURRENT_METHOD_NAME + ":" + e.ToString()); - where MACRO_CURRENT_METHOD_NAME will be preprocessed by eclipse before compilation and result in the name of the method where the catch {} block calls reportthis().
So if the catch{} block happens in main(), the macro should return the string "main" (or "main()", etc.).
Is this possible? how do i go about achieving my goal?
Thank you!
Edit
I wish to get this done by preprocessors in Eclipse - are those impossible? isn't it possible to perhaps write a plugin for eclipse to replace all occurrences of "MACRO_CURRENT_METHOD_NAME" with the current function name?
I've not found an automated way of doing this, so have manually added a string literal that indicates the name of the caller at each invocation of the logging code.
Nokia's S40 platform is also based on Java-ME, and I know some Nokia S40 developers have made good use of Jarrut, which is available on Sourceforge, to produce stack traces by modifying the program to track the stack. You could leverage this functionality to get the calling function name in your logging code, but you may need to modify Jarrut a bit to make that work.
Java does not support Macros.
But what you can do to determine the current method is something like
final StackTraceElement aTop = Thread.currentThread ().getStackTrace ()[1];
System.out.println (aTop.getMethodName ());
By using the element at index [1] you get the calling method, because the element at [0] is Thread.getStackTrace().
If you wrap this code in an additional method, you must adopt the array index e.g. to 2, depending on the number of wrapping methods you are using.
There is no preprocessor in java, and no macro language either.
While there are situations where either could be useful, if I understand your problem its entirely pointless, since the stack trace of the exception will already contain class and method of the place where the excetion occured.
Instead of passing a String to your "reportthis()", make a signature that just takes the exception and prints it (or just write e.printStackTrace()).
I'm writing a Cmdlet that can be called in the middle of a pipeline. With this Cmdlet, there are parameters that have the ValueFromPipelineByPropertyName attribute defined so that the Cmdlet can use parameters with the same names that are defined earlier in the pipeline.
The paradox that I've run into is in the overridden BeginProcessing() method, I utilize one of the parameters that can get its value bound from the pipeline. According to the Cmdlet Processing Lifecycle, the binding of pipeline parameters does not occur until after BeginProcessing() is called. Therefore, it seems that I'm unable to rely on pipeline bound parameters if they're attempting to be used in BeginProcessing().
I've thought about moving things to the ProcessRecord() method. Unfortunately, there is a one time, relatively expensive operation that needs to occur. The best place for this to happen seems to be in the BeginProcessing() method to help ensure that it only happens once in the pipeline.
A few questions question surrounding this:
Is there a good way around this?
These same parameters also have the Mandatory attribute set on them. How can I even get this far without PowerShell complaining about not having these required parameters?
Thanks in advance for your thoughts.
Update
I took out the second part of the question as I realized I just didn't understand pipeline bound parameters well enough. I mistakingly thought that pipeline bound parameters came from the previous Cmdlet that executed in the pipeline. The actually come from the object being passed through the pipeline! I referenced a post by Keith Hill to help understand this.
You could set an instance field bool (Init) to false in BeginProcessing. Then check to see if the parameter is set in BeginProcessing. If it is then call a method that does the one time init (InitMe). In ProcessRecord check the value of Init and if it is false, then call InitMe. InitMe should set Init to true before returning.
Regarding your second question, if you've marked the parameter as mandatory then it must be supplied either as a parameter or via the pipeline. Are you using multiple parameter sets? If so, then even if a parameter is marked as mandatory, it is only mandatory if the associated parameter set is the one that is determined by PowerShell to be in use for a particular invocation of the cmdlet.