You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2015/01/23 00:47:22 UTC
[49/51] [partial] incubator-reef git commit: [REEF-93] Move java
sources to lang/java
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/AssemblyInfo.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/AssemblyInfo.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/AssemblyInfo.cpp
new file mode 100644
index 0000000..f6c3178
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/AssemblyInfo.cpp
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+using namespace System;
+using namespace System::Reflection;
+using namespace System::Runtime::CompilerServices;
+using namespace System::Runtime::InteropServices;
+using namespace System::Security::Permissions;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly:AssemblyTitleAttribute("JavaClrBridge")];
+[assembly:AssemblyProductAttribute("JavaClrBridge")];
+[assembly:AssemblyCopyrightAttribute("Copyright (c) 2014")];
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the value or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly:AssemblyVersionAttribute("1.0.*")];
+
+[assembly:ComVisible(false)];
+
+[assembly:CLSCompliantAttribute(true)];
+
+[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/AssemblyUtil.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/AssemblyUtil.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/AssemblyUtil.cpp
new file mode 100644
index 0000000..ce9239c
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/AssemblyUtil.cpp
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropAssemblies.h"
+
+
+void AssemblyUtil::Add(Assembly^ myasm) {
+ if (0 == _asmCount) {
+ //asm1 = myasm;
+ AppDomain^ currentDomain = AppDomain::CurrentDomain;
+ currentDomain->AssemblyResolve += gcnew ResolveEventHandler(&MyResolveEventHandler);
+ }
+ String^ asmName = myasm->FullName->ToLower();
+ Assembly^ existingAsm = nullptr;
+ if (!asms2->TryGetValue(asmName, existingAsm)) {
+ Console::WriteLine ("AssemblyUtil:: Adding " + asmName);
+ asms2->Add(asmName , myasm);
+ ++_asmCount;
+ }
+}
+
+Assembly^ AssemblyUtil::FindAsm (String^ myasm) {
+ Assembly^ returnAsm = nullptr;
+ if (!asms2->TryGetValue(myasm->ToLower(), returnAsm)) {
+ Console::WriteLine ("AssemblyUtil:: FindAsm_Not_Found " + myasm->ToString());
+ }
+ return returnAsm;
+}
+
+Assembly^ AssemblyUtil::MyResolveEventHandler(Object^ sender, ResolveEventArgs^ args) {
+ Console::WriteLine ("AssemblyUtil:: Resolving " + args->Name);
+ Assembly^ myAsm = AssemblyUtil::FindAsm(args->Name);
+ if (nullptr != myAsm) {
+ Console::WriteLine ("AssemblyUtil:: Found " + args->Name);
+ }
+ return myAsm ;
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/BinaryUtil.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/BinaryUtil.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/BinaryUtil.cpp
new file mode 100644
index 0000000..b7c3a2e
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/BinaryUtil.cpp
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropUtil.h"
+#include "BinaryUtil.h"
+
+DWORD GetActualAddressFromRVA(IMAGE_SECTION_HEADER* pSectionHeader, IMAGE_NT_HEADERS* pNTHeaders, DWORD dwRVA) {
+ DWORD dwRet = 0;
+
+ for (int j = 0; j < pNTHeaders->FileHeader.NumberOfSections; j++, pSectionHeader++) {
+ DWORD cbMaxOnDisk = min( pSectionHeader->Misc.VirtualSize, pSectionHeader->SizeOfRawData );
+
+ DWORD startSectRVA, endSectRVA;
+
+ startSectRVA = pSectionHeader->VirtualAddress;
+ endSectRVA = startSectRVA + cbMaxOnDisk;
+
+ if ( (dwRVA >= startSectRVA) && (dwRVA < endSectRVA)) {
+ dwRet = (pSectionHeader->PointerToRawData ) + (dwRVA - startSectRVA);
+ break;
+ }
+
+ }
+
+ return dwRet;
+}
+
+
+BINARY_TYPE IsManagedBinary(const wchar_t* lpszImageName) {
+ BINARY_TYPE binaryType = BINARY_TYPE_NONE;
+ HANDLE hFile = CreateFile(lpszImageName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (INVALID_HANDLE_VALUE != hFile) {
+ //succeeded
+ HANDLE hOpenFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
+ if (hOpenFileMapping) {
+ BYTE* lpBaseAddress = NULL;
+
+ lpBaseAddress = (BYTE*)MapViewOfFile(hOpenFileMapping, FILE_MAP_READ, 0, 0, 0);
+
+ if (lpBaseAddress) {
+ //having mapped the executable to our process space, now start navigating through the sections
+
+ //DOS header is straightforward. It is the topmost structure in the PE file
+ //i.e. the one at the lowest offset into the file
+ IMAGE_DOS_HEADER* pDOSHeader = (IMAGE_DOS_HEADER*)lpBaseAddress;
+
+ //the only important data in the DOS header is the e_lfanew
+ //the e_lfanew points to the offset of the beginning of NT Headers data
+ IMAGE_NT_HEADERS* pNTHeaders = (IMAGE_NT_HEADERS*)((BYTE*)pDOSHeader + pDOSHeader->e_lfanew);
+
+ IMAGE_SECTION_HEADER* pSectionHeader = (IMAGE_SECTION_HEADER*)((BYTE*)pNTHeaders + sizeof(IMAGE_NT_HEADERS));
+
+ //Now, start parsing
+ //check if it is a PE file
+
+ if (pNTHeaders->Signature == IMAGE_NT_SIGNATURE) {
+ //start parsing COM table
+
+ DWORD dwNETHeaderTableLocation = pNTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress;
+
+ if (dwNETHeaderTableLocation) {
+ //import data does exist for this module
+ IMAGE_COR20_HEADER* pNETHeader = (IMAGE_COR20_HEADER*)((BYTE*)pDOSHeader + GetActualAddressFromRVA(pSectionHeader, pNTHeaders, dwNETHeaderTableLocation));
+
+ if (pNETHeader) {
+ binaryType = BINARY_TYPE_CLR;
+ }
+ else {
+ binaryType = BINARY_TYPE_NATIVE;
+ }
+ }
+ else {
+ binaryType = BINARY_TYPE_NATIVE;
+ }
+ }
+ else {
+ binaryType = BINARY_TYPE_NONE;
+ }
+ UnmapViewOfFile(lpBaseAddress);
+ }
+ CloseHandle(hOpenFileMapping);
+ }
+ CloseHandle(hFile);
+ }
+ return binaryType;
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/BinaryUtil.h
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/BinaryUtil.h b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/BinaryUtil.h
new file mode 100644
index 0000000..dc946a6
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/BinaryUtil.h
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+typedef enum BINARY_TYPE {
+ BINARY_TYPE_NONE = 0,
+ BINARY_TYPE_NATIVE = 1,
+ BINARY_TYPE_CLR = 2,
+} BINARY_TYPE ;
+
+
+BINARY_TYPE IsManagedBinary(const wchar_t* lpszImageName);
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ClosedContextClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ClosedContextClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ClosedContextClr2Java.cpp
new file mode 100644
index 0000000..d87d17a
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ClosedContextClr2Java.cpp
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+ ClosedContextClr2Java::ClosedContextClr2Java(JNIEnv *env, jobject jobjectClosedContext) {
+ ManagedLog::LOGGER->LogStart("ClosedContextClr2Java::ClosedContextClr2Java");
+
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectClosedContext = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectClosedContext));
+ jclass jclassClosedContext = env->GetObjectClass (_jobjectClosedContext);
+
+ jfieldID jidContextId = env->GetFieldID(jclassClosedContext, "contextId", "Ljava/lang/String;");
+ jfieldID jidEvaluatorId = env->GetFieldID(jclassClosedContext, "evaluatorId", "Ljava/lang/String;");
+
+ _jstringContextId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectClosedContext, jidContextId)));
+ _jstringEvaluatorId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectClosedContext, jidEvaluatorId)));
+
+ ManagedLog::LOGGER->LogStop("ClosedContextClr2Java::ClosedContextClr2Java");
+ }
+
+ IActiveContextClr2Java^ ClosedContextClr2Java::GetParentContext() {
+ ManagedLog::LOGGER->LogStart("ClosedContextClr2Java::GetParentContext");
+
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassClosedContext = env->GetObjectClass(_jobjectClosedContext);
+ jfieldID jidParentContext = env->GetFieldID(jclassClosedContext, "parentContext", "Lorg/apache/reef/javabridge/ActiveContextBridge;");
+ jobject jobjectParentContext = env->GetObjectField(_jobjectClosedContext, jidParentContext);
+ ManagedLog::LOGGER->LogStop("ClosedContextClr2Java::GetParentContext");
+
+ return gcnew ActiveContextClr2Java(env, jobjectParentContext);
+ }
+
+ String^ ClosedContextClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("ClosedContextClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringContextId);
+ }
+
+ String^ ClosedContextClr2Java::GetEvaluatorId() {
+ ManagedLog::LOGGER->Log("ClosedContextClr2Java::GetEvaluatorId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringEvaluatorId);
+ }
+
+ IEvaluatorDescriptor^ ClosedContextClr2Java::GetEvaluatorDescriptor() {
+ ManagedLog::LOGGER->LogStart("ClosedContextClr2Java::GetEvaluatorDescriptor");
+ return CommonUtilities::RetrieveEvaluatorDescriptor(_jobjectClosedContext, _jvm);
+ }
+
+ void ClosedContextClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("ClosedContextClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectClosedContext);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/Clr2JavaImpl.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/Clr2JavaImpl.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/Clr2JavaImpl.cpp
new file mode 100644
index 0000000..ebd1aa4
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/Clr2JavaImpl.cpp
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft
+{
+ namespace Reef
+ {
+ namespace Interop
+ {
+ Clr2JavaImpl::Clr2JavaImpl (JNIEnv* env, jobject jobjectEManager, jobject jobjectDriverManager)
+ {
+ _env = env;
+ _jobjectEManager = jobjectEManager;
+ _jclassEManager = env->GetObjectClass (_jobjectEManager);
+ _jmidSubmit = env->GetMethodID(_jclassEManager, "submit", "([B)V");
+ _jobjectDriverManager = jobjectDriverManager;
+ _jclassDriverManager = env->GetObjectClass (_jobjectDriverManager);
+
+ }
+
+ void Clr2JavaImpl::AllocatedEvaluatorSubmitContextAndTask(String^ contextConfigStr, String^ taskConfigStr)
+ {
+ Console::WriteLine("AllocatedEvaluatorSubmitContextAndTask not implemented for Clr2JavaImpl");
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/Clr2JavaImpl.h
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/Clr2JavaImpl.h b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/Clr2JavaImpl.h
new file mode 100644
index 0000000..b907c2a
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/Clr2JavaImpl.h
@@ -0,0 +1,220 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropUtil.h"
+#include "org_apache_reef_javabridge_NativeInterop.h"
+#include "JavaClrBridge.h"
+#include "InteropAssemblies.h"
+#using "clrhandler.dll"
+#using "Microsoft.Reef.Driver.dll"
+
+using namespace System;
+using namespace System::IO;
+using namespace System::Collections::Generic;
+using namespace System::Runtime::InteropServices;
+using namespace System::Reflection;
+using namespace Microsoft::Reef::Driver::Bridge;
+using namespace Microsoft::Reef::Driver::Evaluator;
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ public ref class CommonUtilities {
+ public:
+ static IEvaluatorDescriptor^ RetrieveEvaluatorDescriptor(jobject object, JavaVM* jvm);
+ };
+
+ public ref class AllocatedEvaluatorClr2Java : public IAllocatedEvaluaotrClr2Java {
+ jobject _jobjectAllocatedEvaluator;
+ JavaVM* _jvm;
+ jstring _jstringId;
+ jstring _jstringNameServerInfo;
+ public:
+ AllocatedEvaluatorClr2Java(JNIEnv *env, jobject jallocatedEvaluator);
+ virtual void SubmitContextAndTask(String^ contextConfigStr, String^ taskConfigStr);
+ virtual void SubmitContext(String^ contextConfigStr);
+ virtual void SubmitContextAndService(String^ contextConfigStr, String^ serviceConfigStr);
+ virtual void SubmitContextAndServiceAndTask(String^ contextConfigStr, String^ serviceConfigStr, String^ taskConfigStr);
+ virtual void OnError(String^ message);
+ virtual void Close();
+ virtual String^ GetId();
+ virtual String^ GetNameServerInfo();
+ virtual IEvaluatorDescriptor^ GetEvaluatorDescriptor();
+ };
+
+ public ref class ActiveContextClr2Java : public IActiveContextClr2Java {
+ jobject _jobjectActiveContext;
+ jstring _jstringId;
+ jstring _jstringEvaluatorId;
+ JavaVM* _jvm;
+ public:
+ ActiveContextClr2Java(JNIEnv *env, jobject jallocatedEvaluator);
+ virtual void SubmitTask(String^ taskConfigStr);
+ virtual void Close();
+ virtual void OnError(String^ message);
+ virtual String^ GetId();
+ virtual String^ GetEvaluatorId();
+ virtual IEvaluatorDescriptor^ GetEvaluatorDescriptor();
+ };
+
+ public ref class EvaluatorRequestorClr2Java : public IEvaluatorRequestorClr2Java {
+ jobject _jobjectEvaluatorRequestor;
+ JavaVM* _jvm;
+ public:
+ EvaluatorRequestorClr2Java(JNIEnv *env, jobject jevaluatorRequestor);
+ virtual void OnError(String^ message);
+ virtual void Submit(IEvaluatorRequest^ request);
+ };
+
+ public ref class TaskMessageClr2Java : public ITaskMessageClr2Java {
+ jobject _jobjectTaskMessage;
+ JavaVM* _jvm;
+ jstring _jstringId;
+ public:
+ TaskMessageClr2Java(JNIEnv *env, jobject jtaskMessage);
+ virtual void OnError(String^ message);
+ virtual String^ GetId();
+ };
+
+ public ref class FailedTaskClr2Java : public IFailedTaskClr2Java {
+ jobject _jobjectFailedTask;
+ JavaVM* _jvm;
+ public:
+ FailedTaskClr2Java(JNIEnv *env, jobject jfailedTask);
+ virtual void OnError(String^ message);
+ virtual IActiveContextClr2Java^ GetActiveContext();
+ virtual String^ GetString();
+ };
+
+ public ref class RunningTaskClr2Java : public IRunningTaskClr2Java {
+ jobject _jobjectRunningTask;
+ JavaVM* _jvm;
+ jstring _jstringId;
+ public:
+ RunningTaskClr2Java(JNIEnv *env, jobject jrunningTask);
+ virtual void OnError(String^ message);
+ virtual IActiveContextClr2Java^ GetActiveContext();
+ virtual String^ GetId();
+ virtual void Send(array<byte>^ message);
+ };
+
+ public ref class FailedEvaluatorClr2Java : public IFailedEvaluatorClr2Java {
+ jobject _jobjectFailedEvaluator;
+ JavaVM* _jvm;
+ jstring _jstringId;
+ public:
+ FailedEvaluatorClr2Java(JNIEnv *env, jobject jfailedEvaluator);
+ virtual void OnError(String^ message);
+ virtual IEvaluatorRequestorClr2Java^ GetEvaluatorRequestor();
+ virtual String^ GetId();
+ };
+
+ public ref class HttpServerClr2Java : public IHttpServerBridgeClr2Java {
+ jobject _jhttpServerEventBridge;
+ JavaVM* _jvm;
+ public:
+ HttpServerClr2Java(JNIEnv *env, jobject jhttpServerEventBridge);
+ virtual void OnError(String^ message);
+ virtual String^ GetQueryString();
+ virtual void SetUriSpecification(String^ uriSpecification);
+ virtual void SetQueryResult(String^ queryResult);
+ virtual array<byte>^ GetQueryRequestData();
+ virtual void SetQueryResponseData(array<byte>^ responseData);
+ };
+
+ public ref class CompletedTaskClr2Java : public ICompletedTaskClr2Java {
+ jobject _jobjectCompletedTask;
+ JavaVM* _jvm;
+ jstring _jstringId;
+ public:
+ CompletedTaskClr2Java(JNIEnv *env, jobject jcompletedTask);
+ virtual void OnError(String^ message);
+ virtual IActiveContextClr2Java^ GetActiveContext();
+ virtual String^ GetId();
+ };
+
+ public ref class SuspendedTaskClr2Java : public ISuspendedTaskClr2Java {
+ jobject _jobjectSuspendedTask;
+ JavaVM* _jvm;
+ jstring _jstringId;
+ public:
+ SuspendedTaskClr2Java(JNIEnv *env, jobject jobjectSuspendedTask);
+ virtual void OnError(String^ message);
+ virtual IActiveContextClr2Java^ GetActiveContext();
+ virtual String^ GetId();
+ virtual array<byte>^ Get();
+ };
+
+ public ref class CompletedEvaluatorClr2Java : public ICompletedEvaluatorClr2Java {
+ jobject _jobjectCompletedEvaluator;
+ JavaVM* _jvm;
+ jstring _jstringId;
+ public:
+ CompletedEvaluatorClr2Java(JNIEnv *env, jobject jobjectCompletedEvaluator);
+ virtual void OnError(String^ message);
+ virtual String^ GetId();
+ };
+
+ public ref class ClosedContextClr2Java : public IClosedContextClr2Java {
+ jobject _jobjectClosedContext;
+ JavaVM* _jvm;
+ jstring _jstringContextId;
+ jstring _jstringEvaluatorId;
+ public:
+ ClosedContextClr2Java(JNIEnv *env, jobject jobjectClosedContext);
+ virtual void OnError(String^ message);
+ virtual String^ GetId();
+ virtual String^ GetEvaluatorId();
+ virtual IEvaluatorDescriptor^ GetEvaluatorDescriptor();
+ virtual IActiveContextClr2Java^ GetParentContext();
+ };
+
+ public ref class FailedContextClr2Java : public IFailedContextClr2Java {
+ jobject _jobjectFailedContext;
+ JavaVM* _jvm;
+ jstring _jstringContextId;
+ jstring _jstringEvaluatorId;
+ jstring _jstringParentContextId;
+ public:
+ FailedContextClr2Java(JNIEnv *env, jobject jobjectFailedContext);
+ virtual void OnError(String^ message);
+ virtual String^ GetId();
+ virtual String^ GetEvaluatorId();
+ virtual String^ GetParentId();
+ virtual IEvaluatorDescriptor^ GetEvaluatorDescriptor();
+ virtual IActiveContextClr2Java^ GetParentContext();
+ };
+
+ public ref class ContextMessageClr2Java : public IContextMessageClr2Java {
+ jobject _jobjectContextMessage;
+ JavaVM* _jvm;
+ jbyteArray _jarrayMessage;
+ jstring _jstringId;
+ jstring _jstringSourceId;
+ public:
+ ContextMessageClr2Java(JNIEnv *env, jobject jobjectContextMessage);
+ virtual void OnError(String^ message);
+ virtual array<byte>^ Get();
+ virtual String^ GetId();
+ virtual String^ GetMessageSourceId();
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CommonUtilities.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CommonUtilities.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CommonUtilities.cpp
new file mode 100644
index 0000000..c9b6cf1
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CommonUtilities.cpp
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>CommonUtilities");
+ };
+
+ IEvaluatorDescriptor^ CommonUtilities::RetrieveEvaluatorDescriptor(jobject object, JavaVM* jvm) {
+ ManagedLog::LOGGER->LogStart("CommonUtilities::GetEvaluatorDescriptor");
+ JNIEnv *env = RetrieveEnv(jvm);
+ jclass jclassActiveContext = env->GetObjectClass (object);
+ jmethodID jmidGetEvaluatorDescriptor = env->GetMethodID(jclassActiveContext, "getEvaluatorDescriptorSring", "()Ljava/lang/String;");
+
+ if (jmidGetEvaluatorDescriptor == NULL) {
+ ManagedLog::LOGGER->Log("jmidGetEvaluatorDescriptor is NULL");
+ return nullptr;
+ }
+ jstring jevaluatorDescriptorString = (jstring)env -> CallObjectMethod(
+ object,
+ jmidGetEvaluatorDescriptor);
+ String^ evaluatorDescriptorString = ManagedStringFromJavaString(env, jevaluatorDescriptorString);
+ ManagedLog::LOGGER->LogStop("InteropUtil::GetEvaluatorDescriptor");
+
+ return gcnew EvaluatorDescriptorImpl(evaluatorDescriptorString);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CompletedEvaluatorClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CompletedEvaluatorClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CompletedEvaluatorClr2Java.cpp
new file mode 100644
index 0000000..296670e
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CompletedEvaluatorClr2Java.cpp
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ CompletedEvaluatorClr2Java::CompletedEvaluatorClr2Java(JNIEnv *env, jobject jCompletedEvaluator) {
+ ManagedLog::LOGGER->LogStart("CompletedEvaluatorClr2Java::CompletedEvaluatorClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectCompletedEvaluator = reinterpret_cast<jobject>(env->NewGlobalRef(jCompletedEvaluator));
+
+ jclass jclassCompletedEvaluator = env->GetObjectClass (_jobjectCompletedEvaluator);
+ jfieldID jidEvaluatorId = env->GetFieldID(jclassCompletedEvaluator, "evaluatorId", "Ljava/lang/String;");
+ _jstringId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectCompletedEvaluator, jidEvaluatorId)));
+ ManagedLog::LOGGER->LogStop("CompletedEvaluatorClr2Java::CompletedEvaluatorClr2Java");
+ }
+
+ void CompletedEvaluatorClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("CompletedEvaluatorClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectCompletedEvaluator);
+ }
+
+ String^ CompletedEvaluatorClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("CompletedEvaluatorClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringId);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CompletedTaskClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CompletedTaskClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CompletedTaskClr2Java.cpp
new file mode 100644
index 0000000..631b2ea
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/CompletedTaskClr2Java.cpp
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ CompletedTaskClr2Java::CompletedTaskClr2Java(JNIEnv *env, jobject jobjectCompletedTask) {
+ ManagedLog::LOGGER->LogStart("CompletedTaskClr2Java::CompletedTaskClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectCompletedTask = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectCompletedTask));
+
+ jclass jclassCompletedTask = env->GetObjectClass (_jobjectCompletedTask);
+ jfieldID jidTaskId = env->GetFieldID(jclassCompletedTask, "taskId", "Ljava/lang/String;");
+ _jstringId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectCompletedTask, jidTaskId)));
+ ManagedLog::LOGGER->LogStop("CompletedTaskClr2Java::CompletedTaskClr2Java");
+ }
+
+ void CompletedTaskClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("CompletedTaskClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectCompletedTask);
+ }
+
+ IActiveContextClr2Java^ CompletedTaskClr2Java::GetActiveContext() {
+ ManagedLog::LOGGER->LogStart("CompletedTaskClr2Java::GetActiveContext");
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassCompletedTask = env->GetObjectClass (_jobjectCompletedTask);
+ jfieldID jidActiveContext = env->GetFieldID(jclassCompletedTask, "jactiveContext", "Lorg/apache/reef/javabridge/ActiveContextBridge;");
+ jobject jobjectActiveContext = env->GetObjectField(_jobjectCompletedTask, jidActiveContext);
+ ManagedLog::LOGGER->LogStop("CompletedTaskClr2Java::GetActiveContext");
+ return gcnew ActiveContextClr2Java(env, jobjectActiveContext);
+ }
+
+ String^ CompletedTaskClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("CompletedTaskClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringId);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ContextMessageClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ContextMessageClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ContextMessageClr2Java.cpp
new file mode 100644
index 0000000..6f0834a
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/ContextMessageClr2Java.cpp
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+ ContextMessageClr2Java::ContextMessageClr2Java(JNIEnv *env, jobject jobjectContextMessage) {
+ ManagedLog::LOGGER->LogStart("ContextMessageClr2Java::ContextMessageClr2Java");
+
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectContextMessage = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectContextMessage));
+ jclass jclassContextMessage = env->GetObjectClass (_jobjectContextMessage);
+
+ jfieldID jidId = env->GetFieldID(jclassContextMessage, "contextMessageId", "Ljava/lang/String;");
+ jfieldID jidSourceId = env->GetFieldID(jclassContextMessage, "messageSourceId", "Ljava/lang/String;");
+ jfieldID jidMessage = env->GetFieldID(jclassContextMessage, "message", "()[B");
+
+ _jstringId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectContextMessage, jidId)));
+ _jstringSourceId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectContextMessage, jidSourceId)));
+ _jarrayMessage = reinterpret_cast<jbyteArray>(env->NewGlobalRef(env->GetObjectField(_jobjectContextMessage, jidMessage)));
+
+ ManagedLog::LOGGER->LogStop("ContextMessageClr2Java::ContextMessageClr2Java");
+ }
+
+ String^ ContextMessageClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("ContextMessageClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringId);
+ }
+
+ String^ ContextMessageClr2Java::GetMessageSourceId() {
+ ManagedLog::LOGGER->Log("ContextMessageClr2Java::GetMessageSourceId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringSourceId);
+ }
+
+ array<byte>^ ContextMessageClr2Java::Get() {
+ ManagedLog::LOGGER->Log("ContextMessageClr2Java::Get");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedByteArrayFromJavaByteArray(env, _jarrayMessage);
+ }
+
+ void ContextMessageClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("ContextMessageClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectContextMessage);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/EvaluatorRequestorClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/EvaluatorRequestorClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/EvaluatorRequestorClr2Java.cpp
new file mode 100644
index 0000000..eff8e3e
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/EvaluatorRequestorClr2Java.cpp
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ EvaluatorRequestorClr2Java::EvaluatorRequestorClr2Java(JNIEnv *env, jobject jevaluatorRequestor) {
+ ManagedLog::LOGGER->LogStart("EvaluatorRequestorClr2Java::EvaluatorRequestorClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectEvaluatorRequestor = reinterpret_cast<jobject>(env->NewGlobalRef(jevaluatorRequestor));
+ ManagedLog::LOGGER->LogStop("EvaluatorRequestorClr2Java::EvaluatorRequestorClr2Java");
+ }
+
+ void EvaluatorRequestorClr2Java::Submit(IEvaluatorRequest^ request) {
+ ManagedLog::LOGGER->LogStart("EvaluatorRequestorClr2Java::Submit");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclassEvaluatorRequestor = env->GetObjectClass (_jobjectEvaluatorRequestor);
+ jmethodID jmidSubmit = env->GetMethodID(jclassEvaluatorRequestor, "submit", "(IIILjava/lang/String;)V");
+
+ if (jmidSubmit == NULL) {
+ fprintf(stdout, " jmidSubmit is NULL\n");
+ fflush (stdout);
+ return;
+ }
+ env -> CallObjectMethod(
+ _jobjectEvaluatorRequestor,
+ jmidSubmit,
+ request -> Number,
+ request -> MemoryMegaBytes,
+ request -> VirtualCore,
+ JavaStringFromManagedString(env, request -> Rack));
+ ManagedLog::LOGGER->LogStop("EvaluatorRequestorClr2Java::Submit");
+ }
+
+ void EvaluatorRequestorClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("EvaluatorRequestorClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectEvaluatorRequestor);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedContextClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedContextClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedContextClr2Java.cpp
new file mode 100644
index 0000000..9a6e6d8
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedContextClr2Java.cpp
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+ FailedContextClr2Java::FailedContextClr2Java(JNIEnv *env, jobject jobjectFailedContext) {
+ ManagedLog::LOGGER->LogStart("FailedContextClr2Java::FailedContextClr2Java");
+
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectFailedContext = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectFailedContext));
+ jclass jclassFailedContext = env->GetObjectClass (_jobjectFailedContext);
+
+ jfieldID jidContextId = env->GetFieldID(jclassFailedContext, "contextId", "Ljava/lang/String;");
+ jfieldID jidEvaluatorId = env->GetFieldID(jclassFailedContext, "evaluatorId", "Ljava/lang/String;");
+ jfieldID jidParentId = env->GetFieldID(jclassFailedContext, "parentContextId", "Ljava/lang/String;");
+
+ _jstringContextId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectFailedContext, jidContextId)));
+ _jstringEvaluatorId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectFailedContext, jidEvaluatorId)));
+ _jstringParentContextId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectFailedContext, jidParentId)));
+
+ ManagedLog::LOGGER->LogStop("FailedContextClr2Java::FailedContextClr2Java");
+ }
+
+ IActiveContextClr2Java^ FailedContextClr2Java::GetParentContext() {
+ ManagedLog::LOGGER->LogStart("FailedContextClr2Java::GetParentContext");
+
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassFailedContext = env->GetObjectClass(_jobjectFailedContext);
+ jfieldID jidParentContext = env->GetFieldID(jclassFailedContext, "parentContext", "Lorg/apache/reef/javabridge/ActiveContextBridge;");
+ jobject jobjectParentContext = env->GetObjectField(_jobjectFailedContext, jidParentContext);
+ ManagedLog::LOGGER->LogStop("FailedContextClr2Java::GetParentContext");
+
+ return gcnew ActiveContextClr2Java(env, jobjectParentContext);
+ }
+
+ String^ FailedContextClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("FailedContextClr2Java::GetId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringContextId);
+ }
+
+ String^ FailedContextClr2Java::GetEvaluatorId() {
+ ManagedLog::LOGGER->Log("FailedContextClr2Java::GetEvaluatorId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringEvaluatorId);
+ }
+
+ String^ FailedContextClr2Java::GetParentId() {
+ ManagedLog::LOGGER->Log("FailedContextClr2Java::GetParentId");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringParentContextId);
+ }
+
+ IEvaluatorDescriptor^ FailedContextClr2Java::GetEvaluatorDescriptor() {
+ ManagedLog::LOGGER->LogStart("FailedContextClr2Java::GetEvaluatorDescriptor");
+ return CommonUtilities::RetrieveEvaluatorDescriptor(_jobjectFailedContext, _jvm);
+ }
+
+ void FailedContextClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("FailedContextClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectFailedContext);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedEvaluatorClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedEvaluatorClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedEvaluatorClr2Java.cpp
new file mode 100644
index 0000000..d79ecce
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedEvaluatorClr2Java.cpp
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+using namespace JavaClrBridge;
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ FailedEvaluatorClr2Java::FailedEvaluatorClr2Java(JNIEnv *env, jobject jobjectFailedEvaluator) {
+ ManagedLog::LOGGER->LogStart("FailedEvaluatorClr2Java::FailedEvaluatorClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectFailedEvaluator = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectFailedEvaluator));
+
+ jclass jclassFailedEvaluator = env->GetObjectClass(_jobjectFailedEvaluator);
+ jfieldID jidEvaluatorId = env->GetFieldID(jclassFailedEvaluator, "evaluatorId", "Ljava/lang/String;");
+ _jstringId = reinterpret_cast<jstring>(env->NewGlobalRef(env->GetObjectField(_jobjectFailedEvaluator, jidEvaluatorId)));
+ ManagedLog::LOGGER->LogStop("FailedEvaluatorClr2Java::FailedEvaluatorClr2Java");
+ }
+
+ IEvaluatorRequestorClr2Java^ FailedEvaluatorClr2Java::GetEvaluatorRequestor() {
+ ManagedLog::LOGGER->LogStart("FailedEvaluatorClr2Java::GetEvaluatorRequestor");
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassFailedEvaluator = env->GetObjectClass(_jobjectFailedEvaluator);
+ jfieldID jidEvaluatorRequestor = env->GetFieldID(jclassFailedEvaluator, "evaluatorRequestorBridge", "Lorg/apache/reef/javabridge/EvaluatorRequestorBridge;");
+ jobject jobjectEvaluatorRequestor = env->GetObjectField(_jobjectFailedEvaluator, jidEvaluatorRequestor);
+ ManagedLog::LOGGER->LogStop("FailedEvaluatorClr2Java::GetEvaluatorRequestor");
+ return gcnew EvaluatorRequestorClr2Java(env, jobjectEvaluatorRequestor);
+ }
+
+ String^ FailedEvaluatorClr2Java::GetId() {
+ ManagedLog::LOGGER->Log("FailedEvaluatorClr2Java::GetId");
+
+ JNIEnv *env = RetrieveEnv(_jvm);
+ return ManagedStringFromJavaString(env, _jstringId);
+ }
+
+ void FailedEvaluatorClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("FailedEvaluatorClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectFailedEvaluator);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedTaskClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedTaskClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedTaskClr2Java.cpp
new file mode 100644
index 0000000..32414c6
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/FailedTaskClr2Java.cpp
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ FailedTaskClr2Java::FailedTaskClr2Java(JNIEnv *env, jobject jobjectFailedTask) {
+ ManagedLog::LOGGER->LogStart("FailedTaskClr2Java::AllocatedEvaluatorClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jobjectFailedTask = reinterpret_cast<jobject>(env->NewGlobalRef(jobjectFailedTask));
+ ManagedLog::LOGGER->LogStop("FailedTaskClr2Java::AllocatedEvaluatorClr2Java");
+ }
+
+ IActiveContextClr2Java^ FailedTaskClr2Java::GetActiveContext() {
+ ManagedLog::LOGGER->LogStart("FailedTaskClr2Java::GetActiveContext");
+
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassFailedTask = env->GetObjectClass(_jobjectFailedTask);
+ jfieldID jidActiveContext = env->GetFieldID(jclassFailedTask, "jactiveContext", "Lorg/apache/reef/javabridge/ActiveContextBridge;");
+ jobject jobjectActiveContext = env->GetObjectField(_jobjectFailedTask, jidActiveContext);
+
+ ManagedLog::LOGGER->LogStop("FailedTaskClr2Java::GetActiveContext");
+ return gcnew ActiveContextClr2Java(env, jobjectActiveContext);
+ }
+
+ String^ FailedTaskClr2Java::GetString() {
+ ManagedLog::LOGGER->LogStart("FailedTaskClr2Java::GetString");
+ JNIEnv *env = RetrieveEnv(_jvm);
+
+ jclass jclassFailedTask = env->GetObjectClass (_jobjectFailedTask);
+ jmethodID jmidGetFailedTaskString = env->GetMethodID(jclassFailedTask, "getFailedTaskString", "()Ljava/lang/String;");
+
+ if (jmidGetFailedTaskString == NULL) {
+ ManagedLog::LOGGER->LogStart("jmidGetFailedTaskString is NULL");
+ return nullptr;
+ }
+ jstring jFailedTaskString = (jstring)env -> CallObjectMethod(
+ _jobjectFailedTask,
+ jmidGetFailedTaskString);
+ ManagedLog::LOGGER->LogStop("FailedTaskClr2Java::GetString");
+ return ManagedStringFromJavaString(env, jFailedTaskString);
+ }
+
+ void FailedTaskClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("FailedTaskClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jobjectFailedTask);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/HttpServerClr2Java.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/HttpServerClr2Java.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/HttpServerClr2Java.cpp
new file mode 100644
index 0000000..90a930f
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/HttpServerClr2Java.cpp
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "Clr2JavaImpl.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Driver {
+ namespace Bridge {
+ ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>");
+ };
+
+ HttpServerClr2Java::HttpServerClr2Java(JNIEnv *env, jobject jhttpServerEventBridge) {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::HttpServerClr2Java");
+ pin_ptr<JavaVM*> pJavaVm = &_jvm;
+ if (env->GetJavaVM(pJavaVm) != 0) {
+ ManagedLog::LOGGER->LogError("Failed to get JavaVM", nullptr);
+ }
+ _jhttpServerEventBridge = reinterpret_cast<jobject>(env->NewGlobalRef(jhttpServerEventBridge));
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::HttpServerClr2Java");
+ }
+
+ String^ HttpServerClr2Java::GetQueryString() {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::GetQueryString");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidgetQueryString = env->GetMethodID(jclasshttpServerEventBridge, "getQueryString", "()Ljava/lang/String;");
+ if (jmidgetQueryString == NULL) {
+ fprintf(stdout, " jmidgetQueryString is NULL\n");
+ fflush (stdout);
+ return nullptr;
+ }
+ jstring jQueryString = (jstring) env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidgetQueryString);
+
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::GetQueryString");
+ return ManagedStringFromJavaString(env, jQueryString);
+ }
+
+ array<byte>^ HttpServerClr2Java::GetQueryRequestData() {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::GetQueryRequestData");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidgetQueryBytes = env->GetMethodID(jclasshttpServerEventBridge, "getQueryRequestData", "()[B");
+
+ if (jmidgetQueryBytes == NULL) {
+ ManagedLog::LOGGER->Log("jmidgetQueryBytes is NULL");
+ return nullptr;
+ }
+ jbyteArray jQueryBytes = (jbyteArray) env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidgetQueryBytes);
+
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::GetQueryRequestData");
+ return ManagedByteArrayFromJavaByteArray(env, jQueryBytes);
+ }
+
+ void HttpServerClr2Java::SetQueryResult(String^ queryResult) {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::SetQueryResult");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidsetQueryResult = env->GetMethodID(jclasshttpServerEventBridge, "setQueryResult", "(Ljava/lang/String;)V");
+
+ if (jmidsetQueryResult == NULL) {
+ ManagedLog::LOGGER->Log("jmidsetQueryResult is NULL");
+ return;
+ }
+ env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidsetQueryResult,
+ JavaStringFromManagedString(env, queryResult));
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::SetQueryResult");
+ }
+
+ void HttpServerClr2Java::SetQueryResponseData(array<byte>^ queryResponseData) {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::SetQueryResponseData");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidsetQueryResult = env->GetMethodID(jclasshttpServerEventBridge, "setQueryResponseData", "([B)V");
+
+ if (jmidsetQueryResult == NULL) {
+ ManagedLog::LOGGER->Log("jmidsetQueryResult is NULL");
+ return;
+ }
+ env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidsetQueryResult,
+ JavaByteArrayFromManagedByteArray(env, queryResponseData));
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::SetQueryResponseData");
+ }
+
+ void HttpServerClr2Java::SetUriSpecification(String^ uriSpecification) {
+ ManagedLog::LOGGER->LogStart("HttpServerClr2Java::SetUriSpecification");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ jclass jclasshttpServerEventBridge = env->GetObjectClass (_jhttpServerEventBridge);
+ jmethodID jmidsetUriSpecification = env->GetMethodID(jclasshttpServerEventBridge, "setUriSpecification", "(Ljava/lang/String;)V");
+
+ if (jmidsetUriSpecification == NULL) {
+ ManagedLog::LOGGER->Log("jmidsetUriSpecification is NULL");
+ return;
+ }
+ env->CallObjectMethod(
+ _jhttpServerEventBridge,
+ jmidsetUriSpecification,
+ JavaStringFromManagedString(env, uriSpecification));
+ ManagedLog::LOGGER->LogStop("HttpServerClr2Java::SetUriSpecification");
+ }
+
+ void HttpServerClr2Java::OnError(String^ message) {
+ ManagedLog::LOGGER->Log("HttpServerClr2Java::OnError");
+ JNIEnv *env = RetrieveEnv(_jvm);
+ HandleClr2JavaError(env, message, _jhttpServerEventBridge);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropAssemblies.h
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropAssemblies.h b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropAssemblies.h
new file mode 100644
index 0000000..2e80d71
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropAssemblies.h
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#pragma once
+#define _USING_V110_SDK71_
+
+#pragma warning( push )
+#pragma warning( disable : 4793 )
+#include <jni.h>
+#pragma warning( pop )
+#include "mscoree.h"
+#include "vcclr.h"
+
+using namespace System;
+using namespace System::Reflection;
+using namespace System::Collections::Generic;
+
+public ref class AssemblyUtil {
+ public :
+ static int _asmCount = 0;
+ static Dictionary<String^, System::Reflection::Assembly^>^ asms2 = gcnew Dictionary<String^, Assembly^>();
+ static void Add(Assembly^ myasm);
+ static Assembly^ FindAsm (String^ myasm);
+ static Assembly^ MyResolveEventHandler(Object^ sender, ResolveEventArgs^ args);
+};
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.cpp
new file mode 100644
index 0000000..418bd55
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.cpp
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropLogger.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Interop {
+ /// currently not being used
+ InteropLogger::InteropLogger (JNIEnv* env, jobject jobjectInteropLogger) {
+ _env = env;
+ _jobjectInteropLogger = jobjectInteropLogger;
+ _jclassInteropLogger = env->GetObjectClass(jobjectInteropLogger);
+ wchar_t formatBuf[1024];
+ if (NULL == _jclassInteropLogger) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jclassInteropLogger %p\n", _jclassInteropLogger);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+ _jmidLog = env->GetMethodID(_jclassInteropLogger, "Log", "(ILjava/lang/String;)V");
+ if (NULL == _jmidLog) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidLog %p\n", _jmidLog);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+ }
+ void InteropLogger::Log(TraceLevel traceLevel, String^ message) {
+ pin_ptr<const wchar_t> wch = PtrToStringChars(message);
+ jstring msg = _env->NewString((const jchar*)wch, message->Length);
+ _env->CallObjectMethod(_jobjectInteropLogger, _jmidLog, (int)traceLevel, msg);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.h
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.h b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.h
new file mode 100644
index 0000000..c2a2e80
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropLogger.h
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropUtil.h"
+#include "org_apache_reef_javabridge_NativeInterop.h"
+#include "JavaClrBridge.h"
+#include "InteropAssemblies.h"
+#using "clrhandler.dll"
+
+using namespace System;
+using namespace System::IO;
+using namespace System::Collections::Generic;
+using namespace System::Runtime::InteropServices;
+using namespace System::Reflection;
+using namespace Microsoft::Reef::Interop;
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Interop {
+ public ref class InteropLogger : public ILogger {
+ jobject _jobjectInteropLogger;
+ jclass _jclassInteropLogger;
+ jmethodID _jmidLog;
+ JNIEnv* _env;
+
+ public:
+ InteropLogger (JNIEnv* env, jobject jobjectInteropLogger);
+ virtual void Log(TraceLevel traceLevel, String^ message );
+ };
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.cpp
new file mode 100644
index 0000000..7a0d35a
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.cpp
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropReturnInfo.h"
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Interop {
+ // currently not being used
+ InteropReturnInfo::InteropReturnInfo (
+ JNIEnv* env,
+ jobject jobjectInteropReturnInfo,
+ ILogger^ logger
+ ) {
+ _env = env;
+ _jobjectInteropReturnInfo = jobjectInteropReturnInfo;
+ jclass thisClass = env->GetObjectClass(jobjectInteropReturnInfo);
+ wchar_t formatBuf[1024];
+
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"zzzzzzz this should be printed by java jmid 00 %p\n", thisClass);
+ logger->Log(TraceLevel::Error, gcnew String(formatBuf));
+ _jmidAddExceptionString = env->GetMethodID(thisClass, "addExceptionString", "(Ljava/lang/String;)V");
+ if (NULL == _jmidAddExceptionString) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidAddExceptionString %p\n", _jmidAddExceptionString);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+ _jmidHasExceptions = env->GetMethodID(thisClass, "hasExceptions", "()Z");
+ if (NULL == _jmidHasExceptions) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidHasExceptions %p\n", _jmidHasExceptions);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+ _jmidsetReturnCode = env->GetMethodID(thisClass, "setReturnCode", "(I)V");
+ if (NULL == _jmidsetReturnCode) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidsetReturnCode %p\n", _jmidsetReturnCode);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+ _jmidgetReturnCode = env->GetMethodID(thisClass, "getReturnCode", "()I");
+ if (NULL == _jmidgetReturnCode) {
+ swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidgetReturnCode %p\n", _jmidgetReturnCode);
+ fwprintf (stdout, formatBuf);
+ fflush (stdout);
+ }
+
+
+ }
+
+ void InteropReturnInfo::AddExceptionString(String^ exceptionString) {
+ HasExceptions();
+ pin_ptr<const wchar_t> wch = PtrToStringChars(exceptionString);
+ jstring ret = _env->NewString((const jchar*)wch, exceptionString->Length);
+ _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidAddExceptionString, ret);
+ HasExceptions();
+ }
+
+ Boolean InteropReturnInfo::HasExceptions() {
+ jobject obj = _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidHasExceptions);
+ return ((int)obj) != 0;
+ }
+ void InteropReturnInfo::SetReturnCode(int rc) {
+ _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidsetReturnCode, rc);
+ GetReturnCode();
+ }
+ int InteropReturnInfo::GetReturnCode() {
+ jobject obj = _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidgetReturnCode);
+ return (int)obj;
+ }
+
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.h
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.h b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.h
new file mode 100644
index 0000000..1278516
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropReturnInfo.h
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropUtil.h"
+#include "org_apache_reef_javabridge_NativeInterop.h"
+#include "JavaClrBridge.h"
+#include "InteropAssemblies.h"
+#using "clrhandler.dll"
+
+using namespace System;
+using namespace System::IO;
+using namespace System::Collections::Generic;
+using namespace System::Runtime::InteropServices;
+using namespace System::Reflection;
+using namespace Microsoft::Reef::Interop;
+
+namespace Microsoft {
+ namespace Reef {
+ namespace Interop {
+ public ref class InteropReturnInfo : public IInteropReturnInfo {
+ JNIEnv* _env;
+ jobject _jobjectInteropReturnInfo;
+
+ jmethodID _jmidAddExceptionString;
+ jmethodID _jmidHasExceptions;
+ jmethodID _jmidsetReturnCode;
+ jmethodID _jmidgetReturnCode;
+
+ public:
+ InteropReturnInfo (
+ JNIEnv* env,
+ jobject jobjectInteropReturnInfo,
+ ILogger^ logger
+ );
+ virtual void AddExceptionString(String^ exceptionString);
+ virtual Boolean HasExceptions();
+ virtual void SetReturnCode(int rc);
+ virtual int GetReturnCode();
+ };
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.cpp
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.cpp b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.cpp
new file mode 100644
index 0000000..be24f32
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.cpp
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "InteropUtil.h"
+#include "Clr2JavaImpl.h"
+
+using namespace System::Runtime::InteropServices;
+
+ref class ManagedLog {
+ internal:
+ static BridgeLogger^ LOGGER = BridgeLogger::GetLogger("<C++>InteropUtil");
+};
+
+const wchar_t* UnicodeCppStringFromJavaString (
+ JNIEnv *env,
+ jstring javaString) {
+ const wchar_t* cppString = NULL;
+ if (NULL != javaString) {
+ cppString = (const wchar_t* )env->GetStringChars( javaString, 0);
+ }
+ return cppString;
+}
+
+void ReleaseUnicodeCppString (
+ JNIEnv* env,
+ jstring javaString,
+ jchar* cppString) {
+ if (NULL != cppString) {
+ env->ReleaseStringChars(javaString, (jchar *)cppString);
+ }
+}
+
+String^ ManagedStringFromJavaString (
+ JNIEnv *env,
+ jstring javaString) {
+ if (javaString != NULL) {
+ int len = env->GetStringLength(javaString);
+ const wchar_t* wcsStr = UnicodeCppStringFromJavaString (env, javaString);
+ String^ managedStr = (NULL == wcsStr || 0 == len) ? nullptr : Marshal::PtrToStringUni((IntPtr)(unsigned short*)wcsStr, len);
+ ReleaseUnicodeCppString (env, javaString, (jchar*)wcsStr);
+ return managedStr;
+ }
+ return nullptr;
+}
+
+jstring JavaStringFromManagedString(
+ JNIEnv *env,
+ String^ managedString) {
+ pin_ptr<const wchar_t> wch = PtrToStringChars(managedString);
+ return env->NewString((const jchar*)wch, managedString->Length);
+}
+
+void HandleClr2JavaError(
+ JNIEnv *env,
+ String^ errorMessage,
+ jobject javaObject) {
+ ManagedLog::LOGGER->LogStart("InteropUtil::HandleClr2JavaError");
+
+ jclass javaClass = env->GetObjectClass (javaObject);
+ jmethodID jmidOnError = env->GetMethodID(javaClass, "onError", "(Ljava/lang/String;)V");
+
+ if (jmidOnError == NULL) {
+ ManagedLog::LOGGER->Log("jmidOnError is NULL");
+ return;
+ }
+ env -> CallObjectMethod(
+ javaObject,
+ jmidOnError,
+ JavaStringFromManagedString(env, errorMessage));
+ ManagedLog::LOGGER->LogStop("InteropUtil::HandleClr2JavaError");
+}
+
+array<byte>^ ManagedByteArrayFromJavaByteArray(
+ JNIEnv *env,
+ jbyteArray javaByteArray) {
+ if (javaByteArray != NULL) {
+ byte* bytes = (byte*)env->GetByteArrayElements (javaByteArray, FALSE);
+ int len = env->GetArrayLength(javaByteArray);
+ array<byte>^ managedByteArray = gcnew array<byte>(len);
+ //System::Array
+ for (int i = 0; i < len; i++) {
+ managedByteArray[i] = bytes[i];
+ }
+ return managedByteArray;
+ }
+ return nullptr;
+}
+
+jbyteArray JavaByteArrayFromManagedByteArray(
+ JNIEnv *env,
+ array<byte>^ managedByteArray) {
+ jbyteArray javaByteArray = env->NewByteArray(managedByteArray->Length);
+ pin_ptr<Byte> p = &managedByteArray[0];
+ env->SetByteArrayRegion(javaByteArray, 0, managedByteArray->Length, (jbyte*) p);
+ return javaByteArray;
+}
+
+jlongArray JavaLongArrayFromManagedLongArray(
+ JNIEnv *env,
+ array<unsigned long long>^ managedLongArray) {
+ jlongArray javaLongArray = env->NewLongArray(managedLongArray->Length);
+ pin_ptr<unsigned long long> p = &managedLongArray[0];
+ env->SetLongArrayRegion(javaLongArray, 0, managedLongArray->Length, (jlong*) p);
+ return javaLongArray;
+}
+
+JNIEnv* RetrieveEnv(JavaVM* jvm) {
+ JNIEnv *env;
+ if (jvm->AttachCurrentThread((void **) &env, NULL) != 0) {
+ ManagedLog::LOGGER->Log("cannot attach jni env to current jvm thread.");
+ throw;
+ }
+ return env;
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.h
----------------------------------------------------------------------
diff --git a/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.h b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.h
new file mode 100644
index 0000000..2d95bcc
--- /dev/null
+++ b/lang/java/reef-bridge-project/reef-bridge-clr/src/main/Cpp/CppBridge/JavaClrBridge/InteropUtil.h
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#pragma once
+#define _USING_V110_SDK71_
+
+#pragma warning( push )
+#pragma warning( disable : 4793 )
+#include <jni.h>
+#pragma warning( pop )
+#include "mscoree.h"
+#include "vcclr.h"
+
+using namespace System;
+
+const wchar_t* UnicodeCppStringFromJavaString (
+ JNIEnv *env,
+ jstring javaString);
+
+void ReleaseUnicodeCppString (
+ JNIEnv* env,
+ jstring javaString,
+ jchar* cppString);
+
+String^ ManagedStringFromJavaString (
+ JNIEnv *env,
+ jstring javaString);
+
+jstring JavaStringFromManagedString(
+ JNIEnv *env,
+ String^ managedString);
+
+array<byte>^ ManagedByteArrayFromJavaByteArray(
+ JNIEnv *env,
+ jbyteArray javaByteArray);
+
+jbyteArray JavaByteArrayFromManagedByteArray(
+ JNIEnv *env,
+ array<byte>^ managedByteArray);
+
+jlongArray JavaLongArrayFromManagedLongArray(
+ JNIEnv *env,
+ array<unsigned long long>^ managedLongArray);
+
+JNIEnv* RetrieveEnv(JavaVM* jvm);
+
+void HandleClr2JavaError(
+ JNIEnv *env,
+ String^ errorMessage,
+ jobject javaObject);
\ No newline at end of file