Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/macosx/native_NOTIOS/jobjc/README.txt
48513 views
#title JObjC1#2# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4#5# This code is free software; you can redistribute it and/or modify it6# under the terms of the GNU General Public License version 2 only, as7# published by the Free Software Foundation. Oracle designates this8# particular file as subject to the "Classpath" exception as provided9# by Oracle in the LICENSE file that accompanied this code.10#11# This code is distributed in the hope that it will be useful, but WITHOUT12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License14# version 2 for more details (a copy is included in the LICENSE file that15# accompanied this code).16#17# You should have received a copy of the GNU General Public License version18# 2 along with this work; if not, write to the Free Software Foundation,19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.20#21# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA22# or visit www.oracle.com if you need additional information or have any23# questions.24#2526JObjC core provides a pure Java interface for calling C functions and27sending ObjC messages. Given some information, it can marshal types28automatically.2930It also parses BridgeSupport to generate Java wrappers around31Framework bundles. These wrappers rely on the core to provide access32to the C constants, enums, structs, functions, ObjC classes, etc of a33framework.3435* How to build it3637Your best option is `ant all`. There's an Xcode "B&I" target that38works for buildit.3940You'll need a recent JavaNativeFoundation, and perhaps some other41things. Everything is usually there on SnowLeopard (or Leopard after42the common ~javabuild/bin/update runs).4344The build process is quite involved. Xcode takes care of the native45parts, ant takes care of the Java parts, and there's an unholy mix of46external targets and hidden dependencies that keep Xcode and ant (and47buildit on top of that) from stepping on each other. So a warning: the48ant and Xcode targets don't have proper dependencies set up because of49this. They have some dependencies configured, but not the entire50chain. This is because of the jumping back and forth between51externals. If you run the aggregate targets (Xcode B&I, ant all, ant52test, ant bench), everything's is good. But if you manually invoke53individual targets, chances are you'll miss something. Let's go over54it all step by step:5556** ant gen-pcoder5758The PrimitiveCoder subclasses have a lot of boiler plate which59simplifies the generated MixedPrimitiveCoder classes. So instead of60maintaining it, I maintain a tiny Haskell script that spits out the61Java code. This ant target runs that script if Haskell is available on62the system. If it isn't available, this will silently fail. That's63okay, because chances are the PrimitiveCoder.java that you got from64svn is current and does not need to be updated.6566** ant build-core / Xcode build-core-java6768Build core simply builds the JObjC core java classes, and also69generates headers for the JNI for Xcode.7071** ant build-core-native / Xcode build-core-native7273Xcode builds the native core, using the headers from the Java core. It74generates libJObjC.dylib.7576** ant build-generator / Xcode build-generator-java7778ant builds the generator.7980** ant run-generator / Xcode run-generator8182ant runs the generator, using the core Java and native classes.8384What is rungen? And what's run-generator-old? run-generator-old is the85preferred way to run the generator from ant, but there's a strange bug86when running from buildit that causes run-generator-old to87freeze. Pratik was helping me debug it, inspecting the stack and88snooping dtrace probes, but we never found the reason for the89block. So I figured that maybe if I just add a layer of indirection90maybe it'll work around that. And it did. Sad but true.9192** ant build-generated / Xcode build-generated-java9394Build the generator output.9596** ant build-additions / Xcode build-additions-java9798Builds java additions.99100** ant build-additions-native / Xcode build-additions-native101102This builds a new version of libJObjC.dylib. It will rebuild103everything from the core, and include everything from additions.104105** ant assemble-product / Xcode assemble-product-java106107Create a jar, copy products to destination, etc.108109* How to test it110111The test cases also contain a Java component and a native component,112and are built similarly to the above. The benchmarks are built113together with the tests. So "ant build-test" and "ant114build-test-native" will build both the benchmarks and the test. "ant115test" will run the test. "ant bench" will run benchmarks. If you only116want to run a specific benchmark, you can pass a regexp in the117environment variable BENCH_MATCH.118119<src>120ant test121ant bench122BENCH_MATCH=Foo ant bench123</src>124125Test and bench reports will end up in126build/JObjC.build/Debug/test-reports/127128* How to use it129130Include the jar in your classpath and set your java.library.path to131the directory that contains the dylib. Same thing for app bundles.132133134