My code which uses NSKeyedUnarchiver now throws a TypeLoadException when using the latest monomac from Git:
System.EntryPointNotFoundException: monomac_IntPtr_objc_msgSend_IntPtr at at (wrapper managed-to-native) MonoMac.ObjCRuntime.Messaging:monomac_IntPtr_objc_msgSend_IntPtr (intptr,intptr,intptr) at MonoMac.Foundation.NSKeyedUnarchiver..ctor (MonoMac.Foundation.NSData data) [0x0002a] in /Users/richard/Development/MonoMacSources/gitsrc/monomac/src/Foundation/NSKeyedUnarchiver.g.cs:93
The same code runs fine using the version of monomac.dll which ships with Xamarin Studio.
Test case:
public NSTextFieldCell Cell = new NSTextFieldCell("string");
public override void AwakeFromNib()
{
base.AwakeFromNib();
Console.WriteLine(Cell.StringValue);
using(NSMutableData data = new NSMutableData())
{
using(NSKeyedArchiver archiver = new NSKeyedArchiver(data))
{
this.Cell.EncodeTo(archiver);
archiver.FinishEncoding();
}
using(NSKeyedUnarchiver unarchiver = new NSKeyedUnarchiver(data))
{
var cell = (NSTextFieldCell)Activator.CreateInstance(typeof(NSTextFieldCell), new object[] { unarchiver });
unarchiver.FinishDecoding();
Console.WriteLine(cell.StringValue);
}
}
}
Exception is thrown at new NSKeyedUnarchiver(data)).
Does anyone have an idea? Or a workaround?
This is effectively a regression in the latest MonoMac from Git.
I will fix it (currently there is no workaround except use an earlier version from Git).
It's fixed now.
Related
I have a simple bytebuddy agent which records method entry/exit. I run it as
export MAVEN_OPTS="-javaagent:$JAVA_AGENT=$CONFIG_FILE"
mvn clean test -DargLine="-javaagent:$JAVA_AGENT_JAR"
It works well for couple of my Java projects. However, when I tried it on few open source projects: flink, guava, dubbo it dint work.
JDK: 1.8
ByteBuddy: 1.10.18
Here is code snippet
#Override
public void instrument(Instrumentation instrumentation) {
final Advice methodAdvice = Advice.to(MethodTracer.class);
ElementMatcher.Junction matcher = nameStartsWithAnyOf(includes);
new AgentBuilder.Default()
.with(new TracerLogger())
.type(matcher)
.transform((builder, typeDescription, classLoader, module) -> {
builder = builder.visit(new AsmVisitorWrapper.ForDeclaredMethods().method(ElementMatchers.isMethod(), methodAdvice));
System.out.println("transform() called");
return builder;
}
})
.installOn(instrumentation);
}
public class MethodTracer {
#Advice.OnMethodEnter(inline = false)
public static StackNode enter(
#Advice.Origin("#t") String type, #Advice.Origin("#m") String method, #Advice.Origin("#s") String signature) {
System.out.println("OnMethodEnter() called");
return CallableTracer.enter(type, method, signature, false);
}
#Advice.OnMethodExit(inline = false, onThrowable = Throwable.class)
public static void exit(#Advice.Enter StackNode node) {
CallableTracer.exit(node);
}
When I run, it prints transform() called
but it never prints OnMethodEnter() called
any hint to resolve this? Thanks
Update: To answer Rafael's questions: Yes, tracer logger outputs. Some samples are here:
[2020-12-28 08:22:40:292] [DEBUG] [TracerLogger] onTransformation: class org.apache.flink.api.common.functions.AbstractRichFunction, null, false, agent.rt.bytebuddy.dynamic.DynamicType$Default$Unloaded#7e56d17f
[2020-12-28 08:22:40:292] [DEBUG] [TracerLogger] onComplete: org.apache.flink.api.common.functions.AbstractRichFunction, null, false
I don't see any log from onError(), so not sure if its transformation error.
adding these to pom.xml allowed me to register retransformation strategy, but the Advice is still not working.
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
This is how I register retransformation strategy:
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
.with(AgentBuilder.InitializationStrategy.NoOp.INSTANCE)
.with(AgentBuilder.TypeStrategy.Default.REDEFINE)
I ran with .with(AgentBuilder.Listener.StreamWriting.toSystemOut()). for flink methods, it prints loaded=false
using janusGraph git code example : example-remotegraph
It works well when i going to create elements and do some query things.
But it report exception when update and delete...
java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: Could not locate method: DefaultGraphTraversal.none()
at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
at org.apache.tinkerpop.gremlin.driver.ResultSet.one(ResultSet.java:107)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.hasNext(ResultSet.java:159)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:166)
at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:153)
at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:142)
at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:127)
at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal.nextTraverser(DriverRemoteTraversal.java:108)
at org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.processNextStart(RemoteStep.java:80)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:128)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:38)
at org.apache.tinkerpop.gremlin.process.traversal.Traversal.iterate(Traversal.java:203)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.iterate(GraphTraversal.java:2694)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal$Admin.iterate(GraphTraversal.java:178)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.iterate(DefaultGraphTraversal.java:48)
at org.janusgraph.example.GraphApp.deleteElements(GraphApp.java:301)
at org.janusgraph.example.GraphApp.runApp(GraphApp.java:350)
at org.janusgraph.example.RemoteGraphApp.main(RemoteGraphApp.java:227)
here is the code :
public void deleteElements() {
try {
if (g == null) {
return;
}
LOGGER.info("deleting elements");
// note that this will succeed whether or not pluto exists
g.V().has("name", "pluto").drop().iterate();
if (supportsTransactions) {
g.tx().commit();
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
if (supportsTransactions) {
g.tx().rollback();
}
}
}
emmm.....i thought i have fixed this problem.....
the only reason perhaps the library version used doesn't match the gremlin-server's version;
I tried to turn the gremlin driver library to 3.2.9 version, and it works well.
You need to use the same Tinkerpop version JanusGraph is using, as this is an incompatible change that was introduced in Tinkerpop
I have a strange problem ...
I have implement the following fonction
private:
void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->Filter = (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1->FilterIndex = 2;
openFileDialog1->RestoreDirectory = true;
if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
{
if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
// her is my listview code
myStream->Close();
}
}
}
in my DLL:
my problem is that, when testing the code as dll, the dialog is not displayed but freezes the application Completely and may be terminated only by Task Manager ...no idea what was going on there ... gives no sense to me. who can help me please?
In the .NET Framework version 2.0, you can also specify the COM threading model for a C++ application using the /CLRTHREADATTRIBUTE (Set CLR Thread Attribute) linker option.
VS Setting:STA threading attribute (/CLRTHREADATTRIBUTE:STA)
https://msdn.microsoft.com/en-us//library/system.stathreadattribute%28v=vs.80%29.aspx
openFileDialog1->ShowHelp = true;
I put this line then it solved the problem.
I'm trying to create a Java Binding Library for BugSense, but one of the methods has a parameter named "params" which is a reserved word in C#. I've tried to use the Metadata.xml file to rename it, but I can't figure out how to access the class, let alone the method or it's parameter.
Here is the problem code it's generating:
namespace Com.Bugsense.Trace {
[global::Android.Runtime.Register ("com/bugsense/trace/ActivityAsyncTask", DoNotGenerateAcw=true)]
internal partial class ActivityAsyncTaskInvoker : ActivityAsyncTask {
static IntPtr id_doInBackground_arrayLjava_lang_Object_;
[Register ("doInBackground", "([Ljava/lang/Object;)Ljava/lang/Object;", "GetDoInBackground_arrayLjava_lang_Object_Handler")]
protected override global::Java.Lang.Object DoInBackground (global::Java.Lang.Object[] params)
{
if (id_doInBackground_arrayLjava_lang_Object_ == IntPtr.Zero)
id_doInBackground_arrayLjava_lang_Object_ = JNIEnv.GetMethodID (class_ref, "doInBackground", "([Ljava/lang/Object;)Ljava/lang/Object;");
IntPtr native_params = JNIEnv.NewArray (params);
global::Java.Lang.Object __ret = Java.Lang.Object.GetObject<global::Java.Lang.Object> (JNIEnv.CallObjectMethod (Handle, id_doInBackground_arrayLjava_lang_Object_, new JValue (native_params)), JniHandleOwnership.TransferLocalRef);
if (params != null) {
JNIEnv.CopyArray (native_params, params);
JNIEnv.DeleteLocalRef (native_params);
}
return __ret;
}
}
}
Here is my mapping, which I feel should work, but just refuses to.
<attr path="/api/package[#name='com.bugsense.trace']/class[#name='ActivityAsyncTaskInvoker']/method[#name='doInBackground']/parameter[#name='params']" name="managedName">#params</attr>
I've tried everything I can think of. Please, HELP!
So, turns out it's just a bug in the current version of Mono for Android. If you update to the 4.2.4 build, which is in beta, everything compiles fine.
Please someone help me. I have tried to convert http://drobosson.blogspot.com/2011/01/google-android-camera-preview-data.html and http://marakana.com/forums/android/examples/39.html to Monodroid (C#) and have had no success. I have followed the instructions (as far as I can see) and I do not know how to preview the camera (I am not even on taking a PICTURE yet).
Here is my current code - it fails on the Android.Hardware.Camera.Open() method with a Java.Lang.RuntimeException (Stacktrace says "at Android.Runtime.JNIEnv.CallStaticObjectMethod (IntPtr jclass, IntPtr jmethod) [0x00000] in :0 at Android.Hardware.Camera.Open()...")
I have added the camera permission in the manifest.
Code:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.CameraPage);
_surfaceView = FindViewById<SurfaceView>(Resource.Id.imgCapture);
_debug = FindViewById<TextView>(Resource.Id.lblCameraDebug);
try
{
_camera = Android.Hardware.Camera.Open();
//Android.Hardware.Camera.Parameters camparam = _camera.GetParameters();
//camparam.SetPreviewSize(_surfaceView.Width, _surfaceView.Height);
//_camera.SetParameters(camparam);
//_camera.SetPreviewDisplay(_surfaceView.Holder);
//_camera.StartPreview();
}
catch(Exception ex)
{
_debug.Text = string.Format("Error: {0} - StackTrace: {1}", ex.Message,ex.StackTrace);
}
}
https://github.com/xamarin/monodroid-samples/blob/master/ApiDemo/Graphics/CameraPreview.cs
This clears most of it up. It's a starting point, not a solution.
It does NOT solve:
1. Rotation / Orientation (but that should be in the parameters)
2. Getting it onto a form element using axml (not as an entire page)
3. Taking a picture.