Author: mturk Date: Wed Apr 22 17:35:13 2009 New Revision: 767595 URL: http://svn.apache.org/viewvc?rev=767595&view=rev Log: Add basic Native class
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java (with props) commons/sandbox/runtime/trunk/src/main/native/shared/native.c (with props) commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java (with props) Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DirectByteBuffer.java commons/sandbox/runtime/trunk/src/main/native/Makefile.in commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DirectByteBuffer.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DirectByteBuffer.java?rev=767595&r1=767594&r2=767595&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DirectByteBuffer.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DirectByteBuffer.java Wed Apr 22 17:35:13 2009 @@ -321,7 +321,9 @@ * <p> * <b>Warning:</b><br/> * Invoke this method only on ByteBuffers - * that were created by {...@code DirectByteBuffer.allocate} methods. + * that were created by {...@code DirectByteBuffer.allocate} methods + * and only if the Buffer was not allocated from the {...@code Pointer} + * object. * </p> * <p> * <b>Warning:</b><br/> Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java?rev=767595&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java Wed Apr 22 17:35:13 2009 @@ -0,0 +1,55 @@ +/* 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. + */ + +package org.apache.commons.runtime; + +/** + * Native library management. + * + * @since Runtime 1.0 + * + */ +public final class Native { + + private Native() + { + // No instance. + } + + private static boolean initialized = false; + private static native boolean init0() + throws Throwable; + + /** + * Initialize Apache Commons Runtime native library. + * <p> + * This method must be called after the {...@code native} library + * has been loaded into current VM address space and before any + * other classes are used. This method ensures that native part + * of the library properly initialize. + * </p> + * @return {...@code true} if the library was properly initialized. + * @throws {...@code Throwable} in case of error. + */ + public static boolean initialize() + throws Throwable + { + if (!initialized) { + initialized = init0(); + } + return initialized; + } +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=767595&r1=767594&r2=767595&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Wed Apr 22 17:35:13 2009 @@ -71,6 +71,7 @@ $(SRCDIR)/shared/error.$(OBJ) \ $(SRCDIR)/shared/fco.$(OBJ) \ $(SRCDIR)/shared/memory.$(OBJ) \ + $(SRCDIR)/shared/native.$(OBJ) \ $(SRCDIR)/shared/pointer.$(OBJ) \ $(SRCDIR)/shared/string.$(OBJ) \ $(SRCDIR)/shared/tables.$(OBJ) \ Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=767595&r1=767594&r2=767595&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Wed Apr 22 17:35:13 2009 @@ -65,6 +65,7 @@ $(SRCDIR)/shared/error.$(OBJ) \ $(SRCDIR)/shared/fco.$(OBJ) \ $(SRCDIR)/shared/memory.$(OBJ) \ + $(SRCDIR)/shared/native.$(OBJ) \ $(SRCDIR)/shared/pointer.$(OBJ) \ $(SRCDIR)/shared/string.$(OBJ) \ $(SRCDIR)/shared/tables.$(OBJ) \ Added: commons/sandbox/runtime/trunk/src/main/native/shared/native.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/native.c?rev=767595&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/native.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/shared/native.c Wed Apr 22 17:35:13 2009 @@ -0,0 +1,36 @@ +/* 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. + */ + +/* + * + * @author Mladen Turk + */ + +#include "acr.h" +#include "acr_private.h" +#include "acr_error.h" +#include "acr_clazz.h" +#include "acr_vm.h" + +ACR_JNI_EXPORT_DECLARE(jboolean, Native, init0)(ACR_JNISTDARGS) +{ + jboolean rv = JNI_FALSE; + + if (ACR_LoadRuntimeClasses(_E) == 0) + rv = JNI_TRUE; + + return rv; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/shared/native.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java?rev=767595&r1=767594&r2=767595&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java (original) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java Wed Apr 22 17:35:13 2009 @@ -31,6 +31,7 @@ { TestSuite suite = new TestSuite(); // Fundamentals + suite.addTest(TestNative.suite()); suite.addTest(TestProperties.suite()); suite.addTest(TestOS.suite()); suite.addTest(TestUUID.suite()); Added: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java?rev=767595&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java (added) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java Wed Apr 22 17:35:13 2009 @@ -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. + */ + +package org.apache.commons.runtime; + +import java.lang.System; +import junit.framework.*; + +/** + * Native Test. + * + */ +public class TestNative extends TestCase +{ + + public static Test suite() { + TestSuite suite = new TestSuite(TestNative.class); + return suite; + } + + protected void setUp() + throws Exception + { + System.loadLibrary("acr"); + } + + public void testNativeInit() + throws Throwable + { + boolean rv = Native.initialize(); + assertTrue("Not initialized", rv); + } + +} Propchange: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java ------------------------------------------------------------------------------ svn:eol-style = native