rJava/0000755000175100001440000000000015133645240011336 5ustar hornikusersrJava/MD50000644000175100001440000004676315133645240011666 0ustar hornikusersd8befe882e45303c55e699ecf2f3390e *DESCRIPTION 8ce0ce5f51c990a52e40300b783b9a82 *NAMESPACE 0633c0ce67b0747bd8fa18b1d60b303a *NEWS c0262f1fee78693a8c38bcb809617145 *R/0classes.R 506b69ab5c1ad97b573874d24554777a *R/J.R f3fb76b841a4385db9de77094ac040a8 *R/arrays.R 575c64359fd7ee6fee236967981783cd *R/call.R d8cc518e9ea16eb69b0327656e06680c *R/comparison.R 39cf1690ea4419bdd52312deddcd0b46 *R/completion.R 46c1f5556d33f24415687bda1385bfc1 *R/converter.R c196ea9f88159fd334eacffcd04394b0 *R/exceptions.R 7d774008ec5904cb1b6729c7caf8ee6b *R/gc.R cd18bdc03d03812e9d850d7f5d481d6e *R/import.R b1d5e8e5f1a708e1e532e98ca015c3a9 *R/instanceof.R eebf265115ed7e272ff27ce642b9c310 *R/jfirst.R c7b11813f1e21fb681c584ebd1f8f6a2 *R/jinit.R f44033bcd8b55df5059790d9f48ccf6f *R/jri.R 8e9d5f144ef7a2ddaa774d69e0bcddf4 *R/loader.R d7b68d370d30c42b76e1c09a1af3553e *R/memprof.R ced216e362b0e2ef2c6b0a2a0510e63a *R/methods.R 703bbb660c9c9c3b87c1901d7cc62d08 *R/options.R c54333aca36610153ad6fc05bf1b9ab8 *R/reflection.R 66cc978228108a49c39e159b419e97a6 *R/rep.R 511ad995209293a190a876a22f31d84d *R/serialize.R 2d5a4d95db9f3435aa627aef91275514 *R/tools.R 57621bdf80ec7782fb6838a816763659 *R/windows/FirstLib.R ec712e3a2878c7c6f4058402208bd8fa *R/with.R d59b3da0c409dcdf2a3e44a1ddf86a3c *R/zzz.R.in fa83e2259836df780b249e023c728ec2 *configure e249f32afe8320c5716f8b63c4bf9c70 *configure.ac fbf09751ef8344617ec0c7d17db3f4cb *configure.win ff1e6a7adff192309b2b618fab6194d0 *inst/java/ArrayDimensionException.class 645da70472ece119aaedfc3ad77ed754 *inst/java/ArrayDimensionException.java 95aae7926e8cb9bc6d2ee7ad30d3c6e6 *inst/java/ArrayWrapper.class bb367164aa632388f6c075a8987f4557 *inst/java/ArrayWrapper.java 5446c5b1a3a01448e5adb2f493419f37 *inst/java/ArrayWrapper_Test.class b549a0e92555b691c3a9054377bc8b9b *inst/java/ArrayWrapper_Test.java 97dd8be6991814bd865a2b8e0d909727 *inst/java/DummyPoint.class d754af1a2f4518bbe5176e9035e75b03 *inst/java/DummyPoint.java ffb9863c51b39d057ca9219879722750 *inst/java/FlatException.class 481d3ff09ad6d5c55402290148a89bda *inst/java/FlatException.java 2604491e9a9a48406b815e4e8a591154 *inst/java/NotAnArrayException.class ef9ef7beaa915a26925cc20c4fbefda6 *inst/java/NotAnArrayException.java 57c019b3cabe4e5178e085f515b793a3 *inst/java/NotComparableException.class 63c0ebbfb86bdde4bff8ebcfd1ece554 *inst/java/NotComparableException.java 11727411ad9df30ce24e6df29a2248c9 *inst/java/ObjectArrayException.class b5b83ff7ddd4c072a50f0b0368e16373 *inst/java/ObjectArrayException.java 821bd0a50136b9f0324fcdb79d767eee *inst/java/PrimitiveArrayException.class 2387add3987f5fd7e415945ccf6d6076 *inst/java/PrimitiveArrayException.java e3699d7682c16d7c163f7a11e797156e *inst/java/RJavaArrayIterator.class ef32fdbb810cf31aa216553342a3c4bc *inst/java/RJavaArrayIterator.java af6d0c2ce1d0bc9a639f244f93ef0900 *inst/java/RJavaArrayTools$ArrayDimensionMismatchException.class 1c08c5e677ef5f74fbb9c20fde9ff16b *inst/java/RJavaArrayTools.class c0074c718ae2153e688d83e57a645ebd *inst/java/RJavaArrayTools.java 3afb959865991fd7b52e611b2cf2fb8d *inst/java/RJavaArrayTools_Test.class 60af1df4c01b9341c94ffae4bb7d463f *inst/java/RJavaArrayTools_Test.java 3196a2685e3d13a430bc72c96a943aa9 *inst/java/RJavaComparator.class 7a72e718abfb06612f1b50c20461c92c *inst/java/RJavaComparator.java d9393576bfca6279baba20390e8c2dc3 *inst/java/RJavaImport.class 96c406f6c5b0811b25d5e96b9a9c2e0c *inst/java/RJavaImport.java ae53f20e7c4e656ee22a78e1fd067e1c *inst/java/RJavaTools.class 952247560db5ed4ac7aa5acd82918caa *inst/java/RJavaTools.java 76175c2e557356eb908d1d9e309222ea *inst/java/RJavaTools_Test$DummyNonStaticClass.class cced0513672f19778d855654a4a64c84 *inst/java/RJavaTools_Test$ExampleClass.class 4aa1233cf46da1d075c1b929f52838f5 *inst/java/RJavaTools_Test$TestException.class f452986ccacf23fe40d194f8d9b23219 *inst/java/RJavaTools_Test.class 57795418a03ad89b77b6c75debf6f322 *inst/java/RJavaTools_Test.java e3069d15bd2ec3f418a02fd09fb5b328 *inst/java/RectangularArrayBuilder.class fc86e40dc5ac9044d5a030417bb2ea80 *inst/java/RectangularArrayBuilder.java 2aa015f254f06f1fa508b9e875cd8dad *inst/java/RectangularArrayBuilder_Test.class c2b39d8cf9759c0be3f5792471d8fc7b *inst/java/RectangularArrayBuilder_Test.java 842ddf927e79ad85c97dd39f79b44e48 *inst/java/RectangularArrayExamples.class 015e6e1f80e15ea50c218c615a17eaa5 *inst/java/RectangularArrayExamples.java 04b98d4fda27233090b468ab9da1e645 *inst/java/RectangularArraySummary.class 20d22ec2a9b22d70ab0bccf67c655ad7 *inst/java/RectangularArraySummary.java c2cfcdd3416e287b3fdeef1328b31fa8 *inst/java/TestException.class 3cad65c59f482541f8f2181585b30dc2 *inst/java/TestException.java 6888d92a6f64414df052663300bac549 *inst/java/boot/RJavaClassLoader$RJavaObjectInputStream.class 5a711bbaa0763c7927ec657240bf5195 *inst/java/boot/RJavaClassLoader$UnixDirectory.class eed34dc82e4c185a71a0cd6499cf98ad *inst/java/boot/RJavaClassLoader$UnixFile.class 371a332e5bd7fd4c41f86c70b14b34ea *inst/java/boot/RJavaClassLoader$UnixJarFile.class af81794823dd522024ceede835bba2f0 *inst/java/boot/RJavaClassLoader.class 0be17cfc7b2a91fc111e8001cd08639f *inst/java/boot/RJavaClassLoader.java 656d7cd8c2bf3af01d3ede2df62a7f94 *inst/jri/JRIEngine.jar e343db28a1af7857c28ca91b5a247c09 *inst/jri/REngine.jar 1702a92c723f09e3fab3583b165a8d90 *jri/LGPL.txt 93f82aebab3ff00b332cf772f576bd74 *jri/LICENSE 6a3ccf125d2f842b0818a623139c8d69 *jri/Makefile.all 4077e065f1febdcb13146b79ce1cc6ae *jri/Makefile.in 03c49ba859c5d95faaad26a62504c927 *jri/Makefile.win 3216ad59f0b9f23c114c16bce1265cbe *jri/Makevars.win bc7cf887c8e1b1f5b1f32df716797bac *jri/Mutex.java e06c14ac136ac4f98ff1205343ef91c7 *jri/NEWS d89806a15972a35208e44cfe67a4c858 *jri/RBool.java 1367ccf5ff46ad11852fd7ad1cbcd3d2 *jri/RConsoleOutputStream.java 111dc569d5346a1f1c817851ae182385 *jri/README 9e80eef6103fd497f9e6f699417cc04e *jri/REXP.java cd72d9d129d543222b6fead0b44a7852 *jri/REngine/JRI/JRIEngine.java 8cd227aa278a590acb08ea8e2eaf8478 *jri/REngine/JRI/Makefile 9714690518f4d6dbfe3f89fefb0e8a91 *jri/REngine/JRI/package-info.java a24881fced120a304d50299e2bca6233 *jri/REngine/JRI/test/Makefile cf61905afba88cc39be79c5dabcf4d07 *jri/REngine/JRI/test/RTest.java 067d3e0bb9ba9932948fecad436036e6 *jri/REngine/LICENSE be6b96b4349a35452a7b2cab4efbe224 *jri/REngine/Makefile 3927ba79c7a801f36075f1b809d06196 *jri/REngine/MutableREXP.java 65e574de8714bdc9f8cd24e8bfafceac *jri/REngine/README.md 865520643c7aa95ed069a4b2a0173fc8 *jri/REngine/REXP.java a8de3e1fab786f0d9762b5b2b0f63bed *jri/REngine/REXPDouble.java 3683350b5fe442d759a1176a96ea7790 *jri/REngine/REXPEnvironment.java 024e5f5858a25b9c88e437bde83b0a08 *jri/REngine/REXPExpressionVector.java 754b193f82b377f2e20437a8deaeb60a *jri/REngine/REXPFactor.java ab79865ed622de5287ea8429514c5984 *jri/REngine/REXPGenericVector.java 8def14772888086b046354a84b5ef042 *jri/REngine/REXPInteger.java edee0fd33051c198b82956231f0f5a68 *jri/REngine/REXPJavaReference.java 42f721124ae0cd5ef5edfb115a412cb6 *jri/REngine/REXPLanguage.java c6c00f3859d2ef66e7b16bd784beebc1 *jri/REngine/REXPList.java e9d0ea19f11eaac2e15980e9b7cf6e9a *jri/REngine/REXPLogical.java c951b85ed10dd9f326d595af605c2aef *jri/REngine/REXPMismatchException.java 28d4839ce78289590aae84bc6d141339 *jri/REngine/REXPNull.java beab9bdcfe5d6a09e8bb0258d086a684 *jri/REngine/REXPRaw.java 0caa0ae63edbeb0ebd28c2371b8d520f *jri/REngine/REXPReference.java e03aebe85120fe43490135da423dcd24 *jri/REngine/REXPS4.java 12f0c290a307d36c419d85cb5e9f8a32 *jri/REngine/REXPString.java 16494ce82d7ac67394151cad5cee3844 *jri/REngine/REXPSymbol.java f28e65acd497901e47295b156775a469 *jri/REngine/REXPUnknown.java 2ad6c462e1fa0498d7ed43d89ba9ca4d *jri/REngine/REXPVector.java 4a2893e415791cf97e161e94f9a626d1 *jri/REngine/REXPWrapper.java 0f4e28d5a7719a3348a7321cd530c74a *jri/REngine/REngine.java ba7130aa5f03935284e484d82f05b2f2 *jri/REngine/REngineCallbacks.java 80f05407ddfa287167fcf5ef9cd84390 *jri/REngine/REngineConsoleHistoryInterface.java c71f9739a92170a9cc623291d1fcd524 *jri/REngine/REngineEvalException.java 7afd3d765c1f3c8aaeb4e595f9bbe72c *jri/REngine/REngineException.java fe69b8b51e8c7ae6a9cdfc5c80f5a2f0 *jri/REngine/REngineInputInterface.java 22b51c4f124c06d1f6d6c9431e6b86ea *jri/REngine/REngineOutputInterface.java baaafc80d15203c724de9f9e439fb157 *jri/REngine/REngineStdOutput.java 78312e95629e7556d324acfd11ddd547 *jri/REngine/REngineUIInterface.java b05e012fb558a1f17213e7f4912c4027 *jri/REngine/RFactor.java 9e0e7022027bd5efb0a5556340364e36 *jri/REngine/RList.java 156922f4fb0190a909641e25094232e0 *jri/REngine/Rserve/Makefile 0a8f260223d6c05eb2fb443b7a107647 *jri/REngine/Rserve/OOBInterface.java eeb0b6fca473f9a4a7a73b02baa4df5e *jri/REngine/Rserve/RConnection.java 1d3f3cac377aaa8428cc6f03782dfd9d *jri/REngine/Rserve/RFileInputStream.java d48ea3cff02124d49b40cdacc461307f *jri/REngine/Rserve/RFileOutputStream.java 8217731c41f582992313a4946401074f *jri/REngine/Rserve/RSession.java 54b81e86a57e56b1637f856be4a86a2d *jri/REngine/Rserve/RserveException.java 7de85b2e0124e7e357ba5ee9f8588930 *jri/REngine/Rserve/StartRserve.java d6244d39698b355ff09cb2c8835b1851 *jri/REngine/Rserve/mkmvn.sh 78bf28c04d3b9de9ef4ef95a0c7918c1 *jri/REngine/Rserve/package-info.java 4fe685ee89c76adc3ba30e4865ee590c *jri/REngine/Rserve/pom.xml 68e1a1474896cc52b31f07652ca74225 *jri/REngine/Rserve/protocol/REXPFactory.java c47aa8abcc0595f96a188c26033ed563 *jri/REngine/Rserve/protocol/RPacket.java a18a52eefeb061ebaaafa23dabaf35a3 *jri/REngine/Rserve/protocol/RTalk.java ed28b70af013379d2a96d0d7dca1a7d6 *jri/REngine/Rserve/protocol/jcrypt.java c3bb8e0b0b40c50d479a3e2b98d20763 *jri/REngine/Rserve/src/test/java/org/rosuda/rserve/RserveTest.java 6c18ff19b49eaf54fb6dd44072f8c727 *jri/REngine/Rserve/test/Makefile 2592ee47962bec10a6c90519c67dd4aa *jri/REngine/Rserve/test/PlotDemo.java a593b733b11ca43a7955c59ebb589e37 *jri/REngine/Rserve/test/StartRserve.java d4ff8f3834f9ca9b742f05c4936a3baa *jri/REngine/Rserve/test/jt.java 3ce7ff2c4dfade193e791813c94d196e *jri/REngine/Rserve/test/test.java e36ef3f74c06d457ba9b5b4a717cd63c *jri/REngine/mkmvn.sh fd1948ffcc8aa12424c33d08869eeb72 *jri/REngine/package-info.java c17346150974cac840361a335e5dca7c *jri/REngine/pom.xml 78b98c7cd55254b58ff011c60a378f4c *jri/RFactor.java 65da163f74e942405100f51457c7c5c7 *jri/RList.java e2ccb469e563006e901b2ed0148a288a *jri/RMainLoopCallbacks.java eeb974948e12d6b2601750ad44ed9763 *jri/RVector.java bf58490a93b67f7eb2fd429d8bbdd6e2 *jri/Rengine.java 3c803b79f3a2dd308f063cb2dc229c6e *jri/bootstrap/Boot.java b8f50d514a93033cc3417b177aae49da *jri/bootstrap/DelegatedClassLoader.java 9d13bd7a1ab846c16892114d544d1c46 *jri/bootstrap/DelegatedURLClassLoader.java 1da78200bd47f7f5600dd603eb17a490 *jri/bootstrap/JRIBootstrap.c 81926a811f52a81cbf79e83ec3b01b51 *jri/bootstrap/JRIBootstrap.h 0e73e0900e11eedef4c3ed1d5358351f *jri/bootstrap/JRIBootstrap.java 1e2605e758ac858a45315877f68e8f45 *jri/bootstrap/JRIClassLoader.java 0e41a1d775ca59467d394b1e5dc57ff5 *jri/bootstrap/Makefile 49b41100efbcb02fdc7d3289851f0c11 *jri/bootstrap/mft 3ac22b40acfcbe08247d5eea83d381ec *jri/configure 19fafed373fd61bd23378220734c461f *jri/configure.ac e9f43c396d7aa93a551ed7e7bd8f04b7 *jri/configure.win 520e423abb56c3b7d2634accf990913f *jri/examples/rtest.java 46e7ae225494cdb2a91b2de96a9ea18b *jri/examples/rtest2.java c69b549f536d2c4fdc7dd6fb2c0c8682 *jri/package-info.java bc8dfbefbb4c8a177682898bfcbe5f54 *jri/run.in ba4f83c3c3acda984dc08c299f5c973a *jri/src/Makefile.all 71dc21c4420695d75d031aede525856f *jri/src/Makefile.in 40bd09315359bb8d8a0efff9ef832890 *jri/src/Makefile.win 4af4494aab4eb68c72bbf2d66d8f9df8 *jri/src/Rcallbacks.c 0e9d20de6cc84e8a7c73f1726cf40e34 *jri/src/Rcallbacks.h 3a493d1e77fa4cc782cbdcfb87f95660 *jri/src/Rdecl.h 8b65b3b732fac9609c2b9d20cd0f637c *jri/src/Rengine.c adb36ab86cb2c731e8af65ed4d69a654 *jri/src/Rinit.c 065ebfa9f7eb83df397bf64e6d69e5c1 *jri/src/Rinit.h c23f315aa91b2494956dce2a4b2f3ced *jri/src/config.h.in a38fc939f86e56b41e19f1d8b28d99ab *jri/src/globals.c 5b9ab765ae9e2e779a7c5d8d7d3c6714 *jri/src/globals.h 095b90e2fa094c201ae5973db032a508 *jri/src/h2ic 07acc909db4d98910292e4286e7f059b *jri/src/jri.c 762a71a98c9f1ac6fef89dbb931adbff *jri/src/jri.h 8e2c496699a639def016017f91dee399 *jri/src/rjava.c 143a716b503395df5178b20a02b68dd1 *jri/src/rjava.h e23740cf5bbb38d024fa78722bbed095 *jri/src/rjstring.c c3a4cc8bb957a22caa6e70d8d1a6004a *jri/src/rjstring.h cd0f80b7eeaeaf7217e8212de507c401 *jri/src/win32/Makefile af290855d859d8feed785b6cc460bdca *jri/src/win32/findjava.c 1c78151860d82da04c904b023d8a57e8 *jri/src/win32/jvm.def 7bbc4291d8011614923e56506dc24ac2 *jri/src/win32/jvm64.def 9828f446225b05e296dc404578a4f092 *jri/tools/config.guess 7efa0e8e26af69d26cb455993dc6587a *jri/tools/config.sub d3de43eb2bbb80375f5afa1d2fe245f7 *jri/tools/getsp.class 22952a289415df6989cf02a6bfe41c80 *jri/tools/getsp.java b090c5891571c820e91d345a9551af44 *jri/tools/install-sh 14f0e0ce972407a0556c89b6d2c50900 *jri/tools/mkinstalldirs ba381d3e918922f6c208ad8225f7e8cd *jri/version 6b0228b2fa88da85179313bcf9058425 *man/Exceptions.Rd f3eace6d924ef71398c57295027244af *man/J.Rd ae43523a3ad4c0dc8f07b34330ff9c3c *man/accessOp.Rd 40fff74556d98fbedbc6854e7f53c23d *man/aslist.Rd c352abc5c3e258de0130127a0577076d *man/clone.Rd dee5645f1ea27113b6bf07173087b1b4 *man/instanceof.Rd 3790b7ba39785eda19dae78d0fc8bb23 *man/jarray.Rd 482be28ccfa570c39ac8ab70673bfa55 *man/jarrayRef-class.Rd 0c69962c9f65812b80aa33220c00edd9 *man/java-tools.Rd 2b577bf507897bb5c6ee0a2825256565 *man/javaImport.Rd 89bfc55898d79f9adab7784c31a0ed98 *man/jcall.Rd e7eb063c7ba073ffb0945860b26afa02 *man/jcast.Rd 49cdbc9900bd6e8ebd0dcfe5a8182576 *man/jcastToArray.Rd 7604dbc21cf9686cb0db7265a79a2973 *man/jcheck.Rd eba4e14cb341f44147aa373a327b440c *man/jclassName.Rd c1ee05e48bb0af24b350ffdae0b9b1ee *man/jengine.Rd bc02763db0a94e3730d5c50ea6b37d26 *man/jequals.Rd b55d48fbeeed00de2dce5b42744ce814 *man/jfield.Rd eaf6a0e7498d10be9dcfc84d329e05b9 *man/jfloat-class.Rd 1528d27faecfb836f5815b772d9046e2 *man/jfloat.Rd 8c23d8437645125a03163b7986d699f2 *man/jgc.Rd a9992230376d447980f6cb96ef1d1621 *man/jinit.Rd d9cddf847d9bd2147f5f711ef0ab4410 *man/jmemprof.Rd f735d24bedce9e0825a74cb73a550340 *man/jnew.Rd 435133b5d10a554a34a6d28969bd9d8a *man/jnull.Rd c8ac98bcf860cbbc8ceab596a889bb32 *man/jobjRef-class.Rd 75f6fe3d78d19a4284d0f44da66ccb7d *man/jpackage.Rd 06ac9575b7b8bb2280582415a0827ae8 *man/jrectRef-class.Rd 47d94ae69febd09e013631647d0e96ed *man/jreflection.Rd bf6c37ec0857eb2bb51c3ac07e5c60f4 *man/jserialize.Rd d21b1e3f6994a6941e9a50e515ca53c7 *man/jsimplify.Rd e4faeeb6e14f43b6b5717fdbb6db8ce8 *man/loader.Rd f42971d8c1454f57226b8607a2f2e1bb *man/new.Rd 376f0173ab4b950cf757b78402f71897 *man/rJava-internal.Rd 393c606a669eb9bacc7e4234bae53ecf *man/rep.Rd b5ba8c698210be6a9abaa85ab25cc2c8 *man/show.Rd 2760bff587d614f13860d5435f0e7181 *man/toJava.Rd 6dd371555cdf1e69a028ee224c460d79 *man/with.Rd 2b764485b08c795de76d81ea588015cf *src/Makevars.in 61e341d751aa8c67162234a838b4760b *src/Makevars.win e77e4b5ee43d3822ca5c959b8fa9493d *src/Rglue.c 71c752999b97f5a3d87fc4574611399d *src/arrayc.c 31383adb32a49536373c640fac5699bf *src/callJNI.c eb839008c4a65f6dc28905c26a0bd436 *src/callback.c b0a0a1a184247e1e249b718008ca3c29 *src/callback.h b3e60bc7509411c8488dc09a590ab378 *src/config.h.in 8a4a0b6b459fd9744abfa1a739ebda19 *src/fields.c a23cbadacae5514a86dbc674a7a2ee04 *src/init.c 842d77ab909b725951d16ae7d5e12836 *src/install.libs.R ff1e6a7adff192309b2b618fab6194d0 *src/java/ArrayDimensionException.class 645da70472ece119aaedfc3ad77ed754 *src/java/ArrayDimensionException.java 95aae7926e8cb9bc6d2ee7ad30d3c6e6 *src/java/ArrayWrapper.class bb367164aa632388f6c075a8987f4557 *src/java/ArrayWrapper.java 5446c5b1a3a01448e5adb2f493419f37 *src/java/ArrayWrapper_Test.class b549a0e92555b691c3a9054377bc8b9b *src/java/ArrayWrapper_Test.java 97dd8be6991814bd865a2b8e0d909727 *src/java/DummyPoint.class d754af1a2f4518bbe5176e9035e75b03 *src/java/DummyPoint.java ffb9863c51b39d057ca9219879722750 *src/java/FlatException.class 481d3ff09ad6d5c55402290148a89bda *src/java/FlatException.java e18c67f965d5960e9e4b0d965d8b3591 *src/java/Makefile 2604491e9a9a48406b815e4e8a591154 *src/java/NotAnArrayException.class ef9ef7beaa915a26925cc20c4fbefda6 *src/java/NotAnArrayException.java 57c019b3cabe4e5178e085f515b793a3 *src/java/NotComparableException.class 63c0ebbfb86bdde4bff8ebcfd1ece554 *src/java/NotComparableException.java 11727411ad9df30ce24e6df29a2248c9 *src/java/ObjectArrayException.class b5b83ff7ddd4c072a50f0b0368e16373 *src/java/ObjectArrayException.java 821bd0a50136b9f0324fcdb79d767eee *src/java/PrimitiveArrayException.class 2387add3987f5fd7e415945ccf6d6076 *src/java/PrimitiveArrayException.java e3699d7682c16d7c163f7a11e797156e *src/java/RJavaArrayIterator.class ef32fdbb810cf31aa216553342a3c4bc *src/java/RJavaArrayIterator.java af6d0c2ce1d0bc9a639f244f93ef0900 *src/java/RJavaArrayTools$ArrayDimensionMismatchException.class 1c08c5e677ef5f74fbb9c20fde9ff16b *src/java/RJavaArrayTools.class c0074c718ae2153e688d83e57a645ebd *src/java/RJavaArrayTools.java 3afb959865991fd7b52e611b2cf2fb8d *src/java/RJavaArrayTools_Test.class 60af1df4c01b9341c94ffae4bb7d463f *src/java/RJavaArrayTools_Test.java 6888d92a6f64414df052663300bac549 *src/java/RJavaClassLoader$RJavaObjectInputStream.class 5a711bbaa0763c7927ec657240bf5195 *src/java/RJavaClassLoader$UnixDirectory.class eed34dc82e4c185a71a0cd6499cf98ad *src/java/RJavaClassLoader$UnixFile.class 371a332e5bd7fd4c41f86c70b14b34ea *src/java/RJavaClassLoader$UnixJarFile.class af81794823dd522024ceede835bba2f0 *src/java/RJavaClassLoader.class 0be17cfc7b2a91fc111e8001cd08639f *src/java/RJavaClassLoader.java 3196a2685e3d13a430bc72c96a943aa9 *src/java/RJavaComparator.class 7a72e718abfb06612f1b50c20461c92c *src/java/RJavaComparator.java d9393576bfca6279baba20390e8c2dc3 *src/java/RJavaImport.class 96c406f6c5b0811b25d5e96b9a9c2e0c *src/java/RJavaImport.java ae53f20e7c4e656ee22a78e1fd067e1c *src/java/RJavaTools.class 952247560db5ed4ac7aa5acd82918caa *src/java/RJavaTools.java 76175c2e557356eb908d1d9e309222ea *src/java/RJavaTools_Test$DummyNonStaticClass.class cced0513672f19778d855654a4a64c84 *src/java/RJavaTools_Test$ExampleClass.class 4aa1233cf46da1d075c1b929f52838f5 *src/java/RJavaTools_Test$TestException.class f452986ccacf23fe40d194f8d9b23219 *src/java/RJavaTools_Test.class 57795418a03ad89b77b6c75debf6f322 *src/java/RJavaTools_Test.java e3069d15bd2ec3f418a02fd09fb5b328 *src/java/RectangularArrayBuilder.class fc86e40dc5ac9044d5a030417bb2ea80 *src/java/RectangularArrayBuilder.java 2aa015f254f06f1fa508b9e875cd8dad *src/java/RectangularArrayBuilder_Test.class c2b39d8cf9759c0be3f5792471d8fc7b *src/java/RectangularArrayBuilder_Test.java 842ddf927e79ad85c97dd39f79b44e48 *src/java/RectangularArrayExamples.class 015e6e1f80e15ea50c218c615a17eaa5 *src/java/RectangularArrayExamples.java 04b98d4fda27233090b468ab9da1e645 *src/java/RectangularArraySummary.class 20d22ec2a9b22d70ab0bccf67c655ad7 *src/java/RectangularArraySummary.java c2cfcdd3416e287b3fdeef1328b31fa8 *src/java/TestException.class 3cad65c59f482541f8f2181585b30dc2 *src/java/TestException.java dabe54457301a06b77d2d7e64991d2c6 *src/jri_glue.c 18d129e1c7776247973b9eea4d406692 *src/jvm-w32/Makefile cd19ef85e932993a3012efe598a9aae7 *src/jvm-w32/WinRegistry.c 797149174d42138ab7e8444c419603f3 *src/jvm-w32/config.h af290855d859d8feed785b6cc460bdca *src/jvm-w32/findjava.c 1c78151860d82da04c904b023d8a57e8 *src/jvm-w32/jvm.def 7bbc4291d8011614923e56506dc24ac2 *src/jvm-w32/jvm64.def 032794afde7d7859c1a94c944ccc2fd4 *src/loader.c 16604fa1fe21032e5603c1c44d085eb6 *src/otables.c 53e0dad35264ebf639c0fb8648f330b1 *src/rJava.c 8b8aa54bb8dfbf5a487beedfcbb41f2f *src/rJava.h 47f73a6a12d498ee9ac9b085de6ce943 *src/registration.c e23740cf5bbb38d024fa78722bbed095 *src/rjstring.c c3a4cc8bb957a22caa6e70d8d1a6004a *src/rjstring.h 88651c3b3bfaa5cd8348c26dca8510ad *src/tools.c 923cb33d4665ca8dd4775ef06db29a8f *tools/getsp.class 1e50e375949e0109a5b69fde529b4080 *tools/getsp.java 80e1ad62ecac019d0b982b2cf8401256 *tools/install-sh rJava/jri/0000755000175100001440000000000015133274032012117 5ustar hornikusersrJava/jri/RMainLoopCallbacks.java0000644000175100001440000000564415133274032016433 0ustar hornikuserspackage org.rosuda.JRI; /** Interface which must be implmented by any class that wants to pose as the call-back handler for R event loop callbacks. It is legal to return immediately except when user interaction is required: {@link #rReadConsole} and {@link #rChooseFile} are expected to block until the user performs the desired action. */ public interface RMainLoopCallbacks { /** called when R prints output to the console @param re calling engine @param text text to display in the console @param oType output type (0=regular, 1=error/warning) */ public void rWriteConsole (Rengine re, String text, int oType); /** called when R enters or exits a longer evaluation. It is usually a good idea to signal this state to the user, e.g. by changing the cursor to a "hourglass" and back. @param re calling engine @param which identifies whether R enters (1) or exits (0) the busy state */ public void rBusy (Rengine re, int which); /** called when R waits for user input. During the duration of this callback it is safe to re-enter R, and very often it is also the only time. The implementation is free to block on this call until the user hits Enter, but in JRI it is a good idea to call {@link Rengine.rniIdle()} occasionally to allow other event handlers (e.g graphics device UIs) to run. Implementations should NEVER return immediately even if there is no input - such behavior will result in a fast cycling event loop which makes the use of R pretty much impossible. @param re calling engine @param prompt prompt to be displayed at the console prior to user's input @param addToHistory flag telling the handler whether the input should be considered for adding to history (!=0) or not (0) @return user's input to be passed to R for evaluation */ public String rReadConsole (Rengine re, String prompt, int addToHistory); /** called when R want to show a warning/error message (not to be confused with messages displayed in the console output) @param re calling engine @param message message to display */ public void rShowMessage (Rengine re, String message); /** called when R expects the user to choose a file @param re calling engine @param newFile flag determining whether an existing or new file is to be selecteed @return path/name of the selected file */ public String rChooseFile (Rengine re, int newFile); /** called when R requests the console to flush any buffered output @param re calling engine */ public void rFlushConsole (Rengine re); /** called to save the contents of the history (the implementation is responsible of keeping track of the history) @param re calling engine @param filename name of the history file */ public void rSaveHistory (Rengine re, String filename); /** called to load the contents of the history @param re calling engine @param filename name of the history file */ public void rLoadHistory (Rengine re, String filename); } rJava/jri/README0000644000175100001440000000420115133274032012774 0ustar hornikusers JRI - Java/R Interface ------------------------ Copyright (C) 2006 Simon Urbanek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details (LGPL.txt). This package contains code that is necessary to run R as a single thread of a Java application. It provides callback that make it possible to run R in REPL mode thus giving the Java application full access to the console. Currently the API is very, very low-level, comparable to the C level interface to R. Convenience methods for mid to high-level are planned, but not implemented yet. For R-to-Java interface, use rJava package which integrates fine with JRI. rJava hooks into the same JVM, so both are opertaing in the same environment. Java to R: JRI R to Java: rJava How to compile ---------------- As of JRI 0.2 everything is 'autoconf'igured. 1) Make sure JDK 1.4 or higher is installed (on Linux 1.5 or later must be installed) and all java commands are ont the PATH. Alternatively you can set JAVA_HOME instead. 2) ./configure 3) make On Windows run "sh configure.win" instead of configure Note for Windows users: you will need the same tools that are necessary to build R, i.e. the /bin tools and MinGW. See R for details. How to use JRI ---------------- There are two Java examples in the JRI directory: rtest.java - demonstrates the use of the low-level interface to construct and retrieve complex R objects. It also demonstrates how to setup callbacks for handling of the console. rtest2.java - a very simple console using stdin as input and a TextField for output. The examples can be run with ./run rtest ./run rtest2 On Windows use run.bat instead --- 04/2006 Simon Urbanek rJava/jri/Rengine.java0000644000175100001440000011073115133274032014354 0ustar hornikuserspackage org.rosuda.JRI; import java.lang.*; /** Rengine class is the interface between an instance of R and the Java VM. Due to the fact that R has no threading support, you can run only one instance of R withing a multi-threaded application. There are two ways to use R from Java: individual call and full event loop. See the Rengine {@link #Rengine constructor} for details.

Important note: All methods starting with rni (R Native Interface) are low-level native methods that should be avoided if a high-level methods exists. They do NOT attempt any synchronization, so it is the duty of the calling program to ensure that the invocation is safe (see {@link #getRsync()} for details). At some point in the future when the high-level API is complete they should become private. However, currently this high-level layer is not complete, so they are available for now.

All rni methods use long type to reference SEXPs on R side. Those reference should never be modified or used in arithmetics - the only reason for not using an extra interface class to wrap those references is that rni methods are all native methods and therefore it would be too expensive to handle the unwrapping on the C side.

jri methods are called internally by R and invoke the corresponding method from the even loop handler. Those methods should usually not be called directly.

Since 0.5 a failure to load the JRI naitve library will not be fatal if jri.ignore.ule=yes system preference is set. Rengine will still not work, but that gives a chance to GUI programs to report the error in a more meaningful way (use {@link #jriLoaded} to check the availability of JRI). */ public class Rengine extends Thread { /** this flags is set to true if the native code was successfully loaded. If this flag is false then none of the rni methods are available. Previous @since API 1.9, JRI 0.5 */ public static boolean jriLoaded; boolean loopHasLock = false; static { try { System.loadLibrary("jri"); jriLoaded = true; } catch (UnsatisfiedLinkError e) { jriLoaded = false; // should be implicit, but well ... String iu = System.getProperty("jri.ignore.ule"); if (iu == null || !iu.equals("yes")) { System.err.println("Cannot find JRI native library!\nPlease make sure that the JRI native library is in a directory listed in java.library.path.\n"); e.printStackTrace(); System.exit(1); } } } static Thread mainRThread = null; // constants to be used with rniSpecialObject /** constant to be used in {@link #rniSpecialObject} to return R_NilValue reference */ public static final int SO_NilValue = 0; /** constant to be used in {@link #rniSpecialObject} to return R_GlobalEnv reference */ public static final int SO_GlobalEnv = 1; /** constant to be used in {@link #rniSpecialObject} to return R_EmptyEnv reference */ public static final int SO_EmptyEnv = 2; /** constant to be used in {@link #rniSpecialObject} to return R_baseEnv reference */ public static final int SO_BaseEnv = 3; /** constant to be used in {@link #rniSpecialObject} to return R_UnboundValue reference */ public static final int SO_UnboundValue = 4; /** constant to be used in {@link #rniSpecialObject} to return R_MissingArg reference */ public static final int SO_MissingArg = 5; /** constant to be used in {@link #rniSpecialObject} to return R_NaString reference */ public static final int SO_NaString = 6; /** constant to be used in {@link #rniSpecialObject} to return R_BlankString reference */ public static final int SO_BlankString = 7; /** API version of the Rengine itself; see also rniGetVersion() for binary version. It's a good idea for the calling program to check the versions of both and abort if they don't match. This should be done using {@link #versionCheck} @return version number as long in the form 0xMMmm */ public static long getVersion() { return 0x010a; } /** check API version of this class and the native binary. This is usually a good idea to ensure consistency. @return true if the API version of the Java code and the native library matches, false otherwise */ public static boolean versionCheck() { return (getVersion()==rniGetVersion()); } /** debug flag. Set to value >0 to enable debugging messages. The verbosity increases with increasing number */ public static int DEBUG = 0; /** this value specifies the time (in ms) to spend sleeping between checks for R shutdown requests if R event loop is not used. The default is 200ms. Higher values lower the CPU usage but may make R less responsive to shutdown attempts (in theory it should not matter because {@link #stop()} uses interrupt to awake from the idle sleep immediately, but some implementation may not honor that). @since JRI 0.3 */ public int idleDelay = 200; /** main engine. Since there can be only one instance of R, this is also the only instance. */ static Rengine mainEngine=null; /** return the current main R engine instance. Since there can be only one true R instance at a time, this is also the only instance. This may not be true for future versions, though. @return current instance of the R engine or null if no R engine was started yet. */ public static Rengine getMainEngine() { return mainEngine; } /* public static Thread getMainRThread() { return mainRThread; } */ /** returns true if the current thread is the main R thread, false otherwise @since JRI 0.4 */ public static boolean inMainRThread() { return (mainRThread != null && mainRThread.equals(Thread.currentThread())); } boolean standAlone = true; /** returns true if this engine was started as a stand-alone Java application or false if this engine was hooked into an existing R instance @since JRI 0.4 */ public boolean isStandAlone() { return standAlone; } boolean died, alive, runLoop, loopRunning; /** arguments used to initialize R, set by the constructor */ String[] args; /** synchronization mutex */ Mutex Rsync; /** callback handler */ RMainLoopCallbacks callback; /** create and start a new instance of R. @param args arguments to be passed to R. Please note that R requires the presence of certain arguments (e.g. --save or --no-save or equivalents), so passing an empty list usually doesn't work. @param runMainLoop if set to true the the event loop will be started as soon as possible, otherwise no event loop is started. Running loop requires initialCallbacks to be set correspondingly as well. @param initialCallbacks an instance implementing the {@link org.rosuda.JRI.RMainLoopCallbacks RMainLoopCallbacks} interface that provides methods to be called by R */ public Rengine(String[] args, boolean runMainLoop, RMainLoopCallbacks initialCallbacks) { super(); Rsync=new Mutex(); died=false; alive=false; runLoop=runMainLoop; loopRunning=false; this.args=args; callback=initialCallbacks; mainEngine=this; mainRThread=this; start(); while (!alive && !died) super.yield(); } /** create a new engine by hooking into an existing, initialized R instance which is calling this constructor. Currently JRI won't influence this R instance other than disabling stack checks (i.e. no callbacks can be registered etc.). It is *not* the designated constructor and it should be used *only* from withing rJava. @since JRI 0.4 */ public Rengine() { super(); Rsync=new Mutex(); died=false; alive=true; runLoop=false; loopRunning=true; standAlone=false; args=new String[] { "--zero-init"}; callback=null; mainEngine=this; mainRThread=Thread.currentThread(); rniSetupR(args); } /** RNI: setup R with supplied parameters (should not be used directly!). @param args arguments @return result code */ native int rniSetupR(String[] args); /** RNI: setup IPC with RJava. This method is used by rJava to pass the IPC information to the JRI engine for synchronization @since experimental, not in the public API! */ public native int rniSetupRJava(int _in, int _out); /** RNI: lock rJava to allow callbacks - this interrupts R event loop until @link{rniRJavaUnlock} is called. @return 0 = lock failed, 1 = locked via IPC (you must use rniRJavaUnlock subsequently), 2 = rJava is already locked */ public native int rniRJavaLock(); /** RNI: unlock rJava - resumes R event loop. Please note that unlocking without a previously successful lock may cause fatal errors, because it may release a lock issued by another thread which may not have finished yet. */ public native int rniRJavaUnlock(); synchronized int setupR() { return setupR(null); } synchronized int setupR(String[] args) { int r=rniSetupR(args); if (r==0) { alive=true; died=false; } else { alive=false; died=true; } return r; } /** RNI: parses a string into R expressions (do NOT use directly unless you know exactly what you're doing, where possible use {@link #eval} instead). Note that no synchronization is performed! @param s string to parse @param parts number of expressions contained in the string @return reference to the resulting list of expressions */ public synchronized native long rniParse(String s, int parts); /** RNI: evaluate R expression (do NOT use directly unless you know exactly what you're doing, where possible use {@link #eval} instead). Note that no synchronization is performed! @param exp reference to the expression to evaluate @param rho environment to use for evaluation (or 0 for global environemnt) @return result of the evaluation or 0 if an error occurred */ public synchronized native long rniEval(long exp, long rho); /** RNI: protect an R object (c.f. PROTECT macro in C) @since API 1.5, JRI 0.3 @param exp reference to protect */ public synchronized native void rniProtect(long exp); /** RNI: unprotect last count references (c.f. UNPROTECT in C) @since API 1.5, JRI 0.3 @param count number of references to unprotect */ public synchronized native void rniUnprotect(int count); /** RNI: get the contents of the first entry of a character vector @param exp reference to STRSXP @return contents or null if the reference is not STRSXP */ public synchronized native String rniGetString(long exp); /** RNI: get the contents of a character vector @param exp reference to STRSXP @return contents or null if the reference is not STRSXP */ public synchronized native String[] rniGetStringArray(long exp); /** RNI: get the contents of an integer vector @param exp reference to INTSXP @return contents or null if the reference is not INTSXP */ public synchronized native int[] rniGetIntArray(long exp); /** RNI: get the contents of a logical vector in its integer array form @since API 1.6, JRI 0.3-2 @param exp reference to LGLSXP @return contents or null if the reference is not LGLSXP */ public synchronized native int[] rniGetBoolArrayI(long exp); /** RNI: get the contents of a numeric vector @param exp reference to REALSXP @return contents or null if the reference is not REALSXP */ public synchronized native double[] rniGetDoubleArray(long exp); /** RNI: get the contents of a raw vector @since API 1.9, JRI 0.5 @param exp reference to RAWSXP @return contents or null if the reference is not RAWSXP */ public synchronized native byte[] rniGetRawArray(long exp); /** RNI: get the contents of a generic vector (aka list) @param exp reference to VECSXP @return contents as an array of references or null if the reference is not VECSXP */ public synchronized native long[] rniGetVector(long exp); /** RNI: create a character vector of the length 1 @param s initial contents of the first entry @return reference to the resulting STRSXP */ public synchronized native long rniPutString(String s); /** RNI: create a character vector @param a initial contents of the vector @return reference to the resulting STRSXP */ public synchronized native long rniPutStringArray(String[] a); /** RNI: create an integer vector @param a initial contents of the vector @return reference to the resulting INTSXP */ public synchronized native long rniPutIntArray(int [] a); /** RNI: create a boolean vector from an integer vector @since API 1.6, JRI 0.3-2 @param a initial contents of the vector @return reference to the resulting LGLSXP */ public synchronized native long rniPutBoolArrayI(int [] a); /** RNI: create a boolean vector @since API 1.6, JRI 0.3-2 @param a initial contents of the vector @return reference to the resulting LGLSXP */ public synchronized native long rniPutBoolArray(boolean [] a); /** RNI: create a numeric vector @param a initial contents of the vector @return reference to the resulting REALSXP */ public synchronized native long rniPutDoubleArray(double[] a); /** RNI: create a raw vector @since API 1.9, JRI 0.5 @param a initial contents of the vector @return reference to the resulting RAWSXP */ public synchronized native long rniPutRawArray(byte[] a); /** RNI: create a generic vector (aka a list) @param exps initial contents of the vector consisiting of an array of references @return reference to the resulting VECSXP */ public synchronized native long rniPutVector(long[] exps); /** RNI: get an attribute @param exp reference to the object whose attribute is requested @param name name of the attribute @return reference to the attribute or 0 if there is none */ public synchronized native long rniGetAttr(long exp, String name); /** RNI: get attribute names @param exp reference to the object whose attributes are requested @return a list of strings naming all attributes or null if there are none @since API 1.9, JRI 0.5 */ public synchronized native String[] rniGetAttrNames(long exp); /** RNI: set an attribute @param exp reference to the object whose attribute is to be modified @param name attribute name @param attr reference to the object to be used as the contents of the attribute */ public synchronized native void rniSetAttr(long exp, String name, long attr); /** RNI: determines whether an R object instance inherits from a specific class (S3 for now) @since API 1.5, JRI 0.3 @param exp reference to an object @param cName name of the class to check @return true if cName inherits from class cName (see inherits in R) */ public synchronized native boolean rniInherits(long exp, String cName); /** RNI: create a dotted-pair list (LISTSXP or LANGSXP) @param head CAR @param tail CDR (must be a reference to LISTSXP or 0) @param tag TAG @param lang if true then LANGSXP is created, otherwise LISTSXP. @return reference to the newly created LISTSXP/LANGSXP @since API 1.7, JRI 0.3-7 */ public synchronized native long rniCons(long head, long tail, long tag, boolean lang); /** RNI: create a dotted-pair list (LISTSXP) @param head CAR @param tail CDR (must be a reference to LISTSXP or 0) @return reference to the newly created LISTSXP */ public long rniCons(long head, long tail) { return rniCons(head, tail, 0, false); } /** RNI: create a dotted-pair language list (LANGSXP) @param head CAR @param tail CDR (must be a reference to LANGSXP or 0) @return reference to the newly created LANGSXP @since API 1.7, JRI 0.3-7 */ public long rniLCons(long head, long tail) { return rniCons(head, tail, 0, true); } /** RNI: get CAR of a dotted-pair list (LISTSXP) @param exp reference to the list @return reference to CAR of the list (head) */ public synchronized native long rniCAR(long exp); /** RNI: get CDR of a dotted-pair list (LISTSXP) @param exp reference to the list @return reference to CDR of the list (tail) */ public synchronized native long rniCDR(long exp); /** RNI: get TAG of a dotted-pair list (LISTSXP) @param exp reference to the list @return reference to TAG of the list (tail) */ public synchronized native long rniTAG(long exp); /** RNI: create a dotted-pair list (LISTSXP) @since API 1.5, JRI 0.3 @param cont contents as an array of references @return reference to the newly created LISTSXP */ public synchronized native long rniPutList(long[] cont); /** RNI: retrieve CAR part of a dotted-part list recursively as an array of references @param exp reference to a dotted-pair list (LISTSXP) @return contents of the list as an array of references */ public synchronized native long[] rniGetList(long exp); /** RNI: retrieve name of a symbol (c.f. PRINTNAME) @since API 1.5, JRI 0.3 @param sym reference to a symbol @return name of the symbol or null on error or if exp is no symbol */ public synchronized native String rniGetSymbolName(long sym); /** RNI: install a symbol name @since API 1.5, JRI 0.3 @param sym symbol name @return reference to SYMSXP referencing the symbol */ public synchronized native long rniInstallSymbol(String sym); /** RNI: print.

Note: May NOT be called inside any WriteConsole callback as it would cause an infinite loop. @since API 1.8, JRI 0.4 @param s string to print (as-is) @param oType output type (see R for exact references, but 0 should be regular output and 1 error/warning) */ public synchronized native void rniPrint(String s, int oType); /** RNI: print the value of a given R object (via print or show method) to the console @since API 1.9, JRI 0.5 @param exp reference to an R object */ public synchronized native void rniPrintValue(long exp); /** RNI: preserve object (prevent grabage collection in R) until rniRelease is called. @since API 1.9, JRI 0.5 @param exp reference to an R object */ public synchronized native void rniPreserve(long exp); /** RNI: release object previously preserved via rniPreserve.

Note: releasing an obejct that was not preserved is an error and results in an undefined behavior. @since API 1.9, JRI 0.5 @param exp reference to an R object */ public synchronized native void rniRelease(long exp); /** RNI: return the parent environment @since API 1.9, JRI 0.5 @param exp reference to environment @return parent environment */ public synchronized native long rniParentEnv(long exp); /** RNI: find variable in an environment @since API 1.9, JRI 0.5 @param sym symbol name @param rho reference to environment @return reference to the value or UnboundValue if not found */ public synchronized native long rniFindVar(String sym, long rho); /** RNI: return the list of variable names of an environment @since API 1.9, JRI 0.5 @param exp reference to the environment @param all if set to true then all objects will be shown, otherwise hidden objects will be omitted @return reference to a string vector of names in the environment */ public synchronized native long rniListEnv(long exp, boolean all); /** RNI: return a special object reference. Note that all such references are constants valid for the entire session and cannot be protected/preserved (they are persistent already). @since API 1.9, JRI 0.5 @param which constant referring to a particular special object (see SO_xxx constants) @return reference to a special object or 0 if the kind of object it unknown/unsupported */ public synchronized native long rniSpecialObject(int which); //--- was API 1.4 but it only caused portability problems, so we got rid of it //public static native void rniSetEnv(String key, String val); //public static native String rniGetEnv(String key); //--- end API 1.4 /** RNI: convert Java object to EXTPTRSEXP @param o arbitrary Java object @return new EXTPTRSEXP pointing to the Java object @since API 1.5, JRI 0.3 */ public synchronized native long rniJavaToXref(Object o); /** RNI: convert EXTPTRSEXP to Java object - make sure the pointer is really what you expect, otherwise you'll crash the JVM! @param exp reference to EXTPTRSEXP pointing to a Java object @return resulting Java object @since API 1.5, JRI 0.3 */ public synchronized native Object rniXrefToJava(long exp); /** RNI: return the API version of the native library @return API version of the native library */ public static native long rniGetVersion(); /** RNI: interrupt the R process (if possible). Note that R handles interrupt requests in (R-thread-)synchronous, co-operative fashion as it wants to make sure that the interrupted state is recoverable. If interrupting from another thread while using blocking ReadConsole REPL make sure you also interrupt your ReadConsole call after rniStop such that R can act on the signalled interrupt. @param flag determines how to attempt to inform R about the interrput. For normal (safe) operation using flag signalling must be 0. Other options are 1 (SIGINT for compatibility with older JRI API) and 2 (Rf_onintr call - use only on the R thread and only if you know what it means). Values other than 0 are only supported since JRI 0.5-4. @return result code (currently 0) */ public native int rniStop(int flag); /** RNI: assign a value to an environment @param name name @param exp value @param rho environment (use 0 for the global environment) @return true if successful, false on failure (usually this means that the binding is locked) @since API 1.10, JRI 0.5-1 (existed before but returned void) */ public synchronized native boolean rniAssign(String name, long exp, long rho); /** RNI: get the SEXP type @param exp reference to a SEXP @return type of the expression (see xxxSEXP constants) */ public synchronized native int rniExpType(long exp); /** RNI: run the main loop.
Note: this is an internal method and it doesn't return until the loop exits. Don't use directly! */ public native void rniRunMainLoop(); /** RNI: run other event handlers in R */ public synchronized native void rniIdle(); /** Add a handler for R callbacks. The current implementation supports only one handler at a time, so call to this function implicitly removes any previous handlers */ public void addMainLoopCallbacks(RMainLoopCallbacks c) { // we don't really "add", we just replace ... (so far) callback = c; } /** if Rengine was initialized with runMainLoop=false then this method can be used to start the main loop at a later point. It has no effect if the loop is running already. This method returns immediately but the loop will be started once the engine is ready. Please note that there is currently no way of stopping the R thread if the R event loop is running other than using quit command in R which closes the entire application. */ public void startMainLoop() { runLoop=true; } //============ R callback methods ========= /** JRI: R_WriteConsole call-back from R @param text text to disply */ public void jriWriteConsole(String text, int oType) { if (callback!=null) callback.rWriteConsole(this, text, oType); } /** JRI: R_Busy call-back from R @param which state */ public void jriBusy(int which) { if (callback!=null) callback.rBusy(this, which); } /** JRI: R_ReadConsole call-back from R. @param prompt prompt to display before waiting for the input.
Note: implementations should block for input. Returning immediately is usually a bad idea, because the loop will be cycling. @param addToHistory flag specifying whether the entered contents should be added to history @return content entered by the user. Returning null corresponds to an EOF and usually causes R to exit (as in q()). */ public String jriReadConsole(String prompt, int addToHistory) { if (DEBUG>1) System.out.println("Rengine.jreReadConsole BEGIN "+Thread.currentThread()); if (loopHasLock) { Rsync.unlock(); loopHasLock = false; } String s = (callback == null) ? null : callback.rReadConsole(this, prompt, addToHistory); loopHasLock = Rsync.safeLock(); if (!loopHasLock) { String es = "\n>>JRI Warning: jriReadConsole detected a possible deadlock ["+Rsync+"]["+Thread.currentThread()+"]. Proceeding without lock, but this is inherently unsafe.\n"; jriWriteConsole(es, 1); System.err.print(es); } if (DEBUG>1) System.out.println("Rengine.jreReadConsole END "+Thread.currentThread()); return s; } /** JRI: R_ShowMessage call-back from R @param message message */ public void jriShowMessage(String message) { if (callback!=null) callback.rShowMessage(this, message); } /** JRI: R_loadhistory call-back from R @param filename name of the history file */ public void jriLoadHistory(String filename) { if (callback!=null) callback.rLoadHistory(this, filename); } /** JRI: R_savehistory call-back from R @param filename name of the history file */ public void jriSaveHistory(String filename) { if (callback!=null) callback.rSaveHistory(this, filename); } /** JRI: R_ChooseFile call-back from R @param newFile flag specifying whether an existing or new file is requested @return name of the selected file or null if cancelled */ public String jriChooseFile(int newFile) { if (callback!=null) return callback.rChooseFile(this, newFile); return null; } /** JRI: R_FlushConsole call-back from R */ public void jriFlushConsole() { if (callback!=null) callback.rFlushConsole(this); } //============ "official" API ============= /** Parses and evaluates an R expression and returns the result. Has the same effect as calling eval(s, true). @param s expression (as string) to parse and evaluate @return resulting expression or null if something wnet wrong */ public synchronized REXP eval(String s) { return eval(s, true); } /** Parses and evaluates an R expression and returns the result. @since JRI 0.3 @param s expression (as string) to parse and evaluate @param convert if set to true the resulting REXP will contain native representation of the contents, otherwise an empty REXP will be returned. Depending on the back-end an empty REXP may or may not be used to convert the result at a later point. @return resulting expression or null if something wnet wrong */ public synchronized REXP eval(String s, boolean convert) { if (DEBUG>0) System.out.println("Rengine.eval("+s+"): BEGIN "+Thread.currentThread()); boolean obtainedLock=Rsync.safeLock(); try { /* --- so far, we ignore this, because it can happen when a callback needs an eval which is ok ... if (!obtainedLock) { String es="\n>>JRI Warning: eval(\""+s+"\") detected a possible deadlock ["+Rsync+"]["+Thread.currentThread()+"]. Proceeding without lock, but this is inherently unsafe.\n"; jriWriteConsole(es); System.err.print(es); } */ long pr = rniParse(s, 1); if (pr != 0) { long er = rniEval(pr, 0); if (er != 0) { REXP x = new REXP(this, er, convert); if (DEBUG>0) System.out.println("Rengine.eval("+s+"): END (OK)"+Thread.currentThread()); return x; } } } finally { if (obtainedLock) Rsync.unlock(); } if (DEBUG>0) System.out.println("Rengine.eval("+s+"): END (ERR)"+Thread.currentThread()); return null; } /** This method is very much like {@link #eval(String)}, except that it is non-blocking and returns null if the engine is busy. @param s string to evaluate @return result of the evaluation or null if the engine is busy */ public synchronized REXP idleEval(String s) { return idleEval(s, true); } /** This method is very much like {@link #eval(String,boolean)}, except that it is non-blocking and returns null if the engine is busy. @since JRI 0.3 @param s string to evaluate @param convert flag denoting whether an empty or fully-converted REXP should be returned (see {@link #eval(String,boolean)} for details) @return result of the evaluation or null if the engine is busy */ public synchronized REXP idleEval(String s, boolean convert) { int lockStatus=Rsync.tryLock(); if (lockStatus==1) return null; // 1=locked by someone else boolean obtainedLock=(lockStatus==0); try { long pr = rniParse(s, 1); if (pr != 0) { long er = rniEval(pr, 0); if (er != 0) { REXP x = new REXP(this, er, convert); return x; } } } finally { if (obtainedLock) Rsync.unlock(); } return null; } /** returns the synchronization mutex for this engine. If an external code needs to use RNI calls, it should do so only in properly protected environment secured by this mutex. Usually the procedure should be as follows:

	boolean obtainedLock = e.getRsync().safeLock();
	try {
		// use RNI here ...
	} finally {
		if (obtainedLock) e.getRsync().unlock();
	}
	
@return synchronization mutex @since JRI 0.3 */ public Mutex getRsync() { return Rsync; } /** check the state of R @return true if R is alive and false if R died or exitted */ public synchronized boolean waitForR() { return alive; } /** attempt to shut down R. This method is asynchronous. */ public void end() { alive = false; interrupt(); } /** The implementation of the R thread. This method should not be called directly. */ public void run() { if (DEBUG > 0) System.out.println("Starting R..."); loopHasLock = Rsync.safeLock(); // force all code to wait until R is ready try { if (setupR(args) == 0) { if (!runLoop && loopHasLock) { // without event loop we can unlock now since we won't do anything Rsync.unlock(); loopHasLock = false; } while (alive) { try { if (runLoop) { if (DEBUG > 0) System.out.println("***> launching main loop:"); loopRunning = true; rniRunMainLoop(); // actually R never returns from runMainLoop ... loopRunning = false; if (DEBUG > 0) System.out.println("***> main loop finished:"); runLoop = false; died = true; return; } sleep(idleDelay); if (runLoop) rniIdle(); } catch (InterruptedException ie) { interrupted(); } } died=true; if (DEBUG>0) System.out.println("Terminating R thread."); } else { System.err.println("Unable to start R"); } } finally { if (loopHasLock) Rsync.unlock(); } } /** assign a string value to a symbol in R. The symbol is created if it doesn't exist already. * @param sym symbol name. The symbol name is used as-is, i.e. as if it was quoted in R code (for example assigning to "foo$bar" has the same effect as `foo$bar`<- and NOT foo$bar<-). * @param ct contents * @return true if successful, false otherwise * @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, String ct) { boolean obtainedLock = Rsync.safeLock(); try { long x1 = rniPutString(ct); return rniAssign(sym,x1,0); } finally { if (obtainedLock) Rsync.unlock(); } } /** assign a content of a REXP to a symbol in R. The symbol is created if it doesn't exist already. @param sym symbol name. The symbol name is used as-is, i.e. as if it was quoted in R code (for example assigning to "foo$bar" has the same effect as `foo$bar`<- and NOT foo$bar<-). @param r contents as REXP. currently only raw references and basic types (int, double, int[], double[], boolean[]) are supported. @return true if successful, false otherwise (usually locked binding or unsupported REXP) @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, REXP r) { boolean obtainedLock = Rsync.safeLock(); try { if (r.Xt == REXP.XT_NONE) { return rniAssign(sym, r.xp, 0); } if (r.Xt == REXP.XT_INT || r.Xt == REXP.XT_ARRAY_INT) { int[] cont = r.rtype == REXP.XT_INT?new int[]{((Integer)r.cont).intValue()}:(int[])r.cont; long x1 = rniPutIntArray(cont); return rniAssign(sym,x1,0); } if (r.Xt == REXP.XT_DOUBLE || r.Xt == REXP.XT_ARRAY_DOUBLE) { double[] cont = r.rtype == REXP.XT_DOUBLE?new double[]{((Double)r.cont).intValue()}:(double[])r.cont; long x1 = rniPutDoubleArray(cont); return rniAssign(sym,x1,0); } if (r.Xt == REXP.XT_ARRAY_BOOL_INT) { long x1 = rniPutBoolArrayI((int[])r.cont); return rniAssign(sym,x1,0); } if (r.Xt == REXP.XT_STR || r.Xt == REXP.XT_ARRAY_STR) { String[] cont = r.rtype == REXP.XT_STR?new String[]{(String)r.cont}:(String[])r.cont; long x1 = rniPutStringArray(cont); return rniAssign(sym,x1,0); } } finally { if (obtainedLock) Rsync.unlock(); } return false; } /** assign values of an array of doubles to a symbol in R (creating an integer vector).
equals to calling {@link #assign(String, REXP)}. @param sym symbol name @param val double array to assign @return true if successful, false otherwise @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, double[] val) { return assign(sym,new REXP(val)); } /** assign values of an array of integers to a symbol in R (creating a numeric vector).
equals to calling {@link #assign(String, REXP)}. @param sym symbol name @param val integer array to assign @return true if successful, false otherwise @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, int[] val) { return assign(sym,new REXP(val)); } /** assign values of an array of booleans to a symbol in R (creating a logical vector).
equals to calling {@link #assign(String, REXP)}. @param sym symbol name @param val boolean array to assign @return true if successful, false otherwise @since JRI 0.3-2 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, boolean[] val) { return assign(sym,new REXP(val)); } /** assign values of an array of strings to a symbol in R (creating a character vector).
equals to calling {@link #assign(String, REXP)}. @param sym symbol name @param val string array to assign @return true if successful, false otherwise @since JRI 0.3 (return value changed to boolean in JRI 0.5-1) */ public boolean assign(String sym, String[] val) { return assign(sym,new REXP(val)); } /** creates a jobjRef reference in R via rJava.
Important: rJava must be loaded and intialized in R (e.g. via eval("{library(rJava);.jinit()}",false), otherwise this will fail. Requires rJava 0.4-13 or higher! @param o object to push @return Pure REXP reference of the newly created jobjRef object or null upon failure. It will have the type XT_NONE such that it can be used in @link{assign(String, REXP)}. @since JRI 0.3-7 */ public REXP createRJavaRef(Object o) { if (o == null) return null; String klass = o.getClass().getName(); boolean obtainedLock = Rsync.safeLock(); try { long l = rniEval( rniLCons( rniInstallSymbol(".jmkref"), rniLCons( rniJavaToXref(o), rniLCons( rniPutString(klass), 0 ) ) ) , 0); if (l <= 0 && l > -4) return null; /* for safety failure codes are only -3 .. 0 to not clash with 64-bit pointers */ return new REXP(this, l, false); } finally { if (obtainedLock) Rsync.unlock(); } } } rJava/jri/Makefile.in0000644000175100001440000000052115133274032014162 0ustar hornikusers# JRI - Java/R Interface experimental! #-------------------------------------------------------------------------- # See Makefile.all for the actual building process # The values are all auto-configured RHOME=@R_HOME@ JAVAC=@JAVAC@ JAVAH=@JAVAH@ JAVA=@JAVA_PROG@ JFLAGS=@JFLAGS@ JRILIB=@JNIPREFIX@jri@JNISO@ include Makefile.all rJava/jri/Makevars.win0000644000175100001440000000072415133274032014412 0ustar hornikusersR_HOME=$(RHOME) JAVA_HOME=$(JAVAHOME) JAVAINC=-I$(JAVAHOME)/include -I$(JAVAHOME)/include/win32 RINC=-I$(R_HOME)/include JNISO=.dll JAVA_LIBS=-Lwin32 -ljvm JNILD=-shared $(JAVA_LIBS) -L$(RHOME)/src/gnuwin32 -L$(RHOME)/bin$(R_ARCH) -lR -Wl,--kill-at CFLAGS+=-DWin32 -D_JNI_IMPLEMENTATION_ JAVA_PROG=$(JAVAHOME)/bin/java JAVA=$(JAVAHOME)/bin/java JAVAC=$(JAVAHOME)/bin/javac JAR=$(JAVAHOME)/bin/jar JRIDEPS=win32/libjvm.dll.a JNIPREFIX= PLATFORMT=run.bat JRILIB=jri.dll rJava/jri/bootstrap/0000755000175100001440000000000015133274032014134 5ustar hornikusersrJava/jri/bootstrap/DelegatedClassLoader.java0000644000175100001440000000037015133274032020772 0ustar hornikusersimport java.net.URL; public interface DelegatedClassLoader { public String delegatedFindLibrary(String name); public Class delegatedFindClass(String name) throws ClassNotFoundException; public URL delegatedFindResource(String name); } rJava/jri/bootstrap/JRIBootstrap.h0000644000175100001440000000260715133274032016634 0ustar hornikusers/* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class JRIBootstrap */ #ifndef _Included_JRIBootstrap #define _Included_JRIBootstrap #ifdef __cplusplus extern "C" { #endif #undef JRIBootstrap_HKLM #define JRIBootstrap_HKLM 0L #undef JRIBootstrap_HKCU #define JRIBootstrap_HKCU 1L /* * Class: JRIBootstrap * Method: getenv * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_JRIBootstrap_getenv (JNIEnv *, jclass, jstring); /* * Class: JRIBootstrap * Method: setenv * Signature: (Ljava/lang/String;Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_JRIBootstrap_setenv (JNIEnv *, jclass, jstring, jstring); /* * Class: JRIBootstrap * Method: regvalue * Signature: (ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_JRIBootstrap_regvalue (JNIEnv *, jclass, jint, jstring, jstring); /* * Class: JRIBootstrap * Method: regsubkeys * Signature: (ILjava/lang/String;)[Ljava/lang/String; */ JNIEXPORT jobjectArray JNICALL Java_JRIBootstrap_regsubkeys (JNIEnv *, jclass, jint, jstring); /* * Class: JRIBootstrap * Method: expand * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_JRIBootstrap_expand (JNIEnv *, jclass, jstring); #ifdef __cplusplus } #endif #endif rJava/jri/bootstrap/JRIBootstrap.c0000644000175100001440000001151515133274032016625 0ustar hornikusers#include "JRIBootstrap.h" #if defined WIN32 || defined Win32 #include #include static const HKEY keyDB[2] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; JNIEXPORT jstring JNICALL Java_JRIBootstrap_getenv (JNIEnv *env, jclass cl, jstring sVar) { char cVal[1024]; int res; const char *cVar = (*env)->GetStringUTFChars(env, sVar, 0); if (!cVar) return 0; *cVal=0; cVal[1023]=0; res = GetEnvironmentVariable(cVar, cVal, 1023); (*env)->ReleaseStringUTFChars(env, sVar, cVar); return res?((*env)->NewStringUTF(env, cVal)):0; } JNIEXPORT void JNICALL Java_JRIBootstrap_setenv (JNIEnv *env, jclass cl, jstring sVar, jstring sVal) { const char *cVar = sVar?(*env)->GetStringUTFChars(env, sVar, 0):0; const char *cVal = sVal?(*env)->GetStringUTFChars(env, sVal, 0):0; if (cVar) SetEnvironmentVariable(cVar, cVal?cVal:""); if (cVar) (*env)->ReleaseStringUTFChars(env, sVar, cVar); if (cVal) (*env)->ReleaseStringUTFChars(env, sVal, cVal); return; } JNIEXPORT jstring JNICALL Java_JRIBootstrap_regvalue (JNIEnv *env, jclass cl, jint iRoot, jstring sKey, jstring sVal) { const char *cKey = sKey?(*env)->GetStringUTFChars(env, sKey, 0):0; const char *cVal = sVal?(*env)->GetStringUTFChars(env, sVal, 0):0; jstring res = 0; if (cKey && cVal) { HKEY key; if (RegOpenKeyEx(keyDB[iRoot], cKey, 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) { char buf[1024]; DWORD t, s = 1023; *buf=0; buf[1023]=0; if (RegQueryValueEx(key, cVal, 0, &t, buf, &s) == ERROR_SUCCESS) { res = (*env)->NewStringUTF(env, buf); } RegCloseKey(key); } } if (cVal) (*env)->ReleaseStringUTFChars(env, sVal, cVal); if (cKey) (*env)->ReleaseStringUTFChars(env, sKey, cKey); return res; } JNIEXPORT jobjectArray JNICALL Java_JRIBootstrap_regsubkeys (JNIEnv *env, jclass cl, jint iRoot, jstring sKey) { const char *cKey = sKey?(*env)->GetStringUTFChars(env, sKey, 0):0; jobjectArray res = 0; if (cKey) { HKEY key; if (RegOpenKeyEx(keyDB[iRoot], cKey, 0, KEY_ENUMERATE_SUB_KEYS|KEY_QUERY_VALUE, &key) == ERROR_SUCCESS) { int n = 0, i = 0; char buf[256]; jclass cStr; *buf=0; buf[255]=0; /* pass 1: count the entries */ while (RegEnumKey(key, n, buf, 254) == ERROR_SUCCESS) n++; /* pass 2: get the values */ cStr = (*env)->FindClass(env, "java/lang/String"); res = (*env)->NewObjectArray(env, n, cStr, 0); (*env)->DeleteLocalRef(env, cStr); while (iSetObjectArrayElement(env, res, i++, (*env)->NewStringUTF(env, buf)); RegCloseKey(key); } (*env)->ReleaseStringUTFChars(env, sKey, cKey); } return res; } JNIEXPORT jstring JNICALL Java_JRIBootstrap_expand (JNIEnv *env, jclass cl, jstring sVal) { jstring res = sVal; const char *cVal = sVal?(*env)->GetStringUTFChars(env, sVal, 0):0; char buf[1024]; *buf=0; buf[1023]=0; if (cVal) { if (ExpandEnvironmentStrings(cVal, buf, 1023)) res = (*env)->NewStringUTF(env, buf); } if (cVal) (*env)->ReleaseStringUTFChars(env, sVal, cVal); return res; } JNIEXPORT jboolean JNICALL Java_JRIBootstrap_hasreg (JNIEnv *env, jclass cl) { return JNI_TRUE; } #else #include JNIEXPORT jstring JNICALL Java_JRIBootstrap_getenv (JNIEnv *env, jclass cl, jstring sVar) { char *cVal; const char *cVar = sVar?(*env)->GetStringUTFChars(env, sVar, 0):0; if (!cVar) return 0; cVal=getenv(cVar); (*env)->ReleaseStringUTFChars(env, sVar, cVar); return cVal?((*env)->NewStringUTF(env, cVal)):0; } JNIEXPORT void JNICALL Java_JRIBootstrap_setenv (JNIEnv *env, jclass cl, jstring sVar, jstring sVal) { const char *cVar = sVar?(*env)->GetStringUTFChars(env, sVar, 0):0; const char *cVal = sVal?(*env)->GetStringUTFChars(env, sVal, 0):0; if (cVar) setenv(cVar, cVal?cVal:"", 1); if (cVar) (*env)->ReleaseStringUTFChars(env, sVar, cVar); if (cVal) (*env)->ReleaseStringUTFChars(env, sVal, cVal); return; } /* no registry on unix, so always return null */ JNIEXPORT jstring JNICALL Java_JRIBootstrap_regvalue (JNIEnv *env, jclass cl, jint iRoot, jstring sKey, jstring sVal) { return 0; } JNIEXPORT jobjectArray JNICALL Java_JRIBootstrap_regsubkeys (JNIEnv *env, jclass cl, jint iRoot, jstring sKey) { return 0; } JNIEXPORT jstring JNICALL Java_JRIBootstrap_expand (JNIEnv *env, jclass cl, jstring sVal) { return sVal; } JNIEXPORT jboolean JNICALL Java_JRIBootstrap_hasreg (JNIEnv *env, jclass cl) { return JNI_FALSE; } #endif JNIEXPORT jstring JNICALL Java_JRIBootstrap_arch (JNIEnv *env, jclass cl) { const char *ca = "unknown"; /* this is mainly for Macs so we can determine the correct arch ... */ #ifdef __ppc__ ca = "ppc"; #endif #ifdef __i386__ ca = "i386"; #endif #ifdef __x86_64__ ca = "x86_64"; #endif #ifdef __ppc64__ ca = "ppc64"; #endif return (*env)->NewStringUTF(env, ca); } rJava/jri/bootstrap/Boot.java0000644000175100001440000001010215133274032015674 0ustar hornikusersimport java.io.File; import java.io.InputStream; import java.io.FileOutputStream; import java.util.StringTokenizer; import java.util.zip.ZipFile; import java.util.zip.ZipEntry; import java.lang.reflect.Method; public class Boot { public static String bootFile = null; public static String findInPath(String path, String fn) { StringTokenizer st = new StringTokenizer(path, File.pathSeparator); while (st.hasMoreTokens()) { String dirname=st.nextToken(); try { File f = new File(dirname+File.separator+fn); if (f.isFile()) return f.getPath(); } catch (Exception fex) {} } return null; } public static String findNativeLibrary(String basename, boolean internalFirst) { String libName = "lib"+basename; String ext = ".so"; String os = System.getProperty("os.name"); if (os.startsWith("Win")) { os = "Win"; ext= ".dll"; libName=basename; } if (os.startsWith("Mac")) { os = "Mac"; ext= ".jnilib"; } String fullName = libName+ext; // first, try the system path unless instructed otherwise if (!internalFirst) { try { String r = findInPath("."+File.pathSeparator+System.getProperty("java.library.path"), fullName); if (r != null) return r; } catch (Exception ex1) {} } // second, try to locate in on the class path (in the JAR file or in one of the directories) String cp = System.getProperty("java.class.path"); StringTokenizer st = new StringTokenizer(cp, File.pathSeparator); while (st.hasMoreTokens()) { String dirname=st.nextToken(); try { File f = new File(dirname); if (f.isFile()) { // look in a JAR file and extract it if necessary ZipFile jf = new ZipFile(f); ZipEntry ze = jf.getEntry(fullName); if (ze != null) { // found it inside a JAR file try { bootFile = f.toString(); File tf = File.createTempFile(basename,ext); System.out.println("Boot.findNativeLibrary: found in a JAR ("+jf+"), extracting into "+tf); InputStream zis = jf.getInputStream(ze); FileOutputStream fos = new FileOutputStream(tf); byte b[] = new byte[65536]; while (zis.available()>0) { int n = zis.read(b); if (n>0) fos.write(b, 0, n); } zis.close(); fos.close(); tf.deleteOnExit(); return tf.getPath(); } catch (Exception foo) { } } } else if (f.isDirectory()) { File ff = new File(dirname+File.separator+fullName); if (ff.isFile()) return ff.getPath(); } } catch(Exception ex2) {} } // third, try the system path if we didn't look there before if (internalFirst) { try { String r = findInPath("."+File.pathSeparator+System.getProperty("java.library.path"), fullName); if (r != null) return r; } catch (Exception ex3) {} } return null; } public static void main(String[] args) { // 1) instantiate master class loader JRIClassLoader mcl = JRIClassLoader.getMainLoader(); // 2) locate boot JNI library String nl = findNativeLibrary("boot", false); if (nl == null) { System.err.println("ERROR: Unable to locate native bootstrap library."); System.exit(1); } // register boot library with MCL mcl.registerLibrary("boot", new File(nl)); // add path necessary for loading JRIBootstrap to MCL String cp = System.getProperty("java.class.path"); StringTokenizer st = new StringTokenizer(cp, File.pathSeparator); while (st.hasMoreTokens()) { String p = st.nextToken(); mcl.addClassPath(p); // we assume that the first file on the CP is us (FIXME: verify this!) if (bootFile==null && (new File(p)).isFile()) bootFile=p; } // call static bootstrap method try { // force the use of the MCL even if the system loader could find it Class stage2class = mcl.findAndLinkClass("JRIBootstrap"); Method m = stage2class.getMethod("bootstrap", new Class[] { String[].class }); m.invoke(null, new Object[] { args }); } catch (Exception rtx) { System.err.println("ERROR: Unable to invoke bootstrap method in JRIBootstrap! ("+rtx+")"); rtx.printStackTrace(); System.exit(2); } } } rJava/jri/bootstrap/Makefile0000644000175100001440000000306615133274037015606 0ustar hornikusers# Makefile for JRI bootstrap # Win/OSX should be ok, Linux will need some tweaking all: boot.jar OSKIND=$(shell if echo "${OS}"|grep -i windows >/dev/null 2>&1; then echo win32; else uname -s; fi) ifeq ($(OSKIND),win32) ifeq ($(JAVA_HOME),) JAVA_HOME=N:/java/jdk1.5.0 endif JSO_PREFIX= JSO_SUFFIX=.dll JCPPFLAGS=-DWIN32 -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/win32 JLDFLAGS=-shared -Wl,--add-stdcall-alias -mno-cygwin JLIBS=-L$(JAVA_HOME)/jre/bin/client -L$(JAVA_HOME)/jre/bin -ljvm PATHSEP=\; KNOWNOS=yes OSNAME=Windows JAVA=$(JAVA_HOME)/bin/java JAVAC=$(JAVA_HOME)/bin/javac JAR=$(JAVA_HOME)/bin/jar endif ifeq ($(OSKIND),Darwin) JSO_PREFIX=lib JSO_SUFFIX=.jnilib JLDFLAGS=-dynamiclib JLIBS=-framework JavaVM JCPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers PATHSEP=: KNOWNOS=yes OSNAME=MacOSX JAVA=java JAVAC=javac JAR=jar endif ifneq ($(KNOWNOS),yes) ifeq ($(JAVA_HOME),) JAVA_HOME=/usr/lib/java endif JSO_PREFIX=lib JSO_SUFFIX=.so JCPPFLAGS=-I$(JAVA_HOME)/include -I$(shell dirname `find $(JAVA_HOME)/include -name jni_md.h|sed -n -e 1p`) JLDFLAGS=-shared JLIBS=-L$(JAVA_HOME)/lib -ljvm PATHSEP=: OSNAME="generic unix" JAVA=java JAVAC=javac JAR=jar endif $(JSO_PREFIX)boot$(JSO_SUFFIX): JRIBootstrap.o $(CC) $(JLDFLAGS) -o $@ $^ #$(JLIBS) JRIBootstrap.o: JRIBootstrap.c JRIBootstrap.h $(CC) -c -o $@ $< $(JCPPFLAGS) run: boot.jar $(JAVA) -jar $< clean: rm -f JRIBootstrap.o $(JSO_PREFIX)boot$(JSO_SUFFIX) *.class *~ boot.jar: $(JSO_PREFIX)boot$(JSO_SUFFIX) $(JAVAC) -source 1.2 -target 1.2 *.java $(JAR) fcm $@ mft *.class $^ .PHONY: clean run all rJava/jri/bootstrap/JRIClassLoader.java0000644000175100001440000000614415133274032017545 0ustar hornikusersimport java.net.URLClassLoader; import java.net.URL; import java.util.HashMap; import java.util.Vector; import java.util.Enumeration; import java.io.File; public class JRIClassLoader extends URLClassLoader { HashMap libMap; Vector children; static JRIClassLoader mainLoader; public static JRIClassLoader getMainLoader() { if (mainLoader == null) mainLoader = new JRIClassLoader(); return mainLoader; } public JRIClassLoader() { super(new URL[]{}); children = new Vector(); libMap = new HashMap(); System.out.println("JRIClassLoader: new loader "+this); } public void registerLoader(DelegatedClassLoader cl) { if (!children.contains(cl)) children.add(cl); } public void unregisterLoader(DelegatedClassLoader cl) { children.removeElement(cl); } public void registerLibrary(String name, File f) { libMap.put(name, f); } /** add path to the class path list @param path string denoting the path to the file or directory */ public void addClassPath(String path) { try { File f = new File(path); if (f.exists()) addURL(f.toURL()); } catch (Exception x) {} } /** add path to the class path list @param f file/directory to add to the list */ public void addClassPath(File f) { try { if (f.exists()) addURL(f.toURL()); } catch (Exception x) {} } protected String findLibrary(String name) { String s = null; System.out.println("boot findLibrary(\""+name+"\")"); try { for (Enumeration e = children.elements() ; e.hasMoreElements() ;) { DelegatedClassLoader cl = (DelegatedClassLoader)e.nextElement(); if (cl != null) { s = cl.delegatedFindLibrary(name); if (s != null) { System.out.println(" - found delegated answer "+s+" from "+cl); return s; } } } } catch (Exception ex) {} File u = (File) libMap.get(name); if (u!=null && u.exists()) s=u.getAbsolutePath(); System.out.println(" - mapping to "+((s==null)?"":s)); return s; } public Class findAndLinkClass(String name) throws ClassNotFoundException { Class c = findClass(name); resolveClass(c); return c; } protected Class findClass(String name) throws ClassNotFoundException { Class cl = null; System.out.println("boot findClass(\""+name+"\")"); for (Enumeration e = children.elements() ; e.hasMoreElements() ;) { DelegatedClassLoader ldr = (DelegatedClassLoader)e.nextElement(); if (ldr != null) { try { cl = ldr.delegatedFindClass(name); if (cl != null) { System.out.println(" - found delegated answer "+cl+" from "+ldr); return cl; } } catch (Exception ex) {} } } return super.findClass(name); } public URL findResource(String name) { URL u = null; System.out.println("boot findResource(\""+name+"\")"); for (Enumeration e = children.elements() ; e.hasMoreElements() ;) { DelegatedClassLoader ldr = (DelegatedClassLoader)e.nextElement(); if (ldr != null) { try { u = ldr.delegatedFindResource(name); if (u != null) { System.out.println(" - found delegated answer "+u+" from "+ldr); return u; } } catch (Exception ex) {} } } return super.findResource(name); } } rJava/jri/bootstrap/mft0000644000175100001440000000002115133274032014636 0ustar hornikusersMain-Class: Boot rJava/jri/bootstrap/DelegatedURLClassLoader.java0000644000175100001440000000122715133274032021357 0ustar hornikusers/* An extension of URLClassLoader that implements DelegatedClassLoader */ import java.net.URL; import java.net.URLClassLoader; public class DelegatedURLClassLoader extends URLClassLoader implements DelegatedClassLoader { public DelegatedURLClassLoader() { super(new URL[]{}); } public DelegatedURLClassLoader(URL[] urls) { super(urls); } public String delegatedFindLibrary(String name) { return super.findLibrary(name); } public Class delegatedFindClass(String name) throws ClassNotFoundException { return super.findClass(name); } public URL delegatedFindResource(String name) { return super.findResource(name); } } rJava/jri/bootstrap/JRIBootstrap.java0000644000175100001440000003345015133274032017326 0ustar hornikusersimport java.io.File; import java.io.PrintStream; import java.io.FileOutputStream; import java.io.BufferedReader; import java.io.FileReader; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.StringTokenizer; public class JRIBootstrap { //--- global constants --- public static final int HKLM = 0; // HKEY_LOCAL_MACHINE public static final int HKCU = 1; // HKEY_CURRENT_USER //--- native methods --- public static native String getenv(String var); public static native void setenv(String var, String val); public static native String regvalue(int root, String key, String value); public static native String[] regsubkeys(int root, String key); public static native String expand(String val); public static native boolean hasreg(); public static native String arch(); //--- helper methods --- static void fail(String msg) { System.err.println("ERROR: "+msg); System.exit(1); } public static String findInPath(String path, String fn, boolean mustBeFile) { StringTokenizer st = new StringTokenizer(path, File.pathSeparator); while (st.hasMoreTokens()) { String dirname=st.nextToken(); try { File f = new File(dirname+File.separator+fn); System.out.println(" * "+f+" ("+f.exists()+", "+f.isFile()+")"); if (f.exists() && (!mustBeFile || f.isFile())) return f.getPath(); } catch (Exception fex) {} } return null; } // set ONLY after findR was run public static boolean isWin32 = false; public static boolean isMac = false; static String findR(boolean findAllSettings) { String ip = null; try { if (hasreg()) { isWin32 = true; int rroot = HKLM; System.out.println("has registry, trying to find R"); ip = regvalue(HKLM, "SOFTWARE\\R-core\\R","InstallPath"); if (ip == null) ip = regvalue(rroot=HKCU, "SOFTWARE\\R-core\\R","InstallPath"); if (ip == null) { System.out.println(" - InstallPath not present (possibly uninstalled R)"); String[] vers = regsubkeys(rroot=HKLM, "SOFTWARE\\R-core\\R"); if (vers == null) vers = regsubkeys(rroot=HKCU, "SOFTWARE\\R-core\\R"); if (vers!=null) { String lvn = ""; // FIXME: we compare versions lexicographically which may fail if we really reach R 2.10 int i = 0; while (i6) ip = s.substring(0, s.length()-6); } } if (findAllSettings) { if (f==null && ip!=null) f=new File(u2w(ip+"/bin/R")); if (f!=null) ip = getRSettings(f.getAbsolutePath()); } } catch (Exception e) { } return ip; } public static String rs_home = ""; public static String rs_arch = ""; public static String rs_docdir = ""; public static String rs_incdir = ""; public static String rs_sharedir = ""; public static String rs_ldp = ""; public static String rs_dyldp = ""; public static String rs_unzip = ""; public static String rs_latex = ""; public static String rs_paper = ""; public static String rs_print = ""; public static String rs_libs = ""; public static void setREnv() { if (rs_home!=null && rs_home.length()>0) setenv("R_HOME", rs_home); if (rs_arch!=null && rs_arch.length()>0) setenv("R_ARCH", rs_arch); if (rs_docdir!=null && rs_docdir.length()>0) setenv("R_DOC_DIR", rs_docdir); if (rs_incdir!=null && rs_incdir.length()>0) setenv("R_INCLUDE_DIR", rs_incdir); if (rs_sharedir!=null && rs_sharedir.length()>0) setenv("R_SHARE_DIR", rs_sharedir); if (rs_ldp!=null && rs_ldp.length()>0) setenv("LD_LIBRARY_PATH", rs_ldp); if (rs_dyldp!=null && rs_dyldp.length()>0) setenv("DYLD_LIBRARY_PATH", rs_dyldp); if (rs_libs!=null && rs_libs.length()>0) setenv("R_LIBS", rs_libs); } public static int execR(String cmd) { try { String binR = u2w(rs_home+"/bin/R"); if (isWin32) { binR+=".exe"; File fin = File.createTempFile("rboot",".R"); File fout = File.createTempFile("rboot",".tmp"); PrintStream p = new PrintStream(new FileOutputStream(fin)); p.println(cmd); p.close(); Process rp = Runtime.getRuntime().exec(new String[] { binR,"CMD","BATCH","--no-restore","--no-save","--slave",fin.getAbsolutePath(), fout.getAbsolutePath()}); int i = rp.waitFor(); if (!fin.delete()) fin.deleteOnExit(); if (!fout.delete()) fout.deleteOnExit(); return i; } else { Process rp = Runtime.getRuntime().exec(new String[] { "/bin/sh","-c","echo \""+cmd+"\" |"+binR+" --no-restore --no-save --slave >/dev/null 2>&1" }); return rp.waitFor(); } } catch (Exception e) { lastError = e.toString(); return -1; } } public static String getRSettings(String binR) { try { File fin = File.createTempFile("rboot",".R"); File fout = File.createTempFile("rboot",".tmp"); PrintStream p = new PrintStream(new FileOutputStream(fin)); p.println("cat(unlist(lapply(c('R_HOME','R_ARCH','R_DOC_DIR','R_INCLUDE_DIR','R_SHARE_DIR','LD_LIBRARY_PATH','DYLD_LIBRARY_PATH','R_UNZIPCMD','R_LATEXCMD','R_PAPERSIZE','R_PRINTCMD'),Sys.getenv)),sep='\n')"); p.println("cat(paste(.libPaths(),collapse=.Platform$path.sep),'\n',sep='')"); p.close(); Process rp = Runtime.getRuntime().exec(new String[] { "/bin/sh","-c",binR+" --no-restore --no-save --slave < \""+fin.getAbsolutePath()+"\" > \""+fout.getAbsolutePath()+"\"" }); int i = rp.waitFor(); System.out.println("getRSettings, i="+i); BufferedReader r = new BufferedReader(new FileReader(fout)); rs_home = r.readLine(); rs_arch = r.readLine(); rs_docdir = r.readLine(); rs_incdir = r.readLine(); rs_sharedir = r.readLine(); rs_ldp = r.readLine(); rs_dyldp = r.readLine(); rs_unzip = r.readLine(); rs_latex = r.readLine(); rs_paper = r.readLine(); rs_print = r.readLine(); rs_libs = r.readLine(); r.close(); if (!fin.delete()) fin.deleteOnExit(); //if (!fout.delete()) fout.deleteOnExit(); System.out.println(" - retrieved R settings, home: "+rs_home+" (arch="+rs_arch+", libs="+rs_libs+")"); } catch (Exception e) { System.err.println("Failed to get R settings: "+e); } return rs_home; } public static String u2w(String fn) { return (java.io.File.separatorChar != '/')?fn.replace('/',java.io.File.separatorChar):fn; } public static Object bootRJavaLoader = null; public static Object getBootRJavaLoader() { System.out.println("JRIBootstrap.bootRJavaLoader="+bootRJavaLoader); return bootRJavaLoader; } static void addClassPath(String s) { if (bootRJavaLoader==null) return; try { Method m = bootRJavaLoader.getClass().getMethod("addClassPath", new Class[] { String.class }); m.invoke(bootRJavaLoader, new Object[] { s }); } catch (Exception e) { System.err.println("FAILED: JRIBootstrap.addClassPath"); } } static String lastError = ""; static String findPackage(String name) { String pd = null; if (rs_libs!=null && rs_libs.length()>0) pd = findInPath(rs_libs, name, false); if (pd == null) { pd = u2w(rs_home+"/library/"+name); if (!(new File(pd)).exists()) pd = null; } return pd; } static Object createRJavaLoader(String rhome, String[] cp, boolean addJRI) { String rJavaRoot = null; if (rs_libs!=null && rs_libs.length()>0) rJavaRoot = findInPath(rs_libs, "rJava", false); if (rJavaRoot == null) rJavaRoot = u2w(rhome+"/library/rJava"); if (!(new File(rJavaRoot)).exists()) { lastError="Unable to find rJava"; return null; } File f = new File(u2w(rJavaRoot+"/java/boot")); if (!f.exists()) { // try harder ... lastError = "rJava too old"; return null; } String rJavaHome = u2w(rJavaRoot); File lf = null; if (rs_arch!=null && rs_arch.length()>0) lf = new File(u2w(rJavaRoot+"/libs"+rs_arch)); if (lf == null || !lf.exists()) lf = new File(u2w(rJavaRoot+"/libs/"+arch())); if (!lf.exists()) lf = new File(u2w(rJavaRoot+"/libs")); String rJavaLibs = lf.toString(); JRIClassLoader mcl = JRIClassLoader.getMainLoader(); mcl.addClassPath(f.toString()); // add rJava boot to primary CP try { // force the use of the MCL even if the system loader could find it Class rjlclass = mcl.findAndLinkClass("RJavaClassLoader"); Constructor c = rjlclass.getConstructor(new Class[] { String.class, String.class }); Object rjcl = c.newInstance(new Object[] { rJavaHome, rJavaLibs }); System.out.println("RJavaClassLoader: "+rjcl); if (addJRI) { if (cp==null || cp.length==0) cp = new String[] { u2w(rJavaRoot+"/jri/JRI.jar") }; else { String[] ncp = new String[cp.length+1]; System.arraycopy(cp, 0, ncp, 1, cp.length); ncp[0] = u2w(rJavaRoot+"/jri/JRI.jar"); cp = ncp; } } if (cp==null || cp.length==0) cp = new String[] { u2w(rJavaRoot+"/java/boot") }; else { String[] ncp = new String[cp.length+1]; System.arraycopy(cp, 0, ncp, 1, cp.length); ncp[0] = u2w(rJavaRoot+"/java/boot"); cp = ncp; } if (cp != null) { System.out.println(" - adding class paths"); Method m = rjlclass.getMethod("addClassPath", new Class[] { String[].class }); m.invoke(rjcl, new Object[] { cp }); } return rjcl; } catch (Exception rtx) { System.err.println("ERROR: Unable to create new RJavaClassLoader in JRIBootstrap! ("+rtx+")"); rtx.printStackTrace(); System.exit(2); } return null; } //--- main bootstrap method --- public static void bootstrap(String[] args) { System.out.println("JRIBootstrap("+args+")"); try { System.loadLibrary("boot"); } catch (Exception e) { fail("Unable to load boot library!"); } // just testing from now on String rhome = findR(true); if (rhome == null) fail("Unable to find R!"); if (isWin32) { String path = getenv("PATH"); if (path==null || path.length()<1) path=rhome+"\\bin"; else path=rhome+"\\bin;"+path; setenv("PATH",path); } setREnv(); System.out.println("PATH="+getenv("PATH")+"\nR_LIBS="+getenv("R_LIBS")); if (!isMac && !isWin32) { String stage = System.getProperty("stage"); if (stage==null || stage.length()<1) { File jl = new File(u2w(System.getProperty("java.home")+"/bin/java")); if (jl.exists()) { try { System.out.println(jl.toString()+" -cp "+System.getProperty("java.class.path")+" -Xmx512m -Dstage=2 Boot"); Process p = Runtime.getRuntime().exec(new String[] { jl.toString(), "-cp", System.getProperty("java.class.path"), "-Xmx512m", "-Dstage=2", "Boot" }); System.out.println("Started stage 2 ("+p+"), waiting for it to finish..."); System.exit(p.waitFor()); } catch (Exception re) { } } } } String needPkg = null; String rj = findPackage("rJava"); if (rj == null) { System.err.println("**ERROR: rJava is not installed"); if (needPkg==null) needPkg="'rJava'"; else needPkg+=",'rJava'"; } String ipl = findPackage("iplots"); if (ipl == null) { System.err.println("**ERROR: iplots is not installed"); if (needPkg==null) needPkg="'iplots'"; else needPkg+=",'iplots'"; } String jgr = findPackage("JGR"); if (jgr == null) { System.err.println("**ERROR: JGR is not installed"); if (needPkg==null) needPkg="'JGR'"; else needPkg+=",'JGR'"; } if (needPkg != null) { if (!isWin32 && !isMac) { System.err.println("*** Please run the following in R as root to install missing packages:\n install.packages(c("+needPkg+"),,'http://www.rforge.net/')"); System.exit(4); } if (execR("install.packages(c("+needPkg+"),,c('http://www.rforge.net/','http://cran.r-project.org'))")!=0) { System.err.println("*** ERROR: failed to install necessary packages"); System.exit(4); } rj = findPackage("rJava"); ipl = findPackage("iplots"); jgr = findPackage("JGR"); if (rj==null || ipl==null || jgr==null) { System.err.println("*** ERROR: failed to find installed packages"); System.exit(5); } } Object o = bootRJavaLoader = createRJavaLoader(rhome, new String[] { "main" }, true); addClassPath(u2w(jgr+"/cont/JGR.jar")); addClassPath(u2w(ipl+"/cont/iplots.jar")); String mainClass = "org.rosuda.JGR.JGR"; try { Method m = o.getClass().getMethod("bootClass", new Class[] { String.class, String.class, String[].class }); m.invoke(o, new Object[] { mainClass, "main", args }); } catch(Exception ie) { System.out.println("cannot boot the final class: "+ie); ie.printStackTrace(); } } public static void main(String[] args) { System.err.println("*** WARNING: JRIBootstrap.main should NOT be called directly, it is intended for debugging use ONLY. Use Boot wrapper instead."); // just for testing bootstrap(args); } } rJava/jri/Makefile.all0000644000175100001440000000213315133274032014325 0ustar hornikusers# JRI 0.2 (C) Simon Urbanek # This is the actual Makefile - all autconf'ed values should # be passed as vars, because we also want to use this for # the Windows build that has no autoconf # # Note: the dependencies are often across directories mainly # for historical reasons. The Java sources are actually compiled # by the Makefile in the src directory, although they are here, # because they originally belonged to src. EX_JAVA=$(wildcard examples/*.java) EX_CLASS=$(EX_JAVA:%.java=%.class) TARGETS=src/JRI.jar $(JRILIB) $(EX_CLASS) all: $(TARGETS) src/JRI.jar: $(MAKE) -C src JRI.jar src/${JRILIB}: $(MAKE) -C src $(JRILIB) $(JRILIB): src/$(JRILIB) rm -f $@ cp $< $@ examples/%.class: examples/%.java src/JRI.jar $(JAVAC) $(JFLAGS) -classpath src/JRI.jar -d examples $< clean: $(MAKE) -C src clean rm -rf $(TARGETS) *~ examples/*.class examples: $(EX_CLASS) JRI_JDOCSRC=$(wildcard *.java) doc: $(JRI_JDOCSRC) rm -rf JavaDoc mkdir JavaDoc $(JAVA)doc -d JavaDoc -author -version -breakiterator -link http://java.sun.com/j2se/1.4.2/docs/api $^ .PHONY: clean all examples doc .NOTPARALLEL: rJava/jri/configure.win0000644000175100001440000000330515133274032014620 0ustar hornikusers#!/bin/sh # if CONFIGURED is set, then we don't attempt to run findjava # (useful when building inside rJava) if [ -z "$CONFIGURED" ]; then echo "Generate Windows-specific files (src/jvm-w32) ..." make -C src/win32 if [ $? != 0 ]; then exit 1 fi echo "Find Java..." # findjava honors JAVA_HOME environment variable, so we can safely overwite it if [ -e src/win32/findjava.exe ]; then JAVA_HOME=`src/win32/findjava -s -f` R_HOME=`src/win32/findjava -R -s -f` fi fi if [ x$JAVA_HOME = x ]; then echo "ERROR: cannot find Java Development Kit." >&2 echo " Please set JAVA_HOME to specify its location manually" >&2 exit 1 fi if [ x$R_HOME = x ]; then echo "ERROR: cannot find R. Please set R_HOME correspondingly." >&2 exit 1 fi echo " JAVA_HOME=$JAVA_HOME" echo " R_HOME=$R_HOME" echo "JAVAHOME:=$JAVA_HOME" > src/Makefile.wconf echo "RHOME:=$R_HOME" >> src/Makefile.wconf if [ -e "$JAVA_HOME/bin/javah.exe" ]; then ## does the JDK have javah? echo 'JDK includes javah.exe' echo 'JAVAH=$(JAVAHOME)/bin/javah' >> src/Makefile.wconf else ## else we have to create headers during the compilation echo 'JDK has no javah.exe - using javac -h . instead' ## if this is at least 1.8 we can set source/target ## it is mandatory for 14 (and may be earlier) due to yield tgt=`"${JAVA_HOME}/bin/java" -cp tools getsp -minver 8` echo "Is the Java version at least 1.8 ... $tgt" if [ x$tgt = xyes ]; then echo 'JFLAGS=-source 1.8 -target 1.8 -h .' >> src/Makefile.wconf else echo 'JFLAGS=-h .' >> src/Makefile.wconf fi fi echo "Creating Makefiles ..." cp Makefile.win Makefile cp src/Makefile.win src/Makefile echo "Configuration done." rJava/jri/examples/0000755000175100001440000000000015133274032013735 5ustar hornikusersrJava/jri/examples/rtest.java0000644000175100001440000002033215133274032015741 0ustar hornikusersimport java.io.*; import java.awt.Frame; import java.awt.FileDialog; import java.util.Enumeration; import org.rosuda.JRI.Rengine; import org.rosuda.JRI.REXP; import org.rosuda.JRI.RList; import org.rosuda.JRI.RVector; import org.rosuda.JRI.RMainLoopCallbacks; class TextConsole implements RMainLoopCallbacks { public void rWriteConsole(Rengine re, String text, int oType) { System.out.print(text); } public void rBusy(Rengine re, int which) { System.out.println("rBusy("+which+")"); } public String rReadConsole(Rengine re, String prompt, int addToHistory) { System.out.print(prompt); try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s=br.readLine(); return (s==null||s.length()==0)?s:s+"\n"; } catch (Exception e) { System.out.println("jriReadConsole exception: "+e.getMessage()); } return null; } public void rShowMessage(Rengine re, String message) { System.out.println("rShowMessage \""+message+"\""); } public String rChooseFile(Rengine re, int newFile) { FileDialog fd = new FileDialog(new Frame(), (newFile==0)?"Select a file":"Select a new file", (newFile==0)?FileDialog.LOAD:FileDialog.SAVE); fd.show(); String res=null; if (fd.getDirectory()!=null) res=fd.getDirectory(); if (fd.getFile()!=null) res=(res==null)?fd.getFile():(res+fd.getFile()); return res; } public void rFlushConsole (Rengine re) { } public void rLoadHistory (Rengine re, String filename) { } public void rSaveHistory (Rengine re, String filename) { } } public class rtest { public static void main(String[] args) { // just making sure we have the right version of everything if (!Rengine.versionCheck()) { System.err.println("** Version mismatch - Java files don't match library version."); System.exit(1); } System.out.println("Creating Rengine (with arguments)"); // 1) we pass the arguments from the command line // 2) we won't use the main loop at first, we'll start it later // (that's the "false" as second argument) // 3) the callbacks are implemented by the TextConsole class above Rengine re=new Rengine(args, false, new TextConsole()); System.out.println("Rengine created, waiting for R"); // the engine creates R is a new thread, so we should wait until it's ready if (!re.waitForR()) { System.out.println("Cannot load R"); return; } /* High-level API - do not use RNI methods unless there is no other way to accomplish what you want */ try { REXP x; re.eval("data(iris)",false); System.out.println(x=re.eval("iris")); // generic vectors are RVector to accomodate names RVector v = x.asVector(); if (v.getNames()!=null) { System.out.println("has names:"); for (Enumeration e = v.getNames().elements() ; e.hasMoreElements() ;) { System.out.println(e.nextElement()); } } // for compatibility with Rserve we allow casting of vectors to lists RList vl = x.asList(); String[] k = vl.keys(); if (k!=null) { System.out.println("and once again from the list:"); int i=0; while (imean(iris[[1]])")); // R knows about TRUE/FALSE/NA, so we cannot use boolean[] this way // instead, we use int[] which is more convenient (and what R uses internally anyway) int[] bi = x.asIntArray(); { int i = 0; while (i to continue (time to attach the debugger if necessary)"); try { System.in.read(); } catch(Exception e) {}; System.out.println("Creating Rengine (with arguments)"); Rengine re=new Rengine(args, true, new TextConsole2()); System.out.println("Rengine created, waiting for R"); if (!re.waitForR()) { System.out.println("Cannot load R"); return; } System.out.println("re-routing stdout/err into R console"); System.setOut(new PrintStream(new RConsoleOutputStream(re, 0))); System.setErr(new PrintStream(new RConsoleOutputStream(re, 1))); System.out.println("Letting go; use main loop from now on"); } } rJava/jri/LGPL.txt0000644000175100001440000005750615133274032013433 0ustar hornikusers GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS rJava/jri/version0000755000175100001440000000023315133274032013530 0ustar hornikusers#!/bin/sh VER=`awk -v ORS= '/JRI v/ { print substr($6,2) }' src/jri.h` if test "$1" == "-f"; then echo "JRI_${VER}.tar.gz" else echo "${VER}" fi rJava/jri/Makefile.win0000644000175100001440000000055415133274032014357 0ustar hornikusers# Windows-specific part of the Makefile include src/Makefile.wconf include Makevars.win windows.all: all run.bat $(RHOME)/src/gnuwin32/libR.a: make -C $(RHOME)/src/gnuwin32 libR.a run.bat: jri.dll echo "set PATH=%PATH%;$(RHOME)\\bin;$(RHOME)\\lib" > run.bat echo "$(JAVA_PROG) -cp .;examples;JRI.jar;src/JRI.jar rtest \$$*" >> run.bat include Makefile.all rJava/jri/RBool.java0000644000175100001440000000202615133274032013777 0ustar hornikuserspackage org.rosuda.JRI; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- /** Implementation of tri-state logical data type in R. The three states are TRUE, FALSE and NA. To obtain truly boolean value, you'll need to use {@link #isTRUE} or {@link #isFALSE} since there is no canonical representation of RBool in boolean @version $Id: RBool.java 2720 2007-03-15 17:35:42Z urbanek $ */ public class RBool extends Object { int val; public RBool(boolean b) { val=(b)?1:0; }; public RBool(RBool r) { val=r.val; }; public RBool(int i) { /* 0=FALSE, 2=NA, anything else = TRUE */ val=(i==0||i==2)?i:1; }; public boolean isNA() { return (val==2); }; public boolean isTRUE() { return (val==1); }; public boolean isFALSE() { return (val==0); }; public String toString() { return (val==0)?"FALSE":((val==2)?"NA":"TRUE"); }; } rJava/jri/run.in0000644000175100001440000000132415133274032013253 0ustar hornikusers#!/bin/sh R_HOME=@R_HOME@ R_SHARE_DIR=@R_SHARE_DIR@ export R_SHARE_DIR R_INCLUDE_DIR=@R_INCLUDE_DIR@ export R_INCLUDE_DIR R_DOC_DIR=@R_DOC_DIR@ export R_DOC_DIR JRI_LD_PATH=${R_HOME}/lib:${R_HOME}/bin:@JAVA_LD_PATH@ if test -z "$LD_LIBRARY_PATH"; then LD_LIBRARY_PATH=$JRI_LD_PATH else LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JRI_LD_PATH fi JAVA=@JAVA_PROG@ : ${CLASSPATH=.:examples} export R_HOME export LD_LIBRARY_PATH if [ -z "$1" ]; then echo "" echo " Usage: run [...]" echo "" echo " For example: ./run rtest" echo " Set CLASSPATH variable if other than .:examples is desired" echo "" else ${JAVA} -Djava.library.path=.:@JAVA_LD_PATH@ -cp ${CLASSPATH}:src/JRI.jar:JRI.jar $* fi rJava/jri/NEWS0000644000175100001440000001112315133274032012614 0ustar hornikusers NEWS/ChangeLog for JRI -------------------------- 0.5-5 (under development) o fix compilation in parallel using the -j switch for GNU Make o some more Win64 fixes 0.5-4 2010-09-17 o added more options to rniStop() on unix and changed the default to use interrupt flags instead of signals since signals cause problems in some JVM implmentations. The previous behavior can be achieved by rniStop(1). 0.5-3 2010-09-02 o fixed changed by the Win64 support which broke some other OSes by using sign extension when converting to long storage. o avoid the use of the sign of pointers for signaling. Note that rniEval() now returns 0 on error and not -1 or -2. The old behavior was undocumented (and dangerous) and thus should not be relied upon. (fixes #172) 0.5-2 2010-04-28 o fixed handling of NAs in strings - they are now correctly converted to s on the Java side. IMPORTANT: previously NAs would come as the string "NA" from R which is incorrect since it is not distinguishable from a literal "NA" string. Code that deals with NAs must be prepared to receive nulls in string arrays (note that nulls where correctly converted to NA string, it's just that incoming string were not converted). (Thanks to Stephan Wahlbrink for pointing out the inconsistency) o multiple fixes to Windows support: common command line arguments are now correctly processed, sub-architectures are supported, Win64 is now also supported 0.5-1 2010-03-16 o API 1.10: rniAssign now returns boolean to denote success/failure o numerous bug fixes and additions 0.5-0 2009-08-22 o API 1.9: added rniPreserve, rniRelease, rniParentEnv, rniFindVar, rniListEnv, rniSpecialObject, rniPrintValue, rniGetRawArray, rniPutRawArray, rniGetAttrNames methods added jriLoaded field (boolean) o new REngine-based API (org.rosuda.REngine.JRI.JRIEngine) has been created - this allows the same code to interface JRI or Rserve without re-compilation Note: the JAR files are currently shipped separately from the JRI installation and can be obtained from http://rforge.net/JRI/files/ o proxy references are now preserved until finalized o if jri.ignore.ule=yes property is set, JRI will not abort on failing to load the JRI library (UnsatisfiedLinkException). This can be used by GUIs to display a more meaningful message instead of abort. The jriLoaded flag is false in that case. 0.4-2 o declare string encoding as UTF-8 and convert incoming strings to UTF-8 if possible (R >= 2.7.0 required). 0.4-1 (part of rJava 0.5-1 and later) o fixed configuration to work with multi-arch builds 0.4-0 2007-08-22 (part of rJava 0.5-0) o adapt to changes in R-devel o add -I. to CFLAGS for compatibility (thanks to BDR) o added RConsoleOuputStream class o API 1.8: added rniPrint, added int oType parameter to the rWriteConsole callback o work around broken MinGW runtimes o allow JRI to hook into a running R process (and thusly provide rJava with callbacks) o added: inMainRThread(), isStandAlone() o include configure in SVN and don't rebuild it on mkdist 0.3-7 2006-01-14 o make sure rniJavaToXref creates a global reference o API 1.7: rniCons can accept two new arguments: tag and lang rniLCons was added o assign now supports raw REXPs (XT_NONE) o createRJavaRef was added to create jobjRef R objects from Java objects 0.3-6 2006-11-29 o adapted to API change in R-devel o fixed double-inclusion of JFLAGS which throws off GIJ 0.3-5 2006-10-06 o remove variadic macros to be compatible with compilers that don't support C99 0.3-4 2006-09-14 o updated Makefiles to force 1.4 target and sources 0.3-3 2006-09-12 o fixed API version in Java sources and added version check to examples 0.3-2 2006-09-11 o New API (1.6): add handling of boolean type 0.3-1 2006-08-31 0.3-0 2006-05-31 o New API (1.5) entries: rniGetTAG, rniInherits, rniGetSymbolName, rniInstallName allows handling of symbols, named lists and inheritance o fixed/improved REXP, RList and RFactor 0.2-5 2006-05-08 o Use configure to detect CStackXXX and R_SignalHandlers set the latter to 0 if present (solves threading issues) 0.2-4 2006-05-03 o added support for pre-configuration passed from rJava 0.2-3 2006-04-20 o fix warnings and issues with R 2.3.0 0.2-2 2006-04-11 o licensed under LGPL 0.2-1 2006-03-07 o fixed Java detection, fixed eval double-unlock, use R shlib flags, added FreeBSD support 0.2-0 2005-12-19 o switched to autoconf process for configuration/installation 0.1-0 o First JRI release rJava/jri/REngine/0000755000175100001440000000000015133274037013453 5ustar hornikusersrJava/jri/REngine/REngine.java0000644000175100001440000003024215133274032015641 0ustar hornikuserspackage org.rosuda.REngine; import java.lang.reflect.Method; /** REngine is an abstract base class for all implementations of R engines. Subclasses can implement interfaces to R in many different ways. Clients should always use methods this class instead of its direct subclasses in order to maintian compatibility with any R engine implementation. The canonical way of obtaining a new engine is to call {@link #engineForClass}. All subclasses must implement createEngine() method. */ public abstract class REngine { /** last created engine or null if there is none */ protected static REngine lastEngine = null; /** this is the designated constructor for REngine classes. It uses reflection to call createEngine method on the given REngine class. @param klass fully qualified class-name of a REngine implementation @return REngine implementation or null if createEngine invokation failed */ public static REngine engineForClass(String klass) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, java.lang.reflect.InvocationTargetException { Class cl=Class.forName(klass); if (cl==null) throw(new ClassNotFoundException("can't find engine class "+klass)); Method m=cl.getMethod("createEngine",(Class[])null); Object o=m.invoke(null,(Object[])null); return lastEngine=(REngine)o; } /** This is the extended constructor for REngine classes. It uses reflection to call createEngine method on the given REngine class with some additional control over the engine. Note that not all engines may support the extended version. @param klass fully qualified class-name of a REngine implementation @param args arguments to pass to R for initialization @param callbacks delegate for REngine callbacks or null if callbacks won't be serviced (engine may not support callbacks) @param runREPL if true then REPL will be started (if supported by the engine) @return REngine implementation or null if createEngine invokation failed */ public static REngine engineForClass(String klass, String[] args, REngineCallbacks callbacks, boolean runREPL) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, java.lang.reflect.InvocationTargetException { Class cl = Class.forName(klass); if (cl == null) throw new ClassNotFoundException("can't find engine class " + klass); Method m = cl.getMethod("createEngine", new Class[] { String[].class, REngineCallbacks.class, Boolean.TYPE }); Object o = m.invoke(null, new Object[] { args, callbacks, Boolean.valueOf(runREPL) }); return lastEngine = (REngine)o; } /** retrieve the last created engine @return last created engine or null if no engine was created yet */ public static REngine getLastEngine() { return lastEngine; } /** parse a string into an expression vector @param text string to parse @param resolve resolve the resulting REXP (true) or just return a reference (false) @return parsed expression */ public abstract REXP parse(String text, boolean resolve) throws REngineException; /** evaluate an expression vector @param what an expression (or vector of such) to evaluate @param where environment to evaluate in (use null for the global environemnt and/or if environments are not supported by the engine) @param resolve resolve the resulting REXP or just return a reference @return the result of the evaluation of the last expression */ public abstract REXP eval(REXP what, REXP where, boolean resolve) throws REngineException, REXPMismatchException; /** assign into an environment @param symbol symbol name @param value value to assign @param env environment to assign to (use null for the global environemnt and/or if environments are not supported by the engine) */ public abstract void assign(String symbol, REXP value, REXP env) throws REngineException, REXPMismatchException; /** get a value from an environment @param symbol symbol name @param env environment (use null for the global environemnt and/or if environments are not supported by the engine) @param resolve resolve the resulting REXP or just return a reference @return value */ public abstract REXP get(String symbol, REXP env, boolean resolve) throws REngineException, REXPMismatchException; /** fetch the contents of the given reference. The resulting REXP may never be REXPReference. The engine should raise a {@link #REngineException} exception if {@link #supportsReferences()} returns false. @param ref reference to resolve @return resolved reference */ public abstract REXP resolveReference(REXP ref) throws REngineException, REXPMismatchException; /** create a reference by pushing local data to R and returning a reference to the data. If ref is a reference it is returned as-is. The engine should raise a {@link #REngineException} exception if {@link #supportsReferences()} returns false. @param value to create reference to @return reference to the value */ public abstract REXP createReference(REXP value) throws REngineException, REXPMismatchException; /** removes reference from the R side. This method is called automatically by the finalizer of REXPReference and should never be called directly. @param ref reference to finalize */ public abstract void finalizeReference(REXP ref) throws REngineException, REXPMismatchException; /** get the parent environemnt of an environemnt @param env environment to query @param resolve whether to resolve the resulting environment reference @return parent environemnt of env */ public abstract REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException, REXPMismatchException; /** create a new environemnt @param parent parent environment @param resolve whether to resolve the reference to the environemnt (usually false since the returned environment will be empty) @return resulting environment */ public abstract REXP newEnvironment(REXP parent, boolean resolve) throws REngineException, REXPMismatchException; /** convenince method equivalent to eval(parse(text, false), where, resolve); @param text to parse (see {@link #parse}) @param where environment to evaluate in (see {@link #eval}) @param resolve whether to resolve the resulting reference or not (see {@link #eval}) @return result */ public REXP parseAndEval(String text, REXP where, boolean resolve) throws REngineException, REXPMismatchException { REXP p = parse(text, false); return eval(p, where, resolve); } /** convenince method equivalent to eval(parse(cmd, false), null, true); @param cmd expression to parse (see {@link #parse}) @return result */ public REXP parseAndEval(String cmd) throws REngineException, REXPMismatchException { return parseAndEval(cmd, null, true); }; /** performs a close operation on engines that support it. The engine may not be used after close() returned true. This operation is optional and will always return false if not implemented. @return true if the close opetaion was successful, false otherwise. */ public boolean close() { return false; } //--- capabilities --- /** check whether this engine supports references to R objects @return true if this engine supports references, false/code> otherwise */ public boolean supportsReferences() { return false; } /** check whether this engine supports handing of environments (if not, {@link #eval} and {@link #assign} only support the global environment denoted by null). @return true if this engine supports environments, false/code> otherwise */ public boolean supportsEnvironments() { return false; } /** check whether this engine supports REPL (Read-Evaluate-Print-Loop) and corresponding callbacks. @return true if this engine supports REPL, false/code> otherwise */ public boolean supportsREPL() { return false; } /** check whether this engine supports locking ({@link #lock}, {@link #tryLock} and {@link #unlock}). @return true if this engine supports REPL, false/code> otherwise */ public boolean supportsLocking() { return false; } //--- convenience methods --- (the REXPMismatchException catches should be no-ops since the value type is guaranteed in the call to assign) /** convenience method equivalent to assign(symbol, new REXPDouble(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, double[] d) throws REngineException { try { assign(symbol, new REXPDouble(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,double[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPInteger(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, int[] d) throws REngineException { try { assign(symbol, new REXPInteger(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,int[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPString(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, String[] d) throws REngineException { try { assign(symbol, new REXPString(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,String[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPRaw(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d values to assign */ public void assign(String symbol, byte[] d) throws REngineException { try { assign(symbol, new REXPRaw(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,byte[]): "+e)); } } /** convenience method equivalent to assign(symbol, new REXPString(d), null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param d value to assign */ public void assign(String symbol, String d) throws REngineException { try { assign(symbol, new REXPString(d), null); } catch (REXPMismatchException e) { throw(new REngineException(this, "REXPMismatchException in assign(,String[]): "+e)); } } /** convenience method equivalent to assign(symbol, value, null) (see {@link #assign(String, REXP, REXP)}) @param symbol symbol name to assign to @param value values to assign */ public void assign(String symbol, REXP value) throws REngineException, REXPMismatchException { assign(symbol, value, null); } //--- locking API --- /** attempts to obtain a lock for this R engine synchronously (without waiting for it).
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, always returns 0. @return 0 if the lock could not be obtained (R engine is busy) and some other value otherwise -- the returned value must be used in a matching call to {@link #unlock(int)}. */ public synchronized int tryLock() { return 0; } /** obtains a lock for this R engine, waiting until it becomes available.
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, always returns 0. @return value that must be passed to {@link #unlock} in order to release the lock */ public synchronized int lock() { return 0; } /** releases a lock previously obtained by {@link #lock()} or {@link #tryLock()}.
Note: check for {@link #supportsLocking()} before relying on this capability. If not implemented, has no effect. @param lockValue value returned by {@link #lock()} or {@link #tryLock()}. */ public synchronized void unlock(int lockValue) {} public String toString() { return super.toString()+((lastEngine==this)?"{last}":""); } public REXP wrap(Object o){ return REXPWrapper.wrap(o); } } rJava/jri/REngine/pom.xml0000644000175100001440000001016115133274032014762 0ustar hornikusers 4.0.0 org.rosuda.REngine REngine REngine Java interface to R REngine API to access R from Java in a backend-independent way. 2.1.1-SNAPSHOT http://github.com/s-u/REngine UTF-8 LGPL v2.1 https://www.gnu.org/licenses/lgpl-2.1.txt Simon Urbanek simon.urbanek@R-project.org scm:git:https://github.com/s-u/REngine.git scm:git:git@github.com:s-u/REngine.git https://github.com/s-u/REngine junit junit 4.13.1 test exec-maven-plugin org.codehaus.mojo 1.3.2 create mvn structure generate-sources exec ${basedir}/mkmvn.sh org.apache.maven.plugins maven-compiler-plugin 3.2 ${target.version} ${target.version} target-1.4 true 1.4 target-1.6 [9,12) 1.6 target-1.7 [12,20) 1.7 release org.apache.maven.plugins maven-gpg-plugin 1.6 sign-artifacts verify sign org.apache.maven.plugins maven-javadoc-plugin 2.10.2 attach-javadocs jar org.apache.maven.plugins maven-source-plugin 2.4 attach-sources jar-no-fork ossrh https://oss.sonatype.org/content/repositories/snapshots ossrh https://oss.sonatype.org/service/local/staging/deploy/maven2/ rJava/jri/REngine/REXPString.java0000644000175100001440000000270215133274032016257 0ustar hornikuserspackage org.rosuda.REngine; /** REXPString represents a character vector in R. */ public class REXPString extends REXPVector { /** payload */ private String[] payload; /** create a new character vector of the length one * @param load first (and only) element of the vector */ public REXPString(String load) { super(); payload=new String[] { load }; } /** create a new character vector * @param load string elements of the vector */ public REXPString(String[] load) { super(); payload=(load==null)?new String[0]:load; } /** create a new character vector with attributes * @param load string elements of the vector * @param attr attributes */ public REXPString(String[] load, REXPList attr) { super(attr); payload=(load==null)?new String[0]:load; } public int length() { return payload.length; } public boolean isString() { return true; } public Object asNativeJavaObject() { return payload; } public String[] asStrings() { return payload; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i]==null); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append("\""+payload[i]+"\""); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } rJava/jri/REngine/REXPRaw.java0000644000175100001440000000151415133274032015542 0ustar hornikuserspackage org.rosuda.REngine; /** REXPRaw represents a raw vector in R - essentially a sequence of bytes. */ public class REXPRaw extends REXPVector { private byte[] payload; /** create a new raw vector with the specified payload * @param load payload of the raw vector */ public REXPRaw(byte[] load) { super(); payload=(load==null)?new byte[0]:load; } /** create a new raw vector with the specified payload and attributes * @param load payload of the raw vector * @param attr attributes for the resulting R object */ public REXPRaw(byte[] load, REXPList attr) { super(attr); payload=(load==null)?new byte[0]:load; } public int length() { return payload.length; } public boolean isRaw() { return true; } public byte[] asBytes() { return payload; } public Object asNativeJavaObject() { return payload; } } rJava/jri/REngine/REXPJavaReference.java0000644000175100001440000000164215133274032017513 0ustar hornikuserspackage org.rosuda.REngine; /** REXPJavaReference is a reference to a Java object that has been resolved from is R wrapper. Note that not all engines support references. */ public class REXPJavaReference extends REXP { /** the referenced Java object */ Object object; /** creates a new Java reference R object * @param o Java object referenced by the REXP */ public REXPJavaReference(Object o) { super(); this.object = o; } /** creates a new Java reference R object * @param o Java object referenced by the REXP * @param attr attributes (of the R wrapper) */ public REXPJavaReference(Object o, REXPList attr) { super(attr); this.object = o; } /** returns the Java object referenced by this REXP * @return Java object */ public Object getObject() { return object; } public Object asNativeJavaObject() { return object; } public String toString() { return super.toString() + "[" + object + "]"; } } rJava/jri/REngine/REXPVector.java0000644000175100001440000000165615133274032016262 0ustar hornikuserspackage org.rosuda.REngine; /** abstract class representing all vectors in R */ public abstract class REXPVector extends REXP { public REXPVector() { super(); } public REXPVector(REXPList attr) { super(attr); } /** returns the length of the vector (i.e. the number of elements) * @return length of the vector */ public abstract int length(); public boolean isVector() { return true; } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values * @return a boolean vector of the same length as this vector with true for NA values and false for any other values */ public boolean[] isNA() { boolean a[] = new boolean[length()]; return a; } public String toString() { return super.toString()+"["+length()+"]"; } public String toDebugString() { return super.toDebugString()+"["+length()+"]"; } } rJava/jri/REngine/REXPReference.java0000644000175100001440000000730315133274032016711 0ustar hornikuserspackage org.rosuda.REngine; /** this class represents a reference (proxy) to an R object.

The reference semantics works by calling {@link #resolve()} (which in turn uses {@link REngine#resolveReference(REXP)} on itself) whenever any methods are accessed. The implementation is not finalized yat and may change as we approach the JRI interface which is more ameanable to reference-style access. Subclasses are free to implement more efficient implementations. */ public class REXPReference extends REXP { /** engine which will be used to resolve the reference */ protected REngine eng; /** an opaque (optional) handle */ protected Object handle; /** resolved (cached) object */ protected REXP resolvedValue; /** create an external REXP reference using given engine and handle. The handle value is just an (optional) identifier not used by the implementation directly. */ public REXPReference(REngine eng, Object handle) { super(); this.eng = eng; this.handle = handle; } /** shortcut for REXPReference(eng, new Long(handle)) that is used by native code */ REXPReference(REngine eng, long handle) { this(eng, Long.valueOf(handle)); } /** resolve the external REXP reference into an actual REXP object. In addition, the value (if not null) will be cached for subsequent calls to resolve until invalidate is called. */ public REXP resolve() { if (resolvedValue != null) return resolvedValue; try { resolvedValue = eng.resolveReference(this); return resolvedValue; } catch (REXPMismatchException me) { // this should never happen since we are REXPReference } catch(REngineException ee) { // FIXME: what to we do? } return null; } /** invalidates any cached representation of the reference */ public void invalidate() { resolvedValue = null; } /** finalization that notifies the engine when a reference gets collected */ protected void finalize() throws Throwable { try { eng.finalizeReference(this); } finally { super.finalize(); } } // type checks public boolean isString() { return resolve().isString(); } public boolean isNumeric() { return resolve().isNumeric(); } public boolean isInteger() { return resolve().isInteger(); } public boolean isNull() { return resolve().isNull(); } public boolean isFactor() { return resolve().isFactor(); } public boolean isList() { return resolve().isList(); } public boolean isLogical() { return resolve().isLogical(); } public boolean isEnvironment() { return resolve().isEnvironment(); } public boolean isLanguage() { return resolve().isLanguage(); } public boolean isSymbol() { return resolve().isSymbol(); } public boolean isVector() { return resolve().isVector(); } public boolean isRaw() { return resolve().isRaw(); } public boolean isComplex() { return resolve().isComplex(); } public boolean isRecursive() { return resolve().isRecursive(); } public boolean isReference() { return true; } // basic accessor methods public String[] asStrings() throws REXPMismatchException { return resolve().asStrings(); } public int[] asIntegers() throws REXPMismatchException { return resolve().asIntegers(); } public double[] asDoubles() throws REXPMismatchException { return resolve().asDoubles(); } public RList asList() throws REXPMismatchException { return resolve().asList(); } public RFactor asFactor() throws REXPMismatchException { return resolve().asFactor(); } public int length() throws REXPMismatchException { return resolve().length(); } public REXPList _attr() { return resolve()._attr(); } public Object getHandle() { return handle; } public REngine getEngine() { return eng; } public String toString() { return super.toString()+"{eng="+eng+",h="+handle+"}"; } } rJava/jri/REngine/REngineException.java0000644000175100001440000000240015133274032017513 0ustar hornikusers// REngine - generic Java/R API // // Copyright (C) 2006 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RSrvException.java // // Created by Simon Urbanek on Wed Jun 21 2006. // // $Id$ // package org.rosuda.REngine; /** REngineException is a generic exception that can be thrown by methods invoked on an R engine. */ public class REngineException extends Exception { /** engine associated with this exception */ protected REngine engine; /** creates an R engine exception @param engine engine associated with this exception @param msg message describing the cause @param cause original cause if this is a chained exception */ public REngineException(REngine engine, String msg, Throwable cause) { super(msg, cause); this.engine = engine; } /** creates an R engine exception @param engine engine associated with this exception @param msg message describing the cause */ public REngineException(REngine engine, String msg) { super(msg); this.engine = engine; } /** returns the engine associated with this exception @return engine associated with this exception */ public REngine getEngine() { return engine; } } rJava/jri/REngine/Makefile0000644000175100001440000000212115133274037015107 0ustar hornikusersRENG_SRC=$(wildcard *.java) RSRV_SRC=$(wildcard Rserve/*.java) $(wildcard Rserve/protocol/*.java) JRI_SRC=$(wildcard JRI/*.java) TARGETS=REngine.jar Rserve.jar all: $(TARGETS) JAVAC=javac JAVADOC=javadoc JDFLAGS=-author -version -breakiterator -link http://java.sun.com/j2se/1.4.2/docs/api/ JFLAGS+=-source 1.6 -target 1.6 REngine.jar: $(RENG_SRC) @rm -rf org $(JAVAC) -d . $(JFLAGS) $(RENG_SRC) jar fc $@ org rm -rf org Rserve.jar: $(RSRV_SRC) REngine.jar @rm -rf org $(JAVAC) -d . -cp REngine.jar $(RSRV_SRC) jar fc $@ org rm -rf org clean: rm -rf org *~ $(TARGETS) doc make -C Rserve clean make -C JRI clean test: make -C Rserve test rc: Rserve.jar Rserve/test/jt.java make -C Rserve/test jt doc: $(RENG_SRC) $(RSRV_SRC) $(JRI_SRC) rm -rf $@ mkdir $@ $(JAVADOC) -d $@ $(JDFLAGS) $^ mvn.pkg: mvn -B clean package install && (cd Rserve && mvn -B clean package) mvn.sign: mvn clean verify install -P release && (cd Rserve && mvn clean verify -P release ) mvn.deploy: mvn clean deploy install -P release && (cd Rserve && mvn clean deploy -P release ) .PHONY: clean all test rJava/jri/REngine/REXPLogical.java0000644000175100001440000001251715133274032016370 0ustar hornikuserspackage org.rosuda.REngine; /** REXPLogical represents a vector of logical values (TRUE, FALSE or NA). Unlike Java's boolean type R's logicals support NA values therefore either of {@link #isTRUE()}, {@link #isFALSE()} or {@link #isNA()} must be used to convert logicals to boolean values. */ public class REXPLogical extends REXPVector { protected byte[] payload; /** NA integer value as defined in R. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(int) } is provided for consistency. */ static final int NA_internal = -2147483648; /** NA boolean value as used in REXPLogical implementation. This differs from the value used in R since R uses int data type and we use byte. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(byte) } is provided for consistency. */ public static final byte NA = -128; public static final byte TRUE = 1; public static final byte FALSE = 0; public static boolean isNA(byte value) { return (value == NA); } /** create logical vector of the length 1 with the given value as its first (and only) element */ public REXPLogical(boolean load) { super(); payload = new byte[] { load ? TRUE : FALSE }; } /** create logical vector of the length 1 with the given value as its first (and only) element */ public REXPLogical(byte load) { super(); payload = new byte[] { load }; } /** create logical vector with the payload specified by load */ public REXPLogical(byte[] load) { super(); payload = (load==null) ? new byte[0]:load; } /** create logical vector with the payload specified by load */ public REXPLogical(boolean[] load) { super(); payload = new byte[(load == null) ? 0 : load.length]; if (load != null) for (int i = 0; i < load.length; i++) payload[i] = load[i] ? TRUE : FALSE; } /** create integer vector with the payload specified by load and attributes attr */ public REXPLogical(byte[] load, REXPList attr) { super(attr); payload = (load==null) ? new byte[0] : load; } /** create integer vector with the payload specified by load and attributes attr */ public REXPLogical(boolean[] load, REXPList attr) { super(attr); payload = new byte[(load == null) ? 0 : load.length]; if (load != null) for (int i = 0; i < load.length; i++) payload[i] = load[i] ? TRUE : FALSE; } public int length() { return payload.length; } public boolean isLogical() { return true; } public Object asNativeJavaObject() { return payload; } public int[] asIntegers() { int p[] = new int[payload.length]; for (int i = 0; i < payload.length; i++) // map bytes to integers including NA representation p[i] = (payload[i] == NA) ? REXPInteger.NA : ((payload[i] == FALSE) ? 0 : 1); return p; } public byte[] asBytes() { return payload; } /** returns the contents of this vector as doubles */ public double[] asDoubles() { double[] d = new double[payload.length]; for (int i = 0; i < payload.length; i++) d[i] = (payload[i] == NA) ? REXPDouble.NA : ((payload[i] == FALSE) ? 0.0 : 1.0); return d; } /** returns the contents of this vector as strings */ public String[] asStrings() { String[] s = new String[payload.length]; for (int i = 0; i < payload.length; i++) s[i] = (payload[i] == NA) ? "NA" : ((payload[i] == FALSE) ? "FALSE" : "TRUE"); return s; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] == NA); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for TRUE values and false for FALSE and NA values. @return boolean array */ public boolean[] isTRUE() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] != NA && payload[i] != FALSE); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for FALSE values and false for TRUE and NA values. @return boolean array */ public boolean[] isFALSE() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i] == FALSE); i++; } return a; } /** returns a boolean array of the same langth as the receiver with true for TRUE values and false for FALSE and NA values. @return boolean array @deprecated replaced by {@link #isTRUE()} for consistency with R nomenclature. */ public boolean[] isTrue() { return isTRUE(); } /** returns a boolean array of the same langth as the receiver with true for FALSE values and false for TRUE and NA values. @return boolean array @deprecated replaced by {@link #isTRUE()} for consistency with R nomenclature. */ public boolean[] isFalse() { return isFALSE(); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append((payload[i] == NA) ? "NA" : ((payload[i] == FALSE) ? "FALSE" : "TRUE")); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } rJava/jri/REngine/REXPWrapper.java0000644000175100001440000001614415133274032016436 0ustar hornikuserspackage org.rosuda.REngine ; /** * Utility class to wrap an Object into a REXP object. * * This facilitates wrapping native java objects and arrays * into REXP objects that can be pushed to R * * @author Romain Francois */ public class REXPWrapper { /* various classes */ private static Class byte_ARRAY ; private static Class short_ARRAY ; private static Class int_ARRAY ; private static Class long_ARRAY ; private static Class float_ARRAY ; private static Class double_ARRAY ; private static Class boolean_ARRAY ; private static Class String_ARRAY ; private static Class Byte_ARRAY ; private static Class Short_ARRAY; private static Class Integer_ARRAY ; private static Class Long_ARRAY ; private static Class Float_ARRAY ; private static Class Double_ARRAY ; private static Class Boolean_ARRAY ; static{ try{ byte_ARRAY = Class.forName("[B") ; short_ARRAY = Class.forName("[S" ); int_ARRAY = Class.forName("[I" ); long_ARRAY = (new long[1]).getClass() ; /* FIXME */ float_ARRAY = Class.forName("[F" ) ; double_ARRAY = Class.forName("[D" ); boolean_ARRAY = Class.forName("[Z" ) ; String_ARRAY = Class.forName( "[Ljava.lang.String;") ; Byte_ARRAY = Class.forName( "[Ljava.lang.Byte;" ) ; Short_ARRAY = Class.forName( "[Ljava.lang.Short;" ) ; Integer_ARRAY = Class.forName( "[Ljava.lang.Integer;" ) ; Long_ARRAY = Class.forName( "[Ljava.lang.Long;" ) ; Float_ARRAY = Class.forName( "[Ljava.lang.Float;" ) ; Double_ARRAY = Class.forName( "[Ljava.lang.Double;" ) ; Boolean_ARRAY = Class.forName( "[Ljava.lang.Boolean;" ) ; } catch( Exception e){ // should never happen e.printStackTrace(); System.err.println( "problem while initiating the classes" ) ; } } /** * Wraps an Object into a REXP * *

Conversion :

* *
    *
  • Byte (byte) : REXPRaw
  • *
  • Short (short) : REXPInteger
  • *
  • Integer (int) : REXPInteger
  • *
  • Long (long) : REXPInteger
  • *
  • Float (float) : REXPDouble
  • *
  • Double (double) : REXPDouble
  • *
  • Boolean (boolean) : REXPLogical
  • *
  • --
  • *
  • String : REXPString
  • *
  • String[] : REXPString
  • *
  • --
  • *
  • byte[] or Byte[] : REXPRaw
  • *
  • short[] or Short[] : REXPInteger
  • *
  • int[] or Integer[] : REXPInteger
  • *
  • long[] or Long[] : REXPInteger
  • *
  • float[] or Float[] : REXPDouble
  • *
  • double[] or Double[] : REXPDouble
  • *
  • boolean[] or Boolean[]: REXPLogical
  • *
  • --
  • *
  • null for anything else
  • *
* * @param o object to wrap * @return REXP object that represents o or null if the conversion is not possible */ public static REXP wrap( Object o ) { /* nothing to do in that case */ if( o instanceof REXP){ return (REXP)o; } Class clazz = o.getClass() ; /* primitives */ if( clazz == Byte.class ){ byte[] load = new byte[1]; load[0] = ((Byte)o).byteValue() ; return new REXPRaw( load ); } if( clazz == Short.class ){ return new REXPInteger( ((Short)o).intValue() ) ; } if( clazz == Integer.class ){ return new REXPInteger( ((Integer)o).intValue() ) ; } if( clazz == Long.class ){ return new REXPInteger( ((Long)o).intValue() ) ; } if( clazz == Float.class ){ return new REXPDouble( ((Float)o).doubleValue() ) ; } if( clazz == Double.class ){ return new REXPDouble( ((Double)o).doubleValue() ) ; } if( clazz == Boolean.class ){ return new REXPLogical( ((Boolean)o).booleanValue() ) ; } /* Strings -> REXPString */ if( clazz == String.class ){ return new REXPString( (String)o ) ; } if( clazz == String_ARRAY ){ /* String[] */ return new REXPString( (String[])o ); } /* array of byte or Bytes -> REXPRaw */ if( clazz == byte_ARRAY ){ /* byte[] */ return new REXPRaw( (byte[])o ) ; } if( clazz == Byte_ARRAY ){ /* Byte[] */ Byte[] b = (Byte[])o; int n = b.length ; byte[] bytes = new byte[b.length]; for( int i=0; i REXPInteger */ if( clazz == short_ARRAY ){ /* short[] */ short[] shorts = (short[])o ; int[] ints = new int[ shorts.length ]; int n = ints.length; for( int i=0; i REXPInteger */ if( clazz == int_ARRAY ){ /* int[] */ return new REXPInteger( (int[])o ) ; } if( clazz == Integer_ARRAY ){ /* Integer[] */ Integer[] integers = (Integer[])o; int n = integers.length ; int[] ints = new int[integers.length]; for( int i=0; i REXPInteger */ if( clazz == long_ARRAY ){ /* long[] */ long[] longs = (long[])o; int n = longs.length ; int[] ints = new int[longs.length]; for( int i=0; i REXPDouble */ if( clazz == float_ARRAY ){ /* float[] */ float[] floats = (float[])o; int n = floats.length ; double[] doubles = new double[floats.length]; for( int i=0; i REXPDouble */ if(clazz == double_ARRAY ) { /* double[] */ return new REXPDouble( (double[])o ) ; } if( clazz == Double_ARRAY ){ /* Double[] */ Double[] doubles = (Double[])o; double n = doubles.length ; double[] d = new double[doubles.length]; for( int i=0; i REXPLogical */ if( clazz == boolean_ARRAY ){ /* boolean[] */ return new REXPLogical( (boolean[])o ) ; } if( clazz == Boolean_ARRAY ){ /* Boolean[] */ Boolean[] booleans = (Boolean[])o; int n = booleans.length ; boolean[] b = new boolean[booleans.length]; for( int i=0; i"names"
attribute is created automatically from it. * @param list list to create the vector from */ public REXPGenericVector(RList list) { super(); payload=(list==null)?new RList():list; // automatically generate 'names' attribute if (payload.isNamed()) attr = new REXPList( new RList(new REXP[] { new REXPString(payload.keys()) }, new String[] { "names" })); } /** creates a new generic vector from a list. Note that the names in the list are ignored as they are expected to be defined by the attributes parameter. * @param list list to create the vector from (names are ignored - use {@link #REXPGenericVector(RList)} or the "names" attribute for named lists * @param attr attributes */ public REXPGenericVector(RList list, REXPList attr) { super(attr); payload=(list==null)?new RList():list; } /* generic vectors are converted either to a Map (if it is a named vector and there are no duplicate names) or a Vector. The contained elements are converted using asNativeJavaObject recursively. */ public Object asNativeJavaObject() throws REXPMismatchException { // we need to convert the inside as well int n = payload.size(); // named list -> map but only if // a) all names are present // b) there are no duplicates in the names if (payload.isNamed()) { String[] names = payload.keys(); if (names.length == n) { HashMap map = new HashMap(); boolean valid = true; for (int i = 0; i < n; i++) { if (map.containsKey(names[i])) { valid = false; break; } Object value = payload.elementAt(i); if (value != null) value = ((REXP) value).asNativeJavaObject(); map.put(names[i], value); } if (valid) return map; } } // otherwise drop names and use just a vector Vector v = new Vector(); for (int i = 0; i < n; i++) { Object value = payload.elementAt(i); if (value != null) value = ((REXP) value).asNativeJavaObject(); v.addElement(value); } return v; } public int length() { return payload.size(); } public boolean isList() { return true; } public boolean isRecursive() { return true; } public RList asList() { return payload; } public String toString() { return super.toString()+(asList().isNamed()?"named":""); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } } rJava/jri/REngine/mkmvn.sh0000755000175100001440000000033315133274032015134 0ustar hornikusers#!/bin/sh BASE="$1" if [ -z "$BASE" ]; then BASE="`pwd`"; fi rm -rf "$BASE/src/main" mkdir -p "$BASE/src/main/java/org/rosuda/REngine" (cd "$BASE/src/main/java/org/rosuda/REngine" && ln -s ../../../../../../*.java .) rJava/jri/REngine/JRI/0000755000175100001440000000000015133274032014072 5ustar hornikusersrJava/jri/REngine/JRI/Makefile0000644000175100001440000000130315133274037015534 0ustar hornikusers## there are two ways to compile JRIEngine - either use ## already installed REngine and JRI and then just ## compile JRIEngine against those jars or use this ## Makefile with all org sources checked out ## in which case the JRIEngine.jar will implicitly ## contain org.rosuda.JRI classes as well ## However, that requires both: ## org/rosuda/JRI ## org/rosuda/REngine JRI_MAIN_SRC=$(wildcard ../../*.java) JRIENGINE_SRC=JRIEngine.java JAVAC=javac JAR=jar JFLAGS=-source 1.6 -target 1.6 all: JRIEngine.jar JRIEngine.jar: $(JRI_MAIN_SRC) $(JRIENGINE_SRC) rm -rf org $(JAVAC) $(JFLAGS) -classpath ../REngine.jar -d . $^ $(JAR) fc $@ org clean: rm -rf org *~ JRIEngine.jar *.class make -C test clean rJava/jri/REngine/JRI/test/0000755000175100001440000000000015133274032015051 5ustar hornikusersrJava/jri/REngine/JRI/test/Makefile0000644000175100001440000000122015133274037016511 0ustar hornikusers## NOTE: the tests require rJava to be installed in the current R ## since they also test the JRI/rJava connectivity CP=../../REngine.jar:../JRIEngine.jar:$(RJAVA)/java/boot:$(RJAVA)/jri/JRI.jar JFLAGS=-source 1.6 -target 1.6 RJAVA=$(shell echo "cat(system.file(package='rJava'))"|R --slave --no-save) JRI=$(shell if test -e ../../../JRI/src/JRI.jar; then echo ../../../JRI/src; else echo $(RJAVA)/jri; fi) JRT=-Djava.library.path=$(JRI):. JAVAC=javac JAVA=java all: run RTest.class: RTest.java $(JAVAC) $(JFLAGS) -classpath $(CP) $^ run: RTest.class R CMD $(JAVA) -cp $(CP):. $(JRT) RTest clean: rm -rf org *.class *~ .PHONY: run clean rJava/jri/REngine/JRI/test/RTest.java0000644000175100001440000004134415133274032016763 0ustar hornikusersimport org.rosuda.REngine.*; class TestException extends Exception { public TestException(String msg) { super(msg); } } // This is the same test as in Rserve but it's using JRI instead public class RTest { public static void main(String[] args) { try { // the simple initialization is done using // REngine eng = REngine.engineForClass("org.rosuda.REngine.JRI.JRIEngine"); // but the one below allows us to see all output from R via REngineStdOutput() // However, it won't succeed if the engine doesn't support callbacks, so be prepared to fall back REngine eng = REngine.engineForClass("org.rosuda.REngine.JRI.JRIEngine", args, new REngineStdOutput(), false); if (args.length > 0 && args[0].equals("--debug")) { // --debug waits for so a debugger can be attached System.out.println("R Version: " + eng.parseAndEval("R.version.string").asString()); System.out.println("ok, connected, press to continue\n"); System.in.read(); } { System.out.println("* Test string and list retrieval"); RList l = eng.parseAndEval("{d=data.frame(\"huhu\",c(11:20)); lapply(d,as.character)}").asList(); int cols = l.size(); int rows = l.at(0).length(); String[][] s = new String[cols][]; for (int i=0; i { .env <- new.env(); .env$x <- 2 }" ); System.out.println( " env = eng.get(\".env\", null, false ) " ); System.out.print( " parseAndEval( \"x+1\", env, true)" ); if( !( x instanceof REXPDouble ) || x.asDouble() != 3.0 ) throw new TestException("eval within environment failed") ; System.out.println( " == 3.0 : ok" ); System.out.println("PASSED"); } /* SU: wrap() tests removed since they didn't even compile ... */ { System.out.println("* Test generation of exceptions"); /* parse exceptions */ String cmd = "rnorm(10))" ; // syntax error System.out.println(" eng.parse(\"rnorm(10))\", false ) -> REngineException( \"Parse Error\" ) " ) ; boolean ok = false; try{ eng.parse( cmd, false ) ; } catch( REngineException e){ ok = true ; } if( !ok ){ throw new TestException( "parse did not generate an exception on syntax error" ) ; } System.out.println(" eng.parseAndEval(\"rnorm(10))\" ) -> REngineException( \"Parse Error\" ) " ) ; ok = false; try{ eng.parseAndEval( cmd ) ; } catch( REngineException e){ ok = true ; } if( !ok ){ throw new TestException( "parseAndEval did not generate an exception on syntax error" ) ; } /* eval exceptions */ cmd = "rnorm(5); stop('error'); rnorm(2)" ; System.out.print(" " + cmd ) ; ok = false; try{ eng.parseAndEval( cmd ) ; } catch( REngineException e){ if( e instanceof REngineEvalException ){ ok = true ; } } if( !ok ){ throw new TestException( "error in R did not generate REngineEvalException" ) ; } System.out.println( " -> REngineEvalException : ok" ) ; System.out.println("PASSED"); } { System.out.println("* Test creation of references to java objects"); if (!((REXPLogical)eng.parseAndEval("require(rJava)")).isTRUE()[0]) { System.out.println(" - rJava is not available, skipping test\n"); } else if (!(eng instanceof org.rosuda.REngine.JRI.JRIEngine)) { System.out.println(" - the used engine is not JRIEngine, skipping test\n"); } else { /* try to use rJava before it is initialized */ System.out.print(" checking that rJava generate error if not yet loaded" ) ; boolean error = false; try{ eng.parseAndEval( "p <- .jnew( 'java/awt/Point' ) " ) ; } catch( REngineException e){ error = true ; } if( !error ){ throw new TestException( "rJava not initiliazed, but did not generate error" ) ; } System.out.println( " : ok" ) ; eng.parseAndEval(".jinit()"); REXPReference ref = ((org.rosuda.REngine.JRI.JRIEngine)eng).createRJavaRef( null ); if( ref != null ){ throw new TestException( "null object should create null REXPReference" ) ; } System.out.println(" eng.createRJavaRef(null) -> null : ok" ) ; System.out.println( " pushing a java.awt.Point to R " ) ; java.awt.Point p = new java.awt.Point( 10, 10) ; ref = ((org.rosuda.REngine.JRI.JRIEngine)eng).createRJavaRef( p ); eng.assign( "p", ref ) ; String cmd = "exists('p') && inherits( p, 'jobjRef') && .jclass(p) == 'java.awt.Point' " ; System.out.println( " test if the object was pushed correctly " ) ; boolean ok = ((REXPLogical)eng.parseAndEval( cmd )).isTRUE()[0] ; if( !ok ){ throw new TestException( "could not push java object to R" ) ; } System.out.println( " R> " + cmd + " : ok " ) ; eng.parseAndEval( ".jcall( p, 'V', 'move', 20L, 20L )" ) ; System.out.println(" manipulate the object " ) ; if( p.x != 20 || p.y != 20 ){ throw new TestException( "not modified the java object with R" ) ; } System.out.println(" R> .jcall( p, 'V', 'move', 20L, 20L ) -> p.x == 20 ,p.y == 20 : ok " ) ; /* bug #126, use of .jfield with guess of the return class using reflection */ System.out.print(" using .jfield with reflection (bug #126)" ) ; eng.parseAndEval( ".jfield( p, , 'x')" ) ; /* used to crash the jvm; (not really - the code in the bgu just forgot to init rJava) */ System.out.println(" : ok " ) ; System.out.println("PASSED"); } } /* setEncoding is Rserve's extension - with JRI you have to use UTF-8 locale so this test will fail unless run in UTF-8 { // string encoding test (will work with Rserve 0.5-3 and higher only) System.out.println("* Test string encoding support ..."); String t = "ã²ã‚‰ãŒãª"; // hiragana (literally, in hiragana ;)) eng.setStringEncoding("utf8"); // -- Just in case the console is not UTF-8 don't display it //System.out.println(" unicode text: "+t); eng.assign("s", t); REXP x = eng.parseAndEval("nchar(s)"); System.out.println(" nchar = " + x); if (x == null || !x.isInteger() || x.asInteger() != 4) throw new TestException("UTF-8 encoding string length test failed"); // we cannot really test any other encoding .. System.out.println("PASSED"); } */ eng.close(); // close the engine connection System.out.println("Done."); } catch (REXPMismatchException me) { // some type is different from what you (the programmer) expected System.err.println("Type mismatch: "+me); me.printStackTrace(); System.exit(1); } catch (REngineException ee) { // something went wring in the engine System.err.println("REngine exception: "+ee); ee.printStackTrace(); System.exit(1); } catch (ClassNotFoundException cnfe) { // class not found is thrown by engineForClass System.err.println("Cannot find JRIEngine class - please fix your class path!\n"+cnfe); System.exit(1); } catch (Exception e) { // some other exception ... System.err.println("Exception: "+e); e.printStackTrace(); System.exit(1); } } } rJava/jri/REngine/JRI/JRIEngine.java0000644000175100001440000010121015133274032016502 0ustar hornikusers// JRIEngine - REngine-based interface to JRI // Copyright(c) 2009 Simon Urbanek // // Currently it uses low-level calls from org.rosuda.JRI.Rengine, but // all REXP representations are created based on the org.rosuda.REngine API package org.rosuda.REngine.JRI; import org.rosuda.JRI.Rengine; import org.rosuda.JRI.Mutex; import org.rosuda.JRI.RMainLoopCallbacks; import org.rosuda.REngine.*; /** JRIEngine is a REngine implementation using JRI (Java/R Interface).

Note that at most one JRI instance can exist in a given JVM process, because R does not support multiple threads. JRIEngine itself is thread-safe, so it is possible to invoke its methods from any thread. However, this is achieved by serializing all entries into R, so be aware of possible deadlock conditions if your R code calls back into Java (JRIEngine is re-entrant from the same thread so deadlock issues can arise only with multiple threads inteacting thorugh R). */ public class JRIEngine extends REngine implements RMainLoopCallbacks { // internal R types as defined in Rinternals.h static final int NILSXP = 0; /* nil = NULL */ static final int SYMSXP = 1; /* symbols */ static final int LISTSXP = 2; /* lists of dotted pairs */ static final int CLOSXP = 3; /* closures */ static final int ENVSXP = 4; /* environments */ static final int PROMSXP = 5; /* promises: [un]evaluated closure arguments */ static final int LANGSXP = 6; /* language constructs */ static final int SPECIALSXP = 7; /* special forms */ static final int BUILTINSXP = 8; /* builtin non-special forms */ static final int CHARSXP = 9; /* "scalar" string type (internal only) */ static final int LGLSXP = 10; /* logical vectors */ static final int INTSXP = 13; /* integer vectors */ static final int REALSXP = 14; /* real variables */ static final int CPLXSXP = 15; /* complex variables */ static final int STRSXP = 16; /* string vectors */ static final int DOTSXP = 17; /* dot-dot-dot object */ static final int ANYSXP = 18; /* make "any" args work */ static final int VECSXP = 19; /* generic vectors */ static final int EXPRSXP = 20; /* expressions vectors */ static final int BCODESXP = 21; /* byte code */ static final int EXTPTRSXP = 22; /* external pointer */ static final int WEAKREFSXP = 23; /* weak reference */ static final int RAWSXP = 24; /* raw bytes */ static final int S4SXP = 25; /* S4 object */ /** minimal JRI API version that is required by this class in order to work properly (currently API 1.10, corresponding to JRI 0.5-1 or higher) */ static public final long requiredAPIversion = 0x010a; /** currently running JRIEngine - there can be only one and we store it here. Essentially if it is null then R was not initialized. */ static JRIEngine jriEngine = null; /** reference to the underlying low-level JRI (RNI) engine */ Rengine rni = null; /** event loop callbacks associated with this engine. */ REngineCallbacks callbacks = null; /** mutex synchronizing access to R through JRIEngine.

NOTE: only access through this class is synchronized. Any other access (e.g. using RNI directly) is NOT. */ Mutex rniMutex = null; // cached pointers of special objects in R long R_UnboundValue, R_NilValue; /** special, global references */ public REXPReference globalEnv, emptyEnv, baseEnv, nullValueRef; /** canonical NULL object */ public REXPNull nullValue; /** class used for wrapping raw pointers such that they are adequately protected and released according to the lifespan of the Java object */ class JRIPointer { long ptr; JRIPointer(long ptr, boolean preserve) { this.ptr = ptr; if (preserve && ptr != 0 && ptr != R_NilValue) { boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { rni.rniPreserve(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } protected void finalize() throws Throwable { try { if (ptr != 0 && ptr != R_NilValue) { boolean obtainedLock = rniMutex.safeLock(); try { rni.rniRelease(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } finally { super.finalize(); } } long pointer() { return ptr; } } /** factory method called by engineForClass @return new or current engine (new if there is none, current otherwise since R allows only one engine at any time) */ public static REngine createEngine() throws REngineException { // there can only be one JRI engine in a process if (jriEngine == null) jriEngine = new JRIEngine(); return jriEngine; } public static REngine createEngine(String[] args, REngineCallbacks callbacks, boolean runREPL) throws REngineException { if (jriEngine != null) throw new REngineException(jriEngine, "engine already running - cannot use extended constructor on a running instance"); return jriEngine = new JRIEngine(args, callbacks, runREPL); } public Rengine getRni() { return rni; } /** default constructor - this constructor is also used via createEngine factory call and implies --no-save R argument, no callbacks and no REPL.

This is equivalent to JRIEngine(new String[] { "--no-save" }, null, false) */ public JRIEngine() throws REngineException { this(new String[] { "--no-save" }, (REngineCallbacks) null, false); } /** create JRIEngine with specified R command line arguments, no callbacks and no REPL.

This is equivalent to JRIEngine(args, null, false) */ public JRIEngine(String args[]) throws REngineException { this(args, (REngineCallbacks) null, false); } /** creates a JRI engine with specified delegate for callbacks (JRI compatibility mode ONLY!). The event loop is started if callbacks in not null. * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callbacks delegate class to process event loop callback from R or null if no event loop is desired **/ public JRIEngine(String args[], RMainLoopCallbacks callbacks) throws REngineException { this(args, callbacks, (callbacks == null) ? false : true); } /** creates a JRI engine with specified delegate for callbacks * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callback delegate class to process callbacks from R or null if no callbacks are desired * @param runREPL if set to true then the event loop (REPL) will be started, otherwise the engine is in direct operation mode. */ public JRIEngine(String args[], REngineCallbacks callbacks, boolean runREPL) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); if (Rengine.getVersion() < requiredAPIversion) throw new REngineException(null, "JRI API version is too old, update rJava/JRI to match the REngine API"); this.callbacks = callbacks; // the default modus operandi is without event loop and with --no-save option rni = new Rengine(args, runREPL, (callbacks == null) ? null : this); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { if (!rni.waitForR()) throw(new REngineException(this, "Unable to initialize R")); if (rni.rniGetVersion() < requiredAPIversion) throw(new REngineException(this, "JRI API version is too old, update rJava/JRI to match the REngine API")); globalEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, Long.valueOf(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } /** creates a JRI engine with specified delegate for callbacks (JRI compatibility mode ONLY! Will be deprecated soon!) * @param args arguments to pass to R (note that R usually requires something like --no-save!) * @param callback delegate class to process callbacks from R or null if no callbacks are desired * @param runREPL if set to true then the event loop (REPL) will be started, otherwise the engine is in direct operation mode. */ public JRIEngine(String args[], RMainLoopCallbacks callbacks, boolean runREPL) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); if (Rengine.getVersion() < requiredAPIversion) throw new REngineException(null, "JRI API version is too old, update rJava/JRI to match the REngine API"); // the default modus operandi is without event loop and with --no-save option rni = new Rengine(args, runREPL, callbacks); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); // this will inherently wait for R to become ready try { if (!rni.waitForR()) throw(new REngineException(this, "Unable to initialize R")); if (rni.rniGetVersion() < requiredAPIversion) throw(new REngineException(this, "JRI API version is too old, update rJava/JRI to match the REngine API")); globalEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, Long.valueOf(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } /** WARNING: legacy fallback for hooking from R into an existing Rengine - do NOT use for creating a new Rengine - it will go away eventually */ public JRIEngine(Rengine eng) throws REngineException { // if Rengine hasn't been able to load the native JRI library in its static // initializer, throw an exception if (!Rengine.jriLoaded) throw new REngineException (null, "Cannot load JRI native library"); rni = eng; if (rni.rniGetVersion() < 0x109) throw(new REngineException(this, "R JRI engine is too old - RNI API 1.9 (JRI 0.5) or newer is required")); rniMutex = rni.getRsync(); boolean obtainedLock = rniMutex.safeLock(); try { globalEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_GlobalEnv))); nullValueRef = new REXPReference(this, Long.valueOf(R_NilValue = rni.rniSpecialObject(Rengine.SO_NilValue))); emptyEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_EmptyEnv))); baseEnv = new REXPReference(this, Long.valueOf(rni.rniSpecialObject(Rengine.SO_BaseEnv))); nullValue = new REXPNull(); R_UnboundValue = rni.rniSpecialObject(Rengine.SO_UnboundValue); } finally { if (obtainedLock) rniMutex.unlock(); } // register ourself as the main and last engine lastEngine = this; if (jriEngine == null) jriEngine = this; } public REXP parse(String text, boolean resolve) throws REngineException { REXP ref = null; boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniParse(text, -1); if (pr == 0 || pr == R_NilValue) throw(new REngineException(this, "Parse error")); rni.rniPreserve(pr); ref = new REXPReference(this, Long.valueOf(pr)); if (resolve) try { ref = resolveReference(ref); } catch (REXPMismatchException me) { }; } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP eval(REXP what, REXP where, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (where != null && !where.isReference()) { if (!where.isEnvironment() || ((REXPEnvironment)where).getHandle() == null) throw(new REXPMismatchException(where, "environment")); else rho = ((JRIPointer)((REXPEnvironment)where).getHandle()).pointer(); } else if (where != null) rho = ((Long)((REXPReference)where).getHandle()).longValue(); if (what == null) throw(new REngineException(this, "null object to evaluate")); if (!what.isReference()) { if (what.isExpression() || what.isLanguage()) what = createReference(what); else throw(new REXPMismatchException(where, "reference, expression or language")); } boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniEval(((Long)((REXPReference)what).getHandle()).longValue(), rho); if (pr == 0) // rniEval() signals error by passing 0 throw new REngineEvalException(this, "error during evaluation", REngineEvalException.ERROR) ; rni.rniPreserve(pr); ref = new REXPReference(this, Long.valueOf(pr)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public void assign(String symbol, REXP value, REXP env) throws REngineException, REXPMismatchException { long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); if (value == null) value = nullValueRef; if (!value.isReference()) value = createReference(value); // if value is not a reference, we have to create one boolean obtainedLock = rniMutex.safeLock(), succeeded = false; try { succeeded = rni.rniAssign(symbol, ((Long)((REXPReference)value).getHandle()).longValue(), rho); } finally { if (obtainedLock) rniMutex.unlock(); } if (!succeeded) throw new REngineException(this, "assign failed (probably locked binding"); } public REXP get(String symbol, REXP env, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniFindVar(symbol, rho); if (pr == R_UnboundValue || pr == 0) return null; rni.rniPreserve(pr); ref = new REXPReference(this, Long.valueOf(pr)); if (resolve) try { ref = resolveReference(ref); } catch (REXPMismatchException me) { }; } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP resolveReference(REXP ref) throws REngineException, REXPMismatchException { REXP res = null; if (ref == null) throw(new REngineException(this, "resolveReference called on NULL input")); if (!ref.isReference()) throw(new REXPMismatchException(ref, "reference")); long ptr = ((Long)((REXPReference)ref).getHandle()).longValue(); if (ptr == 0) return nullValue; return resolvePointer(ptr); } /** * Turn an R pointer (long) into a REXP object. * * This is the actual implementation of resolveReference but it works directly on the long pointers to be more efficient when performing recursive de-referencing */ REXP resolvePointer(long ptr) throws REngineException, REXPMismatchException { if (ptr == 0) return nullValue; REXP res = null; boolean obtainedLock = rniMutex.safeLock(); try { int xt = rni.rniExpType(ptr); String an[] = rni.rniGetAttrNames(ptr); REXPList attrs = null; if (an != null && an.length > 0) { // are there attributes? Then we need to resolve them first // we allow special handling for Java references so we need the class and jobj long jobj = 0; String oclass = null; RList attl = new RList(); for (int i = 0; i < an.length; i++) { long aptr = rni.rniGetAttr(ptr, an[i]); if (aptr != 0 && aptr != R_NilValue) { if (an[i].equals("jobj")) jobj = aptr; REXP av = resolvePointer(aptr); if (av != null && av != nullValue) { attl.put(an[i], av); if (an[i].equals("class") && av.isString()) oclass = av.asString(); } } } if (attl.size() > 0) attrs = new REXPList(attl); // FIXME: in general, we could allow arbitrary convertors here ... // Note that the jobj hack is only needed because we don't support EXTPTRSXP conversion // (for a good reason - we can't separate the PTR from the R object so the only way it can // live is as a reference and we don't want resolvePointer to ever return REXPReference as // that could trigger infinite recursions), but if we did, we could allow post-processing // based on the class attribute on the converted REXP.. (better, we can leverage REXPUnknown // and pass the ptr to the convertor so it can pull things like EXTPTR via rni) if (jobj != 0 && oclass != null && (oclass.equals("jobjRef") || oclass.equals("jarrayRef") || oclass.equals("jrectRef"))) return new REXPJavaReference(rni.rniXrefToJava(jobj), attrs); } switch (xt) { case NILSXP: return nullValue; case STRSXP: String[] s = rni.rniGetStringArray(ptr); res = new REXPString(s, attrs); break; case INTSXP: if (rni.rniInherits(ptr, "factor")) { long levx = rni.rniGetAttr(ptr, "levels"); if (levx != 0) { String[] levels = null; // we're using low-level calls here (FIXME?) int rlt = rni.rniExpType(levx); if (rlt == STRSXP) { levels = rni.rniGetStringArray(levx); int[] ids = rni.rniGetIntArray(ptr); res = new REXPFactor(ids, levels, attrs); } } } // if it's not a factor, then we use int[] instead if (res == null) res = new REXPInteger(rni.rniGetIntArray(ptr), attrs); break; case REALSXP: res = new REXPDouble(rni.rniGetDoubleArray(ptr), attrs); break; case LGLSXP: { int ba[] = rni.rniGetBoolArrayI(ptr); byte b[] = new byte[ba.length]; for (int i = 0; i < ba.length; i++) b[i] = (ba[i] == 0 || ba[i] == 1) ? (byte) ba[i] : REXPLogical.NA; res = new REXPLogical(b, attrs); } break; case VECSXP: { long l[] = rni.rniGetVector(ptr); REXP rl[] = new REXP[l.length]; long na = rni.rniGetAttr(ptr, "names"); String[] names = null; if (na != 0 && rni.rniExpType(na) == STRSXP) names = rni.rniGetStringArray(na); for (int i = 0; i < l.length; i++) rl[i] = resolvePointer(l[i]); RList list = (names == null) ? new RList(rl) : new RList(rl, names); res = new REXPGenericVector(list, attrs); } break; case RAWSXP: res = new REXPRaw(rni.rniGetRawArray(ptr), attrs); break; case LISTSXP: case LANGSXP: { RList l = new RList(); // we need to plow through the list iteratively - the recursion occurs at the value level long cdr = ptr; while (cdr != 0 && cdr != R_NilValue) { long car = rni.rniCAR(cdr); long tag = rni.rniTAG(cdr); String name = null; if (rni.rniExpType(tag) == SYMSXP) name = rni.rniGetSymbolName(tag); REXP val = resolvePointer(car); if (name == null) l.add(val); else l.put(name, val); cdr = rni.rniCDR(cdr); } res = (xt == LANGSXP) ? new REXPLanguage(l, attrs) : new REXPList(l, attrs); } break; case SYMSXP: res = new REXPSymbol(rni.rniGetSymbolName(ptr)); break; case ENVSXP: if (ptr != 0) rni.rniPreserve(ptr); res = new REXPEnvironment(this, new JRIPointer(ptr, false)); break; case S4SXP: res = new REXPS4(attrs); break; default: res = new REXPUnknown(xt, attrs); break; } } finally { if (obtainedLock) rniMutex.unlock(); } return res; } public REXP createReference(REXP value) throws REngineException, REXPMismatchException { if (value == null) throw(new REngineException(this, "createReference from a NULL value")); if (value.isReference()) return value; long ptr = createReferencePointer(value); if (ptr == 0) return null; boolean obtainedLock = rniMutex.safeLock(); try { rni.rniPreserve(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } return new REXPReference(this, Long.valueOf(ptr)); } /** * Create an R object, returning its pointer, from an REXP java object. * * @param value * @return long R pointer * @throws REngineException if any of the RNI calls fails * @throws REXPMismatchException only if some internal inconsistency happens. The internal logic should prevent invalid access to valid objects. */ long createReferencePointer(REXP value) throws REngineException, REXPMismatchException { if (value.isReference()) { // if it's reference, return the handle if it's from this engine REXPReference vref = (REXPReference) value; if (vref.getEngine() != this) throw new REXPMismatchException(value, "reference (cross-engine reference is invalid)"); return ((Long)vref.getHandle()).longValue(); } boolean obtainedLock = rniMutex.safeLock(); int upp = 0; try { long ptr = 0; if (value.isNull()) // NULL cannot have attributes, hence get out right away return R_NilValue; else if (value.isLogical()) { int v[] = value.asIntegers(); for (int i = 0; i < v.length; i++) v[i] = (v[i] < 0) ? 2 : ((v[i] == 0) ? 0 : 1); // convert to logical NAs as used by R ptr = rni.rniPutBoolArrayI(v); } else if (value.isInteger()) ptr = rni.rniPutIntArray(value.asIntegers()); else if (value.isRaw()) ptr = rni.rniPutRawArray(value.asBytes()); else if (value.isNumeric()) ptr = rni.rniPutDoubleArray(value.asDoubles()); else if (value.isString()) ptr = rni.rniPutStringArray(value.asStrings()); else if (value.isEnvironment()) { JRIPointer l = (JRIPointer) ((REXPEnvironment)value).getHandle(); if (l == null) { // no associated reference, create a new environemnt long p = rni.rniParse("new.env(parent=baseenv())", 1); ptr = rni.rniEval(p, 0); /* TODO: should we handle REngineEvalException.ERROR and REngineEvalException.INVALID_INPUT here, for completeness */ } else ptr = l.pointer(); } else if (value.isPairList()) { // LISTSXP / LANGSXP boolean lang = value.isLanguage(); RList rl = value.asList(); ptr = R_NilValue; int j = rl.size(); if (j == 0) ptr = rni.rniCons(R_NilValue, 0, 0, lang); else // we are in a somewhat unfortunate situation because we cannot append to the list (RNI has no rniSetCDR!) so we have to use Preserve and bulild the list backwards which may be a bit slower ... for (int i = j - 1; i >= 0; i--) { REXP v = rl.at(i); String n = rl.keyAt(i); long sn = 0; if (n != null) sn = rni.rniInstallSymbol(n); long vptr = createReferencePointer(v); if (vptr == 0) vptr = R_NilValue; long ent = rni.rniCons(vptr, ptr, sn, (i == 0) && lang); /* only the head should be LANGSXP I think - verify ... */ rni.rniPreserve(ent); // preserve current head rni.rniRelease(ptr); // release previous head (since it's part of the new one already) ptr = ent; } } else if (value.isList()) { // VECSXP int init_upp = upp; RList rl = value.asList(); long xl[] = new long[rl.size()]; for (int i = 0; i < xl.length; i++) { REXP rv = rl.at(i); if (rv == null || rv.isNull()) xl[i] = R_NilValue; else { long lv = createReferencePointer(rv); if (lv != 0 && lv != R_NilValue) { rni.rniProtect(lv); upp++; } else lv = R_NilValue; xl[i] = lv; } } ptr = rni.rniPutVector(xl); if (init_upp > upp) { rni.rniUnprotect(upp - init_upp); upp = init_upp; } } else if (value.isSymbol()) return rni.rniInstallSymbol(value.asString()); // symbols need no attribute handling, hence get out right away else if (value instanceof REXPJavaReference) { // we wrap Java references by calling new("jobjRef", ...) Object jval = ((REXPJavaReference)value).getObject(); long jobj = rni.rniJavaToXref(jval); rni.rniProtect(jobj); long jobj_sym = rni.rniInstallSymbol("jobj"); long jclass_sym = rni.rniInstallSymbol("jclass"); String clname = "java/lang/Object"; if (jval != null) { clname = jval.getClass().getName(); clname = clname.replace('.', '/'); } long jclass = rni.rniPutString(clname); rni.rniProtect(jclass); long jobjRef = rni.rniPutString("jobjRef"); rni.rniProtect(jobjRef); long ro = rni.rniEval(rni.rniLCons(rni.rniInstallSymbol("new"), rni.rniCons(jobjRef, rni.rniCons(jobj, rni.rniCons(jclass, R_NilValue, jclass_sym, false), jobj_sym, false)) ), 0); rni.rniUnprotect(3); ptr = ro; } if (ptr == R_NilValue) return ptr; if (ptr != 0) { REXPList att = value._attr(); if (att == null || !att.isPairList()) return ptr; // no valid attributes? the we're done RList al = att.asList(); if (al == null || al.size() < 1 || !al.isNamed()) return ptr; // again - no valid list, get out rni.rniProtect(ptr); // symbols and other exotic creatures are already out by now, so it's ok to protect upp++; for (int i = 0; i < al.size(); i++) { REXP v = al.at(i); String n = al.keyAt(i); if (n != null) { long vptr = createReferencePointer(v); if (vptr != 0 && vptr != R_NilValue) rni.rniSetAttr(ptr, n, vptr); } } return ptr; } } finally { if (upp > 0) rni.rniUnprotect(upp); if (obtainedLock) rniMutex.unlock(); } // we fall thgough here if the object cannot be handled or something went wrong return 0; } public void finalizeReference(REXP ref) throws REngineException, REXPMismatchException { if (ref != null && ref.isReference()) { long ptr = ((Long)((REXPReference)ref).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { rni.rniRelease(ptr); } finally { if (obtainedLock) rniMutex.unlock(); } } } public REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException, REXPMismatchException { REXP ref = null; long rho = 0; if (env != null && !env.isReference()) { if (!env.isEnvironment() || ((REXPEnvironment)env).getHandle() == null) throw(new REXPMismatchException(env, "environment")); else rho = ((JRIPointer)((REXPEnvironment)env).getHandle()).pointer(); } else if (env != null) rho = ((Long)((REXPReference)env).getHandle()).longValue(); boolean obtainedLock = rniMutex.safeLock(); try { long pr = rni.rniParentEnv(rho); if (pr == 0 || pr == R_NilValue) return null; // this should never happen, really rni.rniPreserve(pr); ref = new REXPReference(this, Long.valueOf(pr)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public REXP newEnvironment(REXP parent, boolean resolve) throws REXPMismatchException, REngineException { REXP ref = null; boolean obtainedLock = rniMutex.safeLock(); try { long rho = 0; if (parent != null && !parent.isReference()) { if (!parent.isEnvironment() || ((REXPEnvironment)parent).getHandle() == null) throw(new REXPMismatchException(parent, "environment")); else rho = ((JRIPointer)((REXPEnvironment)parent).getHandle()).pointer(); } else if (parent != null) rho = ((Long)((REXPReference)parent).getHandle()).longValue(); if (rho == 0) rho = ((Long)((REXPReference)globalEnv).getHandle()).longValue(); long p = rni.rniEval(rni.rniLCons(rni.rniInstallSymbol("new.env"), rni.rniCons(rho, R_NilValue, rni.rniInstallSymbol("parent"), false)), 0); /* TODO: should we handle REngineEvalException.INVALID_INPUT and REngineEvalException.ERROR here, for completeness */ if (p != 0) rni.rniPreserve(p); ref = new REXPReference(this, Long.valueOf(p)); if (resolve) ref = resolveReference(ref); } finally { if (obtainedLock) rniMutex.unlock(); } return ref; } public boolean close() { if (rni == null) return false; rni.end(); return true; } /** attempts to obtain a lock for this R engine synchronously (without waiting for it). @return 0 if the lock could not be obtained (R is busy) and some other value otherwise (1 = lock obtained, 2 = the current thread already holds a lock) -- the returned value must be used in a matching call to {@link #unlock(int)}. */ public synchronized int tryLock() { int res = rniMutex.tryLock(); return (res == 1) ? 0 : ((res == -1) ? 2 : 1); } /** obains a lock for this R engine, waiting until it becomes available. @return value that must be passed to {@link #unlock} in order to release the lock */ public synchronized int lock() { return rniMutex.safeLock() ? 1 : 2; } /** releases a lock previously obtained by {@link #lock()} or {@link #tryLock()}. @param lockValue value returned by {@link #lock()} or {@link #tryLock()}. */ public synchronized void unlock(int lockValue) { if (lockValue == 1) rniMutex.unlock(); } public boolean supportsReferences() { return true; } public boolean supportsEnvironments() { return true; } // public boolean supportsREPL() { return true; } public boolean supportsLocking() { return true; } /** * creates a jobjRef reference in R via rJava.
Important: rJava must be loaded and intialized in R (e.g. via eval("{library(rJava);.jinit()}",false), otherwise this will fail. Requires rJava 0.4-13 or higher! * * @param o object to push to R * * @return unresolved REXPReference of the newly created jobjRef object * or null upon failure */ public REXPReference createRJavaRef(Object o) throws REngineException { /* precaution */ if( o == null ){ return null ; } /* call Rengine api and make REXPReference from the result */ REXPReference ref = null ; boolean obtainedLock = rniMutex.safeLock(); try { org.rosuda.JRI.REXP rx = rni.createRJavaRef( o ); if( rx == null){ throw new REngineException( this, "Could not push java Object to R" ) ; } else{ long p = rx.xp; rni.rniPreserve(p) ; ref = new REXPReference( this, Long.valueOf(p) ) ; } } finally { if (obtainedLock) rniMutex.unlock(); } return ref ; } /** JRI callbacks forwarding */ public void rWriteConsole (Rengine re, String text, int oType) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RWriteConsole(this, text, oType); } public void rBusy (Rengine re, int which) { if (callbacks != null && callbacks instanceof REngineUIInterface) ((REngineUIInterface)callbacks).RBusyState(this, which); } public synchronized String rReadConsole (Rengine re, String prompt, int addToHistory) { if (callbacks != null && callbacks instanceof REngineInputInterface) return ((REngineInputInterface)callbacks).RReadConsole(this, prompt, addToHistory); try { wait(); } catch (Exception e) {} return ""; } public void rShowMessage (Rengine re, String message) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RShowMessage(this, message); } public String rChooseFile (Rengine re, int newFile) { if (callbacks != null && callbacks instanceof REngineUIInterface) return ((REngineUIInterface)callbacks).RChooseFile(this, (newFile == 0)); return null; } public void rFlushConsole (Rengine re) { if (callbacks != null && callbacks instanceof REngineOutputInterface) ((REngineOutputInterface)callbacks).RFlushConsole(this); } public void rSaveHistory (Rengine re, String filename) { if (callbacks != null && callbacks instanceof REngineConsoleHistoryInterface) ((REngineConsoleHistoryInterface)callbacks).RSaveHistory(this, filename); } public void rLoadHistory (Rengine re, String filename) { if (callbacks != null && callbacks instanceof REngineConsoleHistoryInterface) ((REngineConsoleHistoryInterface)callbacks).RLoadHistory(this, filename); } } rJava/jri/REngine/JRI/package-info.java0000644000175100001440000000035015133274032017257 0ustar hornikusers/** * REngine-based interface to JRI * *

* Currently it uses low-level calls from org.rosuda.JRI.Rengine, but * all REXP representations are created based on the org.rosuda.REngine API */ package org.rosuda.REngine.JRI ; rJava/jri/REngine/REngineConsoleHistoryInterface.java0000644000175100001440000000117215133274032022367 0ustar hornikuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward console history callbacks from R. */ public interface REngineConsoleHistoryInterface { /** called when R wants to save the history content. * @param eng calling engine * @param filename name of the file to save command history to */ public void RSaveHistory (REngine eng, String filename); /** called when R wants to load the history content. * @param eng calling engine * @param filename name of the file to load the command history from */ public void RLoadHistory (REngine eng, String filename); } rJava/jri/REngine/Rserve/0000755000175100001440000000000015133274032014714 5ustar hornikusersrJava/jri/REngine/Rserve/pom.xml0000644000175100001440000001124415133274032016233 0ustar hornikusers 4.0.0 org.rosuda.REngine Rserve Rserve client back-end for REngine Rserve client back-end implementation for REngine to access R from Java via Rserve. 1.8.2-SNAPSHOT http://github.com/s-u/REngine UTF-8 LGPL v2.1 https://www.gnu.org/licenses/lgpl-2.1.txt Simon Urbanek simon.urbanek@R-project.org scm:git:https://github.com/s-u/REngine.git scm:git:git@github.com:s-u/REngine.git https://github.com/s-u/REngine/tree/master/Rserve org.rosuda.REngine REngine 2.1.1-SNAPSHOT junit junit 4.13.1 test org.slf4j slf4j-api 1.7.5 test org.slf4j slf4j-simple 1.7.5 test exec-maven-plugin org.codehaus.mojo 1.3.2 create mvn structure generate-sources exec ${basedir}/mkmvn.sh org.apache.maven.plugins maven-compiler-plugin 3.2 ${target.version} ${target.version} target-1.5 true 1.5 target-1.6 [9,12) 1.6 target-1.7 [12,20) 1.7 release org.apache.maven.plugins maven-gpg-plugin 1.6 sign-artifacts verify sign org.apache.maven.plugins maven-javadoc-plugin 2.10.2 attach-javadocs jar org.apache.maven.plugins maven-source-plugin 2.4 attach-sources jar-no-fork ossrh https://oss.sonatype.org/content/repositories/snapshots ossrh https://oss.sonatype.org/service/local/staging/deploy/maven2/ rJava/jri/REngine/Rserve/RSession.java0000644000175100001440000000230715133274032017326 0ustar hornikuserspackage org.rosuda.REngine.Rserve; import org.rosuda.REngine.Rserve.protocol.RPacket; import org.rosuda.REngine.Rserve.protocol.RTalk; public class RSession implements java.io.Serializable { // serial version UID should only change if method signatures change // significantly enough that previous versions cannot be used with // current versions private static final long serialVersionUID = -7048099825974875604l; String host; int port; byte[] key; transient RPacket attachPacket=null; // response on session attach int rsrvVersion; protected RSession() { // default no-args constructor for serialization } RSession(RConnection c, RPacket p) throws RserveException { this.host=c.host; this.rsrvVersion=c.rsrvVersion; byte[] ct = p.getCont(); if (ct==null || ct.length!=32+3*4) throw new RserveException(c, "Invalid response to session detach request."); this.port = RTalk.getInt(ct, 4); this.key=new byte[32]; System.arraycopy(ct, 12, this.key, 0, 32); } /** attach/resume this session */ public RConnection attach() throws RserveException { RConnection c = new RConnection(this); attachPacket = c.rt.request(-1); return c; } } rJava/jri/REngine/Rserve/OOBInterface.java0000644000175100001440000000031515133274032020016 0ustar hornikuserspackage org.rosuda.REngine.Rserve; import org.rosuda.REngine.REXP; public interface OOBInterface { public void oobSend(int code, REXP message); public REXP oobMessage(int code, REXP message); } rJava/jri/REngine/Rserve/RFileOutputStream.java0000644000175100001440000001025215133274032021155 0ustar hornikusers// JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2003 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RFileOutputStream.java // // Created by Simon Urbanek on Wed Oct 22 2003. // package org.rosuda.REngine.Rserve; import java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.protocol.*; /** RFileOutputStream is an {@link OutputStream} to transfer files from the client to Rserve server. It is used very much like a {@link FileOutputStream}. Currently mark and seek is not supported. The current implementation is also "one-shot" only, that means the file can be written only once. @version $Id$ */ public class RFileOutputStream extends OutputStream { /** RTalk class to use for communication with the Rserve */ RTalk rt; /** set to true when {@link #close} was called. Any subsequent read requests on closed stream result in an {@link IOException} or error result */ boolean closed; /** tries to create a file on the R server, using specified {@link RTalk} object and filename. Be aware that the filename has to be specified in host format (which is usually unix). In general you should not use directories since Rserve provides an own directory for every connection. Future Rserve servers may even strip all directory navigation characters for security purposes. Therefore only filenames without path specification are considered valid, the behavior in respect to absolute paths in filenames is undefined. @param rti RTalk object for communication with Rserve @param fb filename of the file to create (existing file will be overwritten) */ RFileOutputStream(RTalk rti, String fn) throws IOException { rt=rti; RPacket rp=rt.request(RTalk.CMD_createFile,fn); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=false; } /** writes one byte to the file. This function should be avoided, since {@link RFileOutputStream} provides no buffering. This means that each call to this function leads to a complete packet exchange between the server and the client. Use {@link #write(byte[])} instead whenever possible. In fact this function calls write(b,0,1). @param b byte to write */ public void write(int b) throws IOException { byte[] ba=new byte[1]; write(ba,0,1); } /** writes the content of b into the file. This methods is equivalent to calling write(b,0,b.length). @param b content to write */ public void write(byte b[]) throws IOException { write(b,0,b.length); } /** Writes specified number of bytes to the remote file. @param b buffer containing the bytes to write @param off offset where to start @param len number of bytes to write */ public void write(byte[] b, int off, int len) throws IOException { if (closed) throw new IOException("File is not open"); if (len<0) len=0; boolean isLarge=(len>0xfffff0); byte[] hdr=RTalk.newHdr(RTalk.DT_BYTESTREAM,len); RPacket rp=rt.request(RTalk.CMD_writeFile,hdr,b,off,len); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); } /** close stream - is not related to the actual RConnection, calling close does not close the RConnection. */ public void close() throws IOException { RPacket rp=rt.request(RTalk.CMD_closeFile,(byte[])null); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=true; } /** currently (Rserve 0.3) there is no way to force flush on the remote side, hence this function is noop. Future versions of Rserve may support this feature though. At any rate, it is safe to call it. */ public void flush() { } } rJava/jri/REngine/Rserve/Makefile0000644000175100001440000000073615133274037016367 0ustar hornikusersRENG_SRC=$(wildcard ../*.java) RSRV_SRC=$(wildcard *.java) $(wildcard protocol/*.java) TARGETS=Rserve.jar all: $(TARGETS) JAVAC=javac JFLAGS=-encoding utf8 -source 1.6 -target 1.6 ../REngine.jar: $(RENG_SRC) make -C .. REngine.jar Rserve.jar: $(RSRV_SRC) ../REngine.jar @rm -rf org $(JAVAC) -d . -cp ../REngine.jar $(RSRV_SRC) jar fc $@ org rm -rf org clean: rm -rf org *~ protocol/*~ $(TARGETS) make -C test clean test: make -C test test .PHONY: clean all test rJava/jri/REngine/Rserve/protocol/0000755000175100001440000000000015133274032016555 5ustar hornikusersrJava/jri/REngine/Rserve/protocol/RTalk.java0000644000175100001440000003012315133274032020434 0ustar hornikuserspackage org.rosuda.REngine.Rserve.protocol; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; import java.io.*; import java.net.*; import org.rosuda.REngine.Rserve.RConnection; import org.rosuda.REngine.Rserve.protocol.REXPFactory; import org.rosuda.REngine.REXP; /** This class encapsulates the QAP1 protocol used by Rserv. it is independent of the underying protocol(s), therefore RTalk can be used over any transport layer

The current implementation supports long (0.3+/0102) data format only up to 32-bit and only for incoming packets.

@version $Id$ */ public class RTalk { public static final int DT_INT=1; public static final int DT_CHAR=2; public static final int DT_DOUBLE=3; public static final int DT_STRING=4; public static final int DT_BYTESTREAM=5; public static final int DT_SEXP=10; public static final int DT_ARRAY=11; /** this is a flag saying that the contents is large (>0xfffff0) and hence uses 56-bit length field */ public static final int DT_LARGE=64; public static final int CMD_login=0x001; public static final int CMD_voidEval=0x002; public static final int CMD_eval=0x003; public static final int CMD_shutdown=0x004; /** OCAP call, only valid in OCAP mode, since Rserve 1.8 */ public static final int CMD_OCcall = 0x00f; /** not a command but rather payload sent by the server in OCAP mode */ public static final int CMD_OCinit = 0x434f7352; /* RsOC in ASCII */ public static final int CMD_openFile=0x010; public static final int CMD_createFile=0x011; public static final int CMD_closeFile=0x012; public static final int CMD_readFile=0x013; public static final int CMD_writeFile=0x014; public static final int CMD_removeFile=0x015; public static final int CMD_setSEXP=0x020; public static final int CMD_assignSEXP=0x021; public static final int CMD_setBufferSize=0x081; public static final int CMD_setEncoding=0x082; public static final int CMD_detachSession=0x030; public static final int CMD_detachedVoidEval=0x031; public static final int CMD_attachSession=0x032; // control commands since 0.6-0 public static final int CMD_ctrlEval=0x42; public static final int CMD_ctrlSource=0x45; public static final int CMD_ctrlShutdown=0x44; // errors as returned by Rserve public static final int ERR_auth_failed=0x41; public static final int ERR_conn_broken=0x42; public static final int ERR_inv_cmd=0x43; public static final int ERR_inv_par=0x44; public static final int ERR_Rerror=0x45; public static final int ERR_IOerror=0x46; public static final int ERR_not_open=0x47; public static final int ERR_access_denied=0x48; public static final int ERR_unsupported_cmd=0x49; public static final int ERR_unknown_cmd=0x4a; public static final int ERR_data_overflow=0x4b; public static final int ERR_object_too_big=0x4c; public static final int ERR_out_of_mem=0x4d; public static final int ERR_ctrl_closed=0x4e; public static final int ERR_session_busy=0x50; public static final int ERR_detach_failed=0x51; /** since 1.7 */ public static final int ERR_disabled = 0x61; public static final int ERR_unavailable = 0x62; public static final int ERR_cryptError = 0x63; public static final int ERR_securityClose = 0x64; public static final int CMD_RESP = 0x10000; /* response bit */ public static final int RESP_OK = 0x10001; public static final int RESP_ERR = 0x10002; public static final int CMD_OOB = 0x20000; /* OOB command, low 12 bits are app-specific */ public static final int OOB_SEND = 0x21000; public static final int OOB_MSG = 0x22000; InputStream is; OutputStream os; /** constructor; parameters specify the streams @param sis socket input stream @param sos socket output stream */ public RTalk(InputStream sis, OutputStream sos) { is=sis; os=sos; } /** writes bit-wise int to a byte buffer at specified position in Intel-endian form @param v value to be written @param buf buffer @param o offset in the buffer to start at. An int takes always 4 bytes */ public static void setInt(int v, byte[] buf, int o) { buf[o]=(byte)(v&255); o++; buf[o]=(byte)((v&0xff00)>>8); o++; buf[o]=(byte)((v&0xff0000)>>16); o++; buf[o]=(byte)((v&0xff000000)>>24); } /** writes cmd/resp/type byte + 3/7 bytes len into a byte buffer at specified offset. @param ty type/cmd/resp byte @param len length @param buf buffer @param o offset @return offset in buf just after the header. Please note that since Rserve 0.3 the header can be either 4 or 8 bytes long, depending on the len parameter. */ public static int setHdr(int ty, int len, byte[] buf, int o) { buf[o]=(byte)((ty&255)|((len>0xfffff0)?DT_LARGE:0)); o++; buf[o]=(byte)(len&255); o++; buf[o]=(byte)((len&0xff00)>>8); o++; buf[o]=(byte)((len&0xff0000)>>16); o++; if (len>0xfffff0) { // for large data we need to set the next 4 bytes as well buf[o]=(byte)((len&0xff000000)>>24); o++; buf[o]=0; o++; // since len is int, we get 32-bits only buf[o]=0; o++; buf[o]=0; o++; } return o; } /** creates a new header according to the type and length of the parameter @param ty type/cmd/resp byte @param len length */ public static byte[] newHdr(int ty, int len) { byte[] hdr=new byte[(len>0xfffff0)?8:4]; setHdr(ty,len,hdr,0); return hdr; } /** converts bit-wise stored int in Intel-endian form into Java int @param buf buffer containg the representation @param o offset where to start (4 bytes will be used) @return the int value. no bounds checking is done so you need to make sure that the buffer is big enough */ public static int getInt(byte[] buf, int o) { return ((buf[o]&255)|((buf[o+1]&255)<<8)|((buf[o+2]&255)<<16)|((buf[o+3]&255)<<24)); } /** converts bit-wise stored length from a header. "long" format is supported up to 32-bit @param buf buffer @param o offset of the header (length is at o+1) @return length */ public static int getLen(byte[] buf, int o) { return ((buf[o]&64)>0)? // "long" format; still - we support 32-bit only ((buf[o+1]&255)|((buf[o+2]&255)<<8)|((buf[o+3]&255)<<16)|((buf[o+4]&255)<<24)) : ((buf[o+1]&255)|((buf[o+2]&255)<<8)|((buf[o+3]&255)<<16)); } /** converts bit-wise Intel-endian format into long @param buf buffer @param o offset (8 bytes will be used) @return long value */ public static long getLong(byte[] buf, int o) { long low=((long)getInt(buf,o))&0xffffffffL; long hi=((long)getInt(buf,o+4))&0xffffffffL; hi<<=32; hi|=low; return hi; } public static void setLong(long l, byte[] buf, int o) { setInt((int)(l&0xffffffffL),buf,o); setInt((int)(l>>32),buf,o+4); } /** sends a request with no attached parameters @param cmd command @return returned packet or null if something went wrong */ public RPacket request(int cmd) { byte[] d = new byte[0]; return request(cmd,d); } /** sends a request with attached parameters @param cmd command @param cont contents - parameters @return returned packet or null if something went wrong */ public RPacket request(int cmd, byte[] cont) { return request(cmd,null,cont,0,(cont==null)?0:cont.length); } /** read the response. Return null on error (FIXME: need to use exceptions) */ public RPacket response() { return response(null); } /** read the response. If header is null then is it read from the socket otherwise the provided header is used instead of reading it. Note that if provided, the header aray must have at least 16 bytes and it must at most contain one message */ public RPacket response(byte[] header) { try { if (header == null) { header = new byte[16]; int n = is.read(header); if (n != 16) return null; } int rep = getInt(header, 0); int rl = getInt(header, 4); if (rl > 0) { byte[] ct = new byte[rl]; int n = 0; if (header.length > 16) { n = header.length - 16; System.arraycopy(header, 16, ct, 0, n); } while (n < rl) { int rd = is.read(ct, n, rl - n); n += rd; } return new RPacket(rep, ct); } return new RPacket(rep, null); } catch(Exception e) { e.printStackTrace(); return null; } } /** sends a request with attached prefix and parameters. Both prefix and cont can be null. Effectively request(a,b,null) and request(a,null,b) are equivalent. @param cmd command - a special command of -1 prevents request from sending anything @param prefix - this content is sent *before* cont. It is provided to save memory copy operations where a small header precedes a large data chunk (usually prefix conatins the parameter header and cont contains the actual data). @param cont contents @param offset offset in cont where to start sending (if <0 then 0 is assumed, if >cont.length then no cont is sent) @param len number of bytes in cont to send (it is clipped to the length of cont if necessary) @return returned packet or null if something went wrong */ public RPacket request(int cmd, byte[] prefix, byte[] cont, int offset, int len) { if (cont!=null) { if (offset>=cont.length) { cont=null; len=0; } else if (len>cont.length-offset) len=cont.length-offset; } if (offset<0) offset=0; if (len<0) len=0; int contlen=(cont==null)?0:len; if (prefix!=null && prefix.length>0) contlen+=prefix.length; byte[] hdr=new byte[16]; setInt(cmd,hdr,0); setInt(contlen,hdr,4); for(int i=8;i<16;i++) hdr[i]=0; try { if (cmd!=-1) { os.write(hdr); if (prefix!=null && prefix.length>0) os.write(prefix); if (cont!=null && cont.length>0) os.write(cont,offset,len); } return response(); } catch(Exception e) { e.printStackTrace(); return null; } } /** sends a request with one string parameter attached @param cmd command @param par parameter - length and DT_STRING will be prepended @return returned packet or null if something went wrong */ public RPacket request(int cmd, String par) { try { byte[] b=par.getBytes(RConnection.transferCharset); int sl=b.length+1; if ((sl&3)>0) sl=(sl&0xfffffc)+4; // make sure the length is divisible by 4 byte[] rq=new byte[sl+5]; int i; for(i=0;iDT_SEXP payload) @param cmd command @param object REXP to send @return returned packet or null if something went wrong */ public RPacket request(int cmd, REXP object) { try { REXPFactory r = new REXPFactory(object); int rl = r.getBinaryLength(); byte[] rq = new byte[rl + ((rl > 0xfffff0) ? 8 : 4)]; setHdr(RTalk.DT_SEXP, rl, rq, 0); r.getBinaryRepresentation(rq, (rl > 0xfffff0) ? 8 : 4); return request(cmd, rq); } catch (Exception e) { e.printStackTrace(); } return null; } /** sends a request with one string parameter attached @param cmd command @param par parameter of the type DT_INT @return returned packet or null if something went wrong */ public RPacket request(int cmd, int par) { try { byte[] rq=new byte[8]; setInt(par,rq,4); setHdr(DT_INT,4,rq,0); return request(cmd,rq); } catch (Exception e) { }; return null; } } rJava/jri/REngine/Rserve/protocol/REXPFactory.java0000644000175100001440000005546315133274032021543 0ustar hornikuserspackage org.rosuda.REngine.Rserve.protocol; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004-8 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; /** representation of R-eXpressions in Java @version $Id$ */ public class REXPFactory { /** xpression type: NULL */ public static final int XT_NULL=0; /** xpression type: integer */ public static final int XT_INT=1; /** xpression type: double */ public static final int XT_DOUBLE=2; /** xpression type: String */ public static final int XT_STR=3; /** xpression type: language construct (currently content is same as list) */ public static final int XT_LANG=4; /** xpression type: symbol (content is symbol name: String) */ public static final int XT_SYM=5; /** xpression type: RBool */ public static final int XT_BOOL=6; /** xpression type: S4 object @since Rserve 0.5 */ public static final int XT_S4=7; /** xpression type: generic vector (RList) */ public static final int XT_VECTOR=16; /** xpression type: dotted-pair list (RList) */ public static final int XT_LIST=17; /** xpression type: closure (there is no java class for that type (yet?). currently the body of the closure is stored in the content part of the REXP. Please note that this may change in the future!) */ public static final int XT_CLOS=18; /** xpression type: symbol name @since Rserve 0.5 */ public static final int XT_SYMNAME=19; /** xpression type: dotted-pair list (w/o tags) @since Rserve 0.5 */ public static final int XT_LIST_NOTAG=20; /** xpression type: dotted-pair list (w tags) @since Rserve 0.5 */ public static final int XT_LIST_TAG=21; /** xpression type: language list (w/o tags) @since Rserve 0.5 */ public static final int XT_LANG_NOTAG=22; /** xpression type: language list (w tags) @since Rserve 0.5 */ public static final int XT_LANG_TAG=23; /** xpression type: expression vector */ public static final int XT_VECTOR_EXP=26; /** xpression type: string vector */ public static final int XT_VECTOR_STR=27; /** xpression type: int[] */ public static final int XT_ARRAY_INT=32; /** xpression type: double[] */ public static final int XT_ARRAY_DOUBLE=33; /** xpression type: String[] (currently not used, Vector is used instead) */ public static final int XT_ARRAY_STR=34; /** internal use only! this constant should never appear in a REXP */ public static final int XT_ARRAY_BOOL_UA=35; /** xpression type: RBool[] */ public static final int XT_ARRAY_BOOL=36; /** xpression type: raw (byte[]) @since Rserve 0.4-? */ public static final int XT_RAW=37; /** xpression type: Complex[] @since Rserve 0.5 */ public static final int XT_ARRAY_CPLX=38; /** xpression type: unknown; no assumptions can be made about the content */ public static final int XT_UNKNOWN=48; /** xpression type: RFactor; this XT is internally generated (ergo is does not come from Rsrv.h) to support RFactor class which is built from XT_ARRAY_INT */ public static final int XT_FACTOR=127; /** used for transport only - has attribute */ private static final int XT_HAS_ATTR=128; int type; REXPFactory attr; REXP cont; RList rootList; public REXP getREXP() { return cont; } public REXPList getAttr() { return (attr==null)?null:(REXPList)attr.cont; } public REXPFactory() { } public REXPFactory(REXP r) throws REXPMismatchException { if (r == null) r=new REXPNull(); REXPList a = r._attr(); cont = r; if (a != null) attr = new REXPFactory(a); if (r instanceof REXPNull) { type=XT_NULL; } else if (r instanceof REXPList) { RList l = r.asList(); type = l.isNamed()?XT_LIST_TAG:XT_LIST_NOTAG; if (r instanceof REXPLanguage) type = (type==XT_LIST_TAG)?XT_LANG_TAG:XT_LANG_NOTAG; } else if (r instanceof REXPGenericVector) { type = XT_VECTOR; // FIXME: may have to adjust names attr } else if (r instanceof REXPS4) { type = XT_S4; } else if (r instanceof REXPInteger) { // this includes factor - FIXME: do we need speacial handling? type = XT_ARRAY_INT; } else if (r instanceof REXPDouble) { type = XT_ARRAY_DOUBLE; } else if (r instanceof REXPString) { type = XT_ARRAY_STR; } else if (r instanceof REXPSymbol) { type = XT_SYMNAME; } else if (r instanceof REXPRaw) { type = XT_RAW; } else if (r instanceof REXPLogical) { type = XT_ARRAY_BOOL; } else { // throw new REXPMismatchException(r, "decode"); System.err.println("*** REXPFactory unable to interpret "+r); } } /** parses byte buffer for binary representation of xpressions - read one xpression slot (descends recursively for aggregated xpressions such as lists, vectors etc.) @param buf buffer containing the binary representation @param o offset in the buffer to start at @return position just behind the parsed xpression. Can be use for successive calls to {@link #parseREXP} if more than one expression is stored in the binary array. */ public int parseREXP(byte[] buf, int o) throws REXPMismatchException { int xl = RTalk.getLen(buf,o); boolean hasAtt = ((buf[o]&128)!=0); boolean isLong = ((buf[o]&64)!=0); int xt = (int)(buf[o]&63); //System.out.println("parseREXP: type="+xt+", len="+xl+", hasAtt="+hasAtt+", isLong="+isLong); if (isLong) o+=4; o+=4; int eox=o+xl; type=xt; attr=new REXPFactory(); cont=null; if (hasAtt) o = attr.parseREXP(buf, o); if (xt==XT_NULL) { cont = new REXPNull(getAttr()); return o; } if (xt==XT_DOUBLE) { long lr = RTalk.getLong(buf,o); double[] d = new double[] { Double.longBitsToDouble(lr) }; o+=8; if (o!=eox) { System.err.println("Warning: double SEXP size mismatch\n"); o=eox; } cont = new REXPDouble(d, getAttr()); return o; } if (xt==XT_ARRAY_DOUBLE) { int as=(eox-o)/8,i=0; double[] d=new double[as]; while (o 0) { c = 0; i = o; while (o < eox) { if (buf[o] == 0) { try { if (buf[i] == -1) { /* if the first byte is 0xff (-1 in signed char) then it either needs to be skipped (doubling) or there is an NA value */ if (buf[i + 1] == 0) s[c] = null; /* NA */ else s[c] = new String(buf, i + 1, o - i - 1, RConnection.transferCharset); } else s[c] = new String(buf, i, o - i, RConnection.transferCharset); } catch (java.io.UnsupportedEncodingException ex) { s[c]=""; } c++; i = o + 1; } o++; } } cont = new REXPString(s, getAttr()); return o; } if (xt==XT_VECTOR_STR) { Vector v=new Vector(); while(oPlease note that currently only XT_[ARRAY_]INT, XT_[ARRAY_]DOUBLE and XT_[ARRAY_]STR are supported! All other types will return 4 which is the size of the header. @return length of the REXP including headers (4 or 8 bytes)*/ public int getBinaryLength() throws REXPMismatchException { int l=0; int rxt = type; if (type==XT_LIST || type==XT_LIST_TAG || type==XT_LIST_NOTAG) rxt=(cont.asList()!=null && cont.asList().isNamed())?XT_LIST_TAG:XT_LIST_NOTAG; //System.out.print("len["+xtName(type)+"/"+xtName(rxt)+"] "); if (type==XT_VECTOR_STR) rxt=XT_ARRAY_STR; // VECTOR_STR is broken right now /* if (type==XT_VECTOR && cont.asList()!=null && cont.asList().isNamed()) setAttribute("names",new REXPString(cont.asList().keys())); */ boolean hasAttr = false; REXPList a = getAttr(); RList al = null; if (a!=null) al = a.asList(); if (al != null && al.size()>0) hasAttr=true; if (hasAttr) l+=attr.getBinaryLength(); switch (rxt) { case XT_NULL: case XT_S4: break; case XT_INT: l+=4; break; case XT_DOUBLE: l+=8; break; case XT_RAW: l+=4 + cont.asBytes().length; if ((l&3)>0) l=l-(l&3)+4; break; case XT_STR: case XT_SYMNAME: l+=(cont==null)?1:(cont.asString().length()+1); if ((l&3)>0) l=l-(l&3)+4; break; case XT_ARRAY_INT: l+=cont.asIntegers().length*4; break; case XT_ARRAY_DOUBLE: l+=cont.asDoubles().length*8; break; case XT_ARRAY_CPLX: l+=cont.asDoubles().length*8; break; case XT_ARRAY_BOOL: l += cont.asBytes().length + 4; if ((l & 3) > 0) l = l - (l & 3) + 4; break; case XT_LIST_TAG: case XT_LIST_NOTAG: case XT_LANG_TAG: case XT_LANG_NOTAG: case XT_LIST: case XT_VECTOR: { final RList lst = cont.asList(); int i=0; while (i0) l=l-(l&3)+4; // System.out.println("TAG length: "+(l-pl)); } i++; } if ((l&3)>0) l=l-(l&3)+4; break; } case XT_ARRAY_STR: { String sa[] = cont.asStrings(); int i=0; while (i < sa.length) { if (sa[i] != null) { try { byte b[] = sa[i].getBytes(RConnection.transferCharset); if (b.length > 0) { if (b[0] == -1) l++; l += b.length; } b = null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } } else l++; // NA = -1 l++; i++; } if ((l&3)>0) l=l-(l&3)+4; break; } } // switch if (l>0xfffff0) l+=4; // large data need 4 more bytes // System.out.println("len:"+(l+4)+" "+xtName(rxt)+"/"+xtName(type)+" "+cont); return l+4; // add the header } /** Stores the REXP in its binary (ready-to-send) representation including header into a buffer and returns the index of the byte behind the REXP.

Please note that currently only XT_[ARRAY_]INT, XT_[ARRAY_]DOUBLE and XT_[ARRAY_]STR are supported! All other types will be stored as SEXP of the length 0 without any contents. @param buf buffer to store the REXP binary into @param off offset of the first byte where to store the REXP @return the offset of the first byte behind the stored REXP */ public int getBinaryRepresentation(byte[] buf, int off) throws REXPMismatchException { int myl=getBinaryLength(); boolean isLarge=(myl>0xfffff0); boolean hasAttr = false; final REXPList a = getAttr(); RList al = null; if (a != null) al = a.asList(); if (al != null && al.size()>0) hasAttr=true; int rxt=type, ooff=off; if (type==XT_VECTOR_STR) rxt=XT_ARRAY_STR; // VECTOR_STR is broken right now if (type==XT_LIST || type==XT_LIST_TAG || type==XT_LIST_NOTAG) rxt=(cont.asList()!=null && cont.asList().isNamed())?XT_LIST_TAG:XT_LIST_NOTAG; // System.out.println("@"+off+": "+xtName(rxt)+"/"+xtName(type)+" "+cont+" ("+myl+"/"+buf.length+") att="+hasAttr); RTalk.setHdr(rxt|(hasAttr?XT_HAS_ATTR:0),myl-(isLarge?8:4),buf,off); off+=(isLarge?8:4); if (hasAttr) off=attr.getBinaryRepresentation(buf, off); switch (rxt) { case XT_S4: case XT_NULL: break; case XT_INT: RTalk.setInt(cont.asInteger(),buf,off); break; case XT_DOUBLE: RTalk.setLong(Double.doubleToRawLongBits(cont.asDouble()),buf,off); break; case XT_ARRAY_INT: { int ia[]=cont.asIntegers(); int i=0, io=off; while(i 0) { for(int i =0; i < ba.length; i++) buf[io++] = (byte) ( (ba[i] == REXPLogical.NA) ? 2 : ((ba[i] == REXPLogical.FALSE) ? 0 : 1) ); while ((io & 3) != 0) buf[io++] = 3; } break; } case XT_ARRAY_DOUBLE: { double da[]=cont.asDoubles(); int i=0, io=off; while(i 0) { if (b[0] == -1) /* if the first entry happens to be -1 then we need to double it so it doesn't get confused with NAs */ buf[io++] = -1; System.arraycopy(b, 0, buf, io, b.length); io += b.length; } b = null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } } else buf[io++] = -1; /* NAs are stored as 0xff (-1 in signed bytes) */ buf[io++] = 0; i++; } i = io - off; while ((i & 3) != 0) { buf[io++] = 1; i++; } // padding if necessary.. break; } case XT_LIST_TAG: case XT_LIST_NOTAG: case XT_LANG_TAG: case XT_LANG_NOTAG: case XT_LIST: case XT_VECTOR: case XT_VECTOR_EXP: { int io = off; final RList lst = cont.asList(); if (lst != null) { int i=0; while (i @"+off+", len "+b.length+" (cont "+buf.length+") \""+s+"\""); System.arraycopy(b,0,buf,io,b.length); io+=b.length; b=null; } catch (java.io.UnsupportedEncodingException uex) { // FIXME: we should so something ... so far we hope noone's gonna mess with the encoding } buf[io++]=0; while ((io&3)!=0) buf[io++]=0; // padding if necessary.. return io; } /** returns human-readable name of the xpression type as string. Arrays are denoted by a trailing asterisk (*). @param xt xpression type @return name of the xpression type */ public static String xtName(int xt) { if (xt==XT_NULL) return "NULL"; if (xt==XT_INT) return "INT"; if (xt==XT_STR) return "STRING"; if (xt==XT_DOUBLE) return "REAL"; if (xt==XT_BOOL) return "BOOL"; if (xt==XT_ARRAY_INT) return "INT*"; if (xt==XT_ARRAY_STR) return "STRING*"; if (xt==XT_ARRAY_DOUBLE) return "REAL*"; if (xt==XT_ARRAY_BOOL) return "BOOL*"; if (xt==XT_ARRAY_CPLX) return "COMPLEX*"; if (xt==XT_SYM) return "SYMBOL"; if (xt==XT_SYMNAME) return "SYMNAME"; if (xt==XT_LANG) return "LANG"; if (xt==XT_LIST) return "LIST"; if (xt==XT_LIST_TAG) return "LIST+T"; if (xt==XT_LIST_NOTAG) return "LIST/T"; if (xt==XT_LANG_TAG) return "LANG+T"; if (xt==XT_LANG_NOTAG) return "LANG/T"; if (xt==XT_CLOS) return "CLOS"; if (xt==XT_RAW) return "RAW"; if (xt==XT_S4) return "S4"; if (xt==XT_VECTOR) return "VECTOR"; if (xt==XT_VECTOR_STR) return "STRING[]"; if (xt==XT_VECTOR_EXP) return "EXPR[]"; if (xt==XT_FACTOR) return "FACTOR"; if (xt==XT_UNKNOWN) return "UNKNOWN"; return ""; } } rJava/jri/REngine/Rserve/protocol/RPacket.java0000644000175100001440000000272015133274032020752 0ustar hornikuserspackage org.rosuda.REngine.Rserve.protocol; import org.rosuda.REngine.Rserve.protocol.RTalk; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- /** small class encapsulating packets from/to Rserv @version $Id$ */ public class RPacket { int cmd; byte[] cont; /** construct new packet @param Rcmd command @param Rcont content */ public RPacket(int Rcmd, byte[] Rcont) { cmd=Rcmd; cont=Rcont; } /** get command @return command */ public int getCmd() { return cmd; } /** check if last response was an OOB message (send or msg) */ public boolean isOOB() { return ((cmd & 0xf0000) == RTalk.CMD_OOB); } /** check last response for RESP_OK @return true if last response was OK */ public boolean isOk() { return ((cmd&15)==1); } /** check last response for RESP_ERR @return true if last response was ERROR */ public boolean isError() { return ((cmd&15)==2); } /** get status code of last response @return status code returned on last response */ public int getStat() { return ((cmd>>24)&127); } /** get content @return inner package content */ public byte[] getCont() { return cont; } public String toString() { return "RPacket[cmd="+cmd+",len="+((cont==null)?"":(""+cont.length))+"]"; } } rJava/jri/REngine/Rserve/protocol/jcrypt.java0000644000175100001440000005731615133274032020747 0ustar hornikuserspackage org.rosuda.REngine.Rserve.protocol; /**************************************************************************** * jcrypt.java * * Java-based implementation of the unix crypt command * * Based upon C source code written by Eric Young, eay@psych.uq.oz.au * ****************************************************************************/ public class jcrypt { private static final int ITERATIONS = 16; private static final int con_salt[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, }; private static final boolean shifts2[] = { false, false, true, true, true, true, true, true, false, true, true, true, true, true, true, false }; private static final int skb[][] = { { /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000, 0x00000010, 0x20000000, 0x20000010, 0x00010000, 0x00010010, 0x20010000, 0x20010010, 0x00000800, 0x00000810, 0x20000800, 0x20000810, 0x00010800, 0x00010810, 0x20010800, 0x20010810, 0x00000020, 0x00000030, 0x20000020, 0x20000030, 0x00010020, 0x00010030, 0x20010020, 0x20010030, 0x00000820, 0x00000830, 0x20000820, 0x20000830, 0x00010820, 0x00010830, 0x20010820, 0x20010830, 0x00080000, 0x00080010, 0x20080000, 0x20080010, 0x00090000, 0x00090010, 0x20090000, 0x20090010, 0x00080800, 0x00080810, 0x20080800, 0x20080810, 0x00090800, 0x00090810, 0x20090800, 0x20090810, 0x00080020, 0x00080030, 0x20080020, 0x20080030, 0x00090020, 0x00090030, 0x20090020, 0x20090030, 0x00080820, 0x00080830, 0x20080820, 0x20080830, 0x00090820, 0x00090830, 0x20090820, 0x20090830, }, { /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */ 0x00000000, 0x02000000, 0x00002000, 0x02002000, 0x00200000, 0x02200000, 0x00202000, 0x02202000, 0x00000004, 0x02000004, 0x00002004, 0x02002004, 0x00200004, 0x02200004, 0x00202004, 0x02202004, 0x00000400, 0x02000400, 0x00002400, 0x02002400, 0x00200400, 0x02200400, 0x00202400, 0x02202400, 0x00000404, 0x02000404, 0x00002404, 0x02002404, 0x00200404, 0x02200404, 0x00202404, 0x02202404, 0x10000000, 0x12000000, 0x10002000, 0x12002000, 0x10200000, 0x12200000, 0x10202000, 0x12202000, 0x10000004, 0x12000004, 0x10002004, 0x12002004, 0x10200004, 0x12200004, 0x10202004, 0x12202004, 0x10000400, 0x12000400, 0x10002400, 0x12002400, 0x10200400, 0x12200400, 0x10202400, 0x12202400, 0x10000404, 0x12000404, 0x10002404, 0x12002404, 0x10200404, 0x12200404, 0x10202404, 0x12202404, }, { /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */ 0x00000000, 0x00000001, 0x00040000, 0x00040001, 0x01000000, 0x01000001, 0x01040000, 0x01040001, 0x00000002, 0x00000003, 0x00040002, 0x00040003, 0x01000002, 0x01000003, 0x01040002, 0x01040003, 0x00000200, 0x00000201, 0x00040200, 0x00040201, 0x01000200, 0x01000201, 0x01040200, 0x01040201, 0x00000202, 0x00000203, 0x00040202, 0x00040203, 0x01000202, 0x01000203, 0x01040202, 0x01040203, 0x08000000, 0x08000001, 0x08040000, 0x08040001, 0x09000000, 0x09000001, 0x09040000, 0x09040001, 0x08000002, 0x08000003, 0x08040002, 0x08040003, 0x09000002, 0x09000003, 0x09040002, 0x09040003, 0x08000200, 0x08000201, 0x08040200, 0x08040201, 0x09000200, 0x09000201, 0x09040200, 0x09040201, 0x08000202, 0x08000203, 0x08040202, 0x08040203, 0x09000202, 0x09000203, 0x09040202, 0x09040203, }, { /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */ 0x00000000, 0x00100000, 0x00000100, 0x00100100, 0x00000008, 0x00100008, 0x00000108, 0x00100108, 0x00001000, 0x00101000, 0x00001100, 0x00101100, 0x00001008, 0x00101008, 0x00001108, 0x00101108, 0x04000000, 0x04100000, 0x04000100, 0x04100100, 0x04000008, 0x04100008, 0x04000108, 0x04100108, 0x04001000, 0x04101000, 0x04001100, 0x04101100, 0x04001008, 0x04101008, 0x04001108, 0x04101108, 0x00020000, 0x00120000, 0x00020100, 0x00120100, 0x00020008, 0x00120008, 0x00020108, 0x00120108, 0x00021000, 0x00121000, 0x00021100, 0x00121100, 0x00021008, 0x00121008, 0x00021108, 0x00121108, 0x04020000, 0x04120000, 0x04020100, 0x04120100, 0x04020008, 0x04120008, 0x04020108, 0x04120108, 0x04021000, 0x04121000, 0x04021100, 0x04121100, 0x04021008, 0x04121008, 0x04021108, 0x04121108, }, { /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */ 0x00000000, 0x10000000, 0x00010000, 0x10010000, 0x00000004, 0x10000004, 0x00010004, 0x10010004, 0x20000000, 0x30000000, 0x20010000, 0x30010000, 0x20000004, 0x30000004, 0x20010004, 0x30010004, 0x00100000, 0x10100000, 0x00110000, 0x10110000, 0x00100004, 0x10100004, 0x00110004, 0x10110004, 0x20100000, 0x30100000, 0x20110000, 0x30110000, 0x20100004, 0x30100004, 0x20110004, 0x30110004, 0x00001000, 0x10001000, 0x00011000, 0x10011000, 0x00001004, 0x10001004, 0x00011004, 0x10011004, 0x20001000, 0x30001000, 0x20011000, 0x30011000, 0x20001004, 0x30001004, 0x20011004, 0x30011004, 0x00101000, 0x10101000, 0x00111000, 0x10111000, 0x00101004, 0x10101004, 0x00111004, 0x10111004, 0x20101000, 0x30101000, 0x20111000, 0x30111000, 0x20101004, 0x30101004, 0x20111004, 0x30111004, }, { /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */ 0x00000000, 0x08000000, 0x00000008, 0x08000008, 0x00000400, 0x08000400, 0x00000408, 0x08000408, 0x00020000, 0x08020000, 0x00020008, 0x08020008, 0x00020400, 0x08020400, 0x00020408, 0x08020408, 0x00000001, 0x08000001, 0x00000009, 0x08000009, 0x00000401, 0x08000401, 0x00000409, 0x08000409, 0x00020001, 0x08020001, 0x00020009, 0x08020009, 0x00020401, 0x08020401, 0x00020409, 0x08020409, 0x02000000, 0x0A000000, 0x02000008, 0x0A000008, 0x02000400, 0x0A000400, 0x02000408, 0x0A000408, 0x02020000, 0x0A020000, 0x02020008, 0x0A020008, 0x02020400, 0x0A020400, 0x02020408, 0x0A020408, 0x02000001, 0x0A000001, 0x02000009, 0x0A000009, 0x02000401, 0x0A000401, 0x02000409, 0x0A000409, 0x02020001, 0x0A020001, 0x02020009, 0x0A020009, 0x02020401, 0x0A020401, 0x02020409, 0x0A020409, }, { /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */ 0x00000000, 0x00000100, 0x00080000, 0x00080100, 0x01000000, 0x01000100, 0x01080000, 0x01080100, 0x00000010, 0x00000110, 0x00080010, 0x00080110, 0x01000010, 0x01000110, 0x01080010, 0x01080110, 0x00200000, 0x00200100, 0x00280000, 0x00280100, 0x01200000, 0x01200100, 0x01280000, 0x01280100, 0x00200010, 0x00200110, 0x00280010, 0x00280110, 0x01200010, 0x01200110, 0x01280010, 0x01280110, 0x00000200, 0x00000300, 0x00080200, 0x00080300, 0x01000200, 0x01000300, 0x01080200, 0x01080300, 0x00000210, 0x00000310, 0x00080210, 0x00080310, 0x01000210, 0x01000310, 0x01080210, 0x01080310, 0x00200200, 0x00200300, 0x00280200, 0x00280300, 0x01200200, 0x01200300, 0x01280200, 0x01280300, 0x00200210, 0x00200310, 0x00280210, 0x00280310, 0x01200210, 0x01200310, 0x01280210, 0x01280310, }, { /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */ 0x00000000, 0x04000000, 0x00040000, 0x04040000, 0x00000002, 0x04000002, 0x00040002, 0x04040002, 0x00002000, 0x04002000, 0x00042000, 0x04042000, 0x00002002, 0x04002002, 0x00042002, 0x04042002, 0x00000020, 0x04000020, 0x00040020, 0x04040020, 0x00000022, 0x04000022, 0x00040022, 0x04040022, 0x00002020, 0x04002020, 0x00042020, 0x04042020, 0x00002022, 0x04002022, 0x00042022, 0x04042022, 0x00000800, 0x04000800, 0x00040800, 0x04040800, 0x00000802, 0x04000802, 0x00040802, 0x04040802, 0x00002800, 0x04002800, 0x00042800, 0x04042800, 0x00002802, 0x04002802, 0x00042802, 0x04042802, 0x00000820, 0x04000820, 0x00040820, 0x04040820, 0x00000822, 0x04000822, 0x00040822, 0x04040822, 0x00002820, 0x04002820, 0x00042820, 0x04042820, 0x00002822, 0x04002822, 0x00042822, 0x04042822, }, }; private static final int SPtrans[][] = { { /* nibble 0 */ 0x00820200, 0x00020000, 0x80800000, 0x80820200, 0x00800000, 0x80020200, 0x80020000, 0x80800000, 0x80020200, 0x00820200, 0x00820000, 0x80000200, 0x80800200, 0x00800000, 0x00000000, 0x80020000, 0x00020000, 0x80000000, 0x00800200, 0x00020200, 0x80820200, 0x00820000, 0x80000200, 0x00800200, 0x80000000, 0x00000200, 0x00020200, 0x80820000, 0x00000200, 0x80800200, 0x80820000, 0x00000000, 0x00000000, 0x80820200, 0x00800200, 0x80020000, 0x00820200, 0x00020000, 0x80000200, 0x00800200, 0x80820000, 0x00000200, 0x00020200, 0x80800000, 0x80020200, 0x80000000, 0x80800000, 0x00820000, 0x80820200, 0x00020200, 0x00820000, 0x80800200, 0x00800000, 0x80000200, 0x80020000, 0x00000000, 0x00020000, 0x00800000, 0x80800200, 0x00820200, 0x80000000, 0x80820000, 0x00000200, 0x80020200, }, { /* nibble 1 */ 0x10042004, 0x00000000, 0x00042000, 0x10040000, 0x10000004, 0x00002004, 0x10002000, 0x00042000, 0x00002000, 0x10040004, 0x00000004, 0x10002000, 0x00040004, 0x10042000, 0x10040000, 0x00000004, 0x00040000, 0x10002004, 0x10040004, 0x00002000, 0x00042004, 0x10000000, 0x00000000, 0x00040004, 0x10002004, 0x00042004, 0x10042000, 0x10000004, 0x10000000, 0x00040000, 0x00002004, 0x10042004, 0x00040004, 0x10042000, 0x10002000, 0x00042004, 0x10042004, 0x00040004, 0x10000004, 0x00000000, 0x10000000, 0x00002004, 0x00040000, 0x10040004, 0x00002000, 0x10000000, 0x00042004, 0x10002004, 0x10042000, 0x00002000, 0x00000000, 0x10000004, 0x00000004, 0x10042004, 0x00042000, 0x10040000, 0x10040004, 0x00040000, 0x00002004, 0x10002000, 0x10002004, 0x00000004, 0x10040000, 0x00042000, }, { /* nibble 2 */ 0x41000000, 0x01010040, 0x00000040, 0x41000040, 0x40010000, 0x01000000, 0x41000040, 0x00010040, 0x01000040, 0x00010000, 0x01010000, 0x40000000, 0x41010040, 0x40000040, 0x40000000, 0x41010000, 0x00000000, 0x40010000, 0x01010040, 0x00000040, 0x40000040, 0x41010040, 0x00010000, 0x41000000, 0x41010000, 0x01000040, 0x40010040, 0x01010000, 0x00010040, 0x00000000, 0x01000000, 0x40010040, 0x01010040, 0x00000040, 0x40000000, 0x00010000, 0x40000040, 0x40010000, 0x01010000, 0x41000040, 0x00000000, 0x01010040, 0x00010040, 0x41010000, 0x40010000, 0x01000000, 0x41010040, 0x40000000, 0x40010040, 0x41000000, 0x01000000, 0x41010040, 0x00010000, 0x01000040, 0x41000040, 0x00010040, 0x01000040, 0x00000000, 0x41010000, 0x40000040, 0x41000000, 0x40010040, 0x00000040, 0x01010000, }, { /* nibble 3 */ 0x00100402, 0x04000400, 0x00000002, 0x04100402, 0x00000000, 0x04100000, 0x04000402, 0x00100002, 0x04100400, 0x04000002, 0x04000000, 0x00000402, 0x04000002, 0x00100402, 0x00100000, 0x04000000, 0x04100002, 0x00100400, 0x00000400, 0x00000002, 0x00100400, 0x04000402, 0x04100000, 0x00000400, 0x00000402, 0x00000000, 0x00100002, 0x04100400, 0x04000400, 0x04100002, 0x04100402, 0x00100000, 0x04100002, 0x00000402, 0x00100000, 0x04000002, 0x00100400, 0x04000400, 0x00000002, 0x04100000, 0x04000402, 0x00000000, 0x00000400, 0x00100002, 0x00000000, 0x04100002, 0x04100400, 0x00000400, 0x04000000, 0x04100402, 0x00100402, 0x00100000, 0x04100402, 0x00000002, 0x04000400, 0x00100402, 0x00100002, 0x00100400, 0x04100000, 0x04000402, 0x00000402, 0x04000000, 0x04000002, 0x04100400, }, { /* nibble 4 */ 0x02000000, 0x00004000, 0x00000100, 0x02004108, 0x02004008, 0x02000100, 0x00004108, 0x02004000, 0x00004000, 0x00000008, 0x02000008, 0x00004100, 0x02000108, 0x02004008, 0x02004100, 0x00000000, 0x00004100, 0x02000000, 0x00004008, 0x00000108, 0x02000100, 0x00004108, 0x00000000, 0x02000008, 0x00000008, 0x02000108, 0x02004108, 0x00004008, 0x02004000, 0x00000100, 0x00000108, 0x02004100, 0x02004100, 0x02000108, 0x00004008, 0x02004000, 0x00004000, 0x00000008, 0x02000008, 0x02000100, 0x02000000, 0x00004100, 0x02004108, 0x00000000, 0x00004108, 0x02000000, 0x00000100, 0x00004008, 0x02000108, 0x00000100, 0x00000000, 0x02004108, 0x02004008, 0x02004100, 0x00000108, 0x00004000, 0x00004100, 0x02004008, 0x02000100, 0x00000108, 0x00000008, 0x00004108, 0x02004000, 0x02000008, }, { /* nibble 5 */ 0x20000010, 0x00080010, 0x00000000, 0x20080800, 0x00080010, 0x00000800, 0x20000810, 0x00080000, 0x00000810, 0x20080810, 0x00080800, 0x20000000, 0x20000800, 0x20000010, 0x20080000, 0x00080810, 0x00080000, 0x20000810, 0x20080010, 0x00000000, 0x00000800, 0x00000010, 0x20080800, 0x20080010, 0x20080810, 0x20080000, 0x20000000, 0x00000810, 0x00000010, 0x00080800, 0x00080810, 0x20000800, 0x00000810, 0x20000000, 0x20000800, 0x00080810, 0x20080800, 0x00080010, 0x00000000, 0x20000800, 0x20000000, 0x00000800, 0x20080010, 0x00080000, 0x00080010, 0x20080810, 0x00080800, 0x00000010, 0x20080810, 0x00080800, 0x00080000, 0x20000810, 0x20000010, 0x20080000, 0x00080810, 0x00000000, 0x00000800, 0x20000010, 0x20000810, 0x20080800, 0x20080000, 0x00000810, 0x00000010, 0x20080010, }, { /* nibble 6 */ 0x00001000, 0x00000080, 0x00400080, 0x00400001, 0x00401081, 0x00001001, 0x00001080, 0x00000000, 0x00400000, 0x00400081, 0x00000081, 0x00401000, 0x00000001, 0x00401080, 0x00401000, 0x00000081, 0x00400081, 0x00001000, 0x00001001, 0x00401081, 0x00000000, 0x00400080, 0x00400001, 0x00001080, 0x00401001, 0x00001081, 0x00401080, 0x00000001, 0x00001081, 0x00401001, 0x00000080, 0x00400000, 0x00001081, 0x00401000, 0x00401001, 0x00000081, 0x00001000, 0x00000080, 0x00400000, 0x00401001, 0x00400081, 0x00001081, 0x00001080, 0x00000000, 0x00000080, 0x00400001, 0x00000001, 0x00400080, 0x00000000, 0x00400081, 0x00400080, 0x00001080, 0x00000081, 0x00001000, 0x00401081, 0x00400000, 0x00401080, 0x00000001, 0x00001001, 0x00401081, 0x00400001, 0x00401080, 0x00401000, 0x00001001, }, { /* nibble 7 */ 0x08200020, 0x08208000, 0x00008020, 0x00000000, 0x08008000, 0x00200020, 0x08200000, 0x08208020, 0x00000020, 0x08000000, 0x00208000, 0x00008020, 0x00208020, 0x08008020, 0x08000020, 0x08200000, 0x00008000, 0x00208020, 0x00200020, 0x08008000, 0x08208020, 0x08000020, 0x00000000, 0x00208000, 0x08000000, 0x00200000, 0x08008020, 0x08200020, 0x00200000, 0x00008000, 0x08208000, 0x00000020, 0x00200000, 0x00008000, 0x08000020, 0x08208020, 0x00008020, 0x08000000, 0x00000000, 0x00208000, 0x08200020, 0x08008020, 0x08008000, 0x00200020, 0x08208000, 0x00000020, 0x00200020, 0x08008000, 0x08208020, 0x00200000, 0x08200000, 0x08000020, 0x00208000, 0x00008020, 0x08008020, 0x08200000, 0x00000020, 0x08208000, 0x00208020, 0x00000000, 0x08000000, 0x08200020, 0x00008000, 0x00208020 } }; private static final int cov_2char[] = { 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A }; private static final int byteToUnsigned(byte b) { int value = (int)b; return(value >= 0 ? value : value + 256); } private static int fourBytesToInt(byte b[], int offset) { int value; value = byteToUnsigned(b[offset++]); value |= (byteToUnsigned(b[offset++]) << 8); value |= (byteToUnsigned(b[offset++]) << 16); value |= (byteToUnsigned(b[offset++]) << 24); return(value); } private static final void intToFourBytes(int iValue, byte b[], int offset) { b[offset++] = (byte)((iValue) & 0xff); b[offset++] = (byte)((iValue >>> 8 ) & 0xff); b[offset++] = (byte)((iValue >>> 16) & 0xff); b[offset++] = (byte)((iValue >>> 24) & 0xff); } private static final void PERM_OP(int a, int b, int n, int m, int results[]) { int t; t = ((a >>> n) ^ b) & m; a ^= t << n; b ^= t; results[0] = a; results[1] = b; } private static final int HPERM_OP(int a, int n, int m) { int t; t = ((a << (16 - n)) ^ a) & m; a = a ^ t ^ (t >>> (16 - n)); return(a); } private static int [] des_set_key(byte key[]) { int schedule[] = new int[ITERATIONS * 2]; int c = fourBytesToInt(key, 0); int d = fourBytesToInt(key, 4); int results[] = new int[2]; PERM_OP(d, c, 4, 0x0f0f0f0f, results); d = results[0]; c = results[1]; c = HPERM_OP(c, -2, 0xcccc0000); d = HPERM_OP(d, -2, 0xcccc0000); PERM_OP(d, c, 1, 0x55555555, results); d = results[0]; c = results[1]; PERM_OP(c, d, 8, 0x00ff00ff, results); c = results[0]; d = results[1]; PERM_OP(d, c, 1, 0x55555555, results); d = results[0]; c = results[1]; d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) | ((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4)); c &= 0x0fffffff; int s, t; int j = 0; for(int i = 0; i < ITERATIONS; i ++) { if(shifts2[i]) { c = (c >>> 2) | (c << 26); d = (d >>> 2) | (d << 26); } else { c = (c >>> 1) | (c << 27); d = (d >>> 1) | (d << 27); } c &= 0x0fffffff; d &= 0x0fffffff; s = skb[0][ (c ) & 0x3f ]| skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)]| skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)]| skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) | ((c >>> 22) & 0x38)]; t = skb[4][ (d ) & 0x3f ]| skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)]| skb[6][ (d >>>15) & 0x3f ]| skb[7][((d >>>21) & 0x0f) | ((d >>> 22) & 0x30)]; schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff; s = ((s >>> 16) | (t & 0xffff0000)); s = (s << 4) | (s >>> 28); schedule[j++] = s & 0xffffffff; } return(schedule); } private static final int D_ENCRYPT ( int L, int R, int S, int E0, int E1, int s[] ) { int t, u, v; v = R ^ (R >>> 16); u = v & E0; v = v & E1; u = (u ^ (u << 16)) ^ R ^ s[S]; t = (v ^ (v << 16)) ^ R ^ s[S + 1]; t = (t >>> 4) | (t << 28); L ^= SPtrans[1][(t ) & 0x3f] | SPtrans[3][(t >>> 8) & 0x3f] | SPtrans[5][(t >>> 16) & 0x3f] | SPtrans[7][(t >>> 24) & 0x3f] | SPtrans[0][(u ) & 0x3f] | SPtrans[2][(u >>> 8) & 0x3f] | SPtrans[4][(u >>> 16) & 0x3f] | SPtrans[6][(u >>> 24) & 0x3f]; return(L); } private static final int [] body(int schedule[], int Eswap0, int Eswap1) { int left = 0; int right = 0; int t = 0; for(int j = 0; j < 25; j ++) { for(int i = 0; i < ITERATIONS * 2; i += 4) { left = D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule); right = D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule); } t = left; left = right; right = t; } t = right; right = (left >>> 1) | (left << 31); left = (t >>> 1) | (t << 31); left &= 0xffffffff; right &= 0xffffffff; int results[] = new int[2]; PERM_OP(right, left, 1, 0x55555555, results); right = results[0]; left = results[1]; PERM_OP(left, right, 8, 0x00ff00ff, results); left = results[0]; right = results[1]; PERM_OP(right, left, 2, 0x33333333, results); right = results[0]; left = results[1]; PERM_OP(left, right, 16, 0x0000ffff, results); left = results[0]; right = results[1]; PERM_OP(right, left, 4, 0x0f0f0f0f, results); right = results[0]; left = results[1]; int out[] = new int[2]; out[0] = left; out[1] = right; return(out); } public static final String crypt(String salt, String original) { while(salt.length() < 2) salt += "A"; StringBuffer buffer = new StringBuffer(" "); char charZero = salt.charAt(0); char charOne = salt.charAt(1); buffer.setCharAt(0, charZero); buffer.setCharAt(1, charOne); int Eswap0 = con_salt[(int)charZero]; int Eswap1 = con_salt[(int)charOne] << 4; byte key[] = new byte[8]; for(int i = 0; i < key.length; i ++) key[i] = (byte)0; for(int i = 0; i < key.length && i < original.length(); i ++) { int iChar = (int)original.charAt(i); key[i] = (byte)(iChar << 1); } int schedule[] = des_set_key(key); int out[] = body(schedule, Eswap0, Eswap1); byte b[] = new byte[9]; intToFourBytes(out[0], b, 0); intToFourBytes(out[1], b, 4); b[8] = 0; for(int i = 2, y = 0, u = 0x80; i < 13; i ++) { for(int j = 0, c = 0; j < 6; j ++) { c <<= 1; if(((int)b[y] & u) != 0) c |= 1; u >>>= 1; if(u == 0) { y++; u = 0x80; } buffer.setCharAt(i, (char)cov_2char[c]); } } return(buffer.toString()); } } rJava/jri/REngine/Rserve/mkmvn.sh0000755000175100001440000000055315133274032016406 0ustar hornikusers#!/bin/sh BASE="$1" if [ -z "$BASE" ]; then BASE="`pwd`"; fi rm -rf "$BASE/src/main" mkdir -p "$BASE/src/main/java/org/rosuda/REngine/Rserve/protocol" (cd "$BASE/src/main/java/org/rosuda/REngine/Rserve" && ln -s ../../../../../../../*.java .) && \ (cd "$BASE/src/main/java/org/rosuda/REngine/Rserve/protocol" && ln -s ../../../../../../../../protocol/*.java .) rJava/jri/REngine/Rserve/RFileInputStream.java0000644000175100001440000000711515133274032020760 0ustar hornikuserspackage org.rosuda.REngine.Rserve; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.protocol.*; /** RFileInputStream is an {@link InputStream} to transfer files from Rserve server to the client. It is used very much like a {@link FileInputStream}. Currently mark and seek is not supported. The current implementation is also "one-shot" only, that means the file can be read only once. @version $Id$ */ public class RFileInputStream extends InputStream { /** RTalk class to use for communication with the Rserve */ RTalk rt; /** set to true when {@link #close} was called. Any subsequent read requests on closed stream result in an {@link IOException} or error result */ boolean closed; /** set to true once EOF is reached - or more specifically the first time remore fread returns OK and 0 bytes */ boolean eof; /** tries to open file on the R server, using specified {@link RTalk} object and filename. Be aware that the filename has to be specified in host format (which is usually unix). In general you should not use directories since Rserve provides an own directory for every connection. Future Rserve servers may even strip all directory navigation characters for security purposes. Therefore only filenames without path specification are considered valid, the behavior in respect to absolute paths in filenames is undefined. */ RFileInputStream(RTalk rti, String fn) throws IOException { rt=rti; RPacket rp=rt.request(RTalk.CMD_openFile,fn); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); closed=false; eof=false; } /** reads one byte from the file. This function should be avoided, since {@link RFileInputStream} provides no buffering. This means that each call to this function leads to a complete packet exchange between the server and the client. Use {@link #read(byte[],int,int)} instead whenever possible. In fact this function calls #read(b,0,1). @return -1 on any failure, or the acquired byte (0..255) on success */ public int read() throws IOException { byte[] b=new byte[1]; if (read(b,0,1)<1) return -1; return b[0]; } /** Reads specified number of bytes (or less) from the remote file. @param b buffer to store the read bytes @param off offset where to strat filling the buffer @param len maximal number of bytes to read @return number of bytes read or -1 if EOF reached */ public int read(byte[] b, int off, int len) throws IOException { if (closed) throw new IOException("File is not open"); if (eof) return -1; RPacket rp=rt.request(RTalk.CMD_readFile,len); if (rp==null || !rp.isOk()) throw new IOException((rp==null)?"Connection to Rserve failed":("Request return code: "+rp.getStat())); byte[] rd=rp.getCont(); if (rd==null) { eof=true; return -1; }; int i=0; while(ibefore connecting to the Rserve in case later Rserves will provide a possibility of setting the encoding during the handshake. */ public static String transferCharset="UTF-8"; /** authorization type: plain text */ public static final int AT_plain = 0; /** authorization type: unix crypt */ public static final int AT_crypt = 1; /** version of the server (as reported in IDstring just after Rsrv) */ protected int rsrvVersion; /** make a new local connection on default port (6311) */ public RConnection() throws RserveException { this("127.0.0.1",6311); } /** make a new connection to specified host on default port (6311) @param host host name/IP */ public RConnection(String host) throws RserveException { this(host,6311); } /** make a new connection to specified host and given port. * Make sure you check {@link #isConnected} to ensure the connection was successfully created. * @param host host name/IP * @param port TCP port */ public RConnection(String host, int port) throws RserveException { this(host, port, null); } /** restore a connection based on a previously detached session * @param session detached session object */ RConnection(RSession session) throws RserveException { this(null, 0, session); } RConnection(String host, int port, RSession session) throws RserveException { try { if (connected) s.close(); s = null; } catch (Exception e) { throw new RserveException(this, "Cannot close previous connection: " + e.getMessage(), e); } if (session != null) { host = session.host; port = session.port; } connected = false; this.host = host; this.port = port; try { Socket ss = new Socket(host,port); // disable Nagle's algorithm since we really want immediate replies ss.setTcpNoDelay(true); initWithSocket(ss, session); } catch (Exception sce) { throw new RserveException(this, "Cannot connect: "+sce.getMessage(), sce); } } /** create a connection based on a previously obtained socket. This constructor allows the use of other communication protocols than TCP/IP (if a Socket implementation exists) or tunneling through other protocols that expose socket insteface (such as SSL). @param sock connected socket */ public RConnection(Socket sock) throws RserveException { this.host = null; this.port = 0; try { if (connected) s.close(); connected = false; s = null; } catch (Exception e) { throw new RserveException(this, "Cannot close previous connection: " + e.getMessage(), e); } initWithSocket(sock, null); } /** set OOB callbacks, i.e. an object that will handle OOB_SEND and OOB_MSG packets in OCAP mode @param callbacks object implementing the OOB interface */ public void setOOB(OOBInterface callbacks) { oob = callbacks; } /** initialization in OCAP mode, assumes all communication variables are setup already, expected to be called by initWithSocket */ private void initOCAP(Socket sock, byte[] header) throws RserveException { /* there is no version in OCAP but 103 is assumed since that is the earliest version that supports OCAPs */ rsrvVersion = 103; isOCAP = true; connected = true; RPacket rp = rt.response(header); capabilities = parseEvalResponse(rp); } private void initWithSocket(Socket sock, RSession session) throws RserveException { s = sock; try { is = s.getInputStream(); os = s.getOutputStream(); } catch (Exception gse) { throw new RserveException(this, "Cannot get io stream: " + gse.getMessage(), gse); } rt = new RTalk(is,os); if (session==null) { byte[] IDs=new byte[32]; int n=-1; try { n=is.read(IDs); } catch (Exception sre) { throw new RserveException(this, "Error while receiving data: "+sre.getMessage(), sre); } try { /* is this OCAP mode ? */ if (n >= 16 && IDs[0] == 0x52 && IDs[1] == 0x73 && IDs[2] == 0x4f && IDs[3] == 0x43) { /* it is possible that the buffering doesn't work out and the first packet is <32 bytes, in which case we have to re-wrap the array to have the correct length */ if (n < 32) { byte[] header = new byte[n]; System.arraycopy(IDs, 0, header, 0, n); IDs = header; } initOCAP(sock, IDs); return; } if (n!=32) { throw new RserveException(this,"Handshake failed: expected 32 bytes header, got "+n); } String ids = new String(IDs); /* regular Rserve mode? */ if (ids.substring(0,4).compareTo("Rsrv")!=0) throw new RserveException(this, "Handshake failed: Rsrv signature expected, but received \""+ids+"\" instead."); try { rsrvVersion=Integer.parseInt(ids.substring(4,8)); } catch (Exception px) {} // we support (knowingly) up to 103 if (rsrvVersion > 103) throw new RserveException(this, "Handshake failed: The server uses more recent protocol than this client."); if (ids.substring(8,12).compareTo("QAP1")!=0) throw new RserveException(this, "Handshake failed: unupported transfer protocol ("+ids.substring(8,12)+"), I talk only QAP1."); for (int i=12; i<32; i+=4) { String attr=ids.substring(i,i+4); if (attr.compareTo("ARpt")==0) { if (!authReq) { // this method is only fallback when no other was specified authReq=true; authType=AT_plain; } } if (attr.compareTo("ARuc")==0) { authReq=true; authType=AT_crypt; } if (attr.charAt(0)=='K') { Key=attr.substring(1,3); } } } catch (RserveException innerX) { try { s.close(); } catch (Exception ex01) {}; is=null; os=null; s=null; throw innerX; } } else { // we have a session to take care of try { os.write(session.key,0,32); } catch (Exception sre) { throw new RserveException(this, "Error while sending session key: " + sre.getMessage(), sre); } rsrvVersion = session.rsrvVersion; } connected=true; lastError="OK"; } public void finalize() { close(); is=null; os=null; } /** get server version as reported during the handshake. @return server version as integer (Rsrv0100 will return 100) */ public int getServerVersion() { return rsrvVersion; } /** closes current connection */ public boolean close() { try { if (s != null) s.close(); connected = false; return true; } catch(Exception e) { }; return false; } /** Returns capabilities received from the server on connect. For non-OCAP mode this always returns null */ public REXP capabilities() { return capabilities; } /** Check whether this connection is to Rserve in OCAP mode. Note that callOC is the only command allowed in OCAP mode. @return true if this connection is in OCAP mode, false otherwise. */ public boolean isOCAP() { return isOCAP; } /** evaluates the given command, but does not fetch the result (useful for assignment operations) @param cmd command/expression string */ public void voidEval(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_voidEval,cmd+"\n"); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"voidEval failed",rp); } /** evaluates the given command, detaches the session (see @link{detach()}) and closes connection while the command is being evaluted (requires Rserve 0.4+). Note that a session cannot be attached again until the commad was successfully processed. Techincally the session is put into listening mode while the command is being evaluated but accept is called only after the command was evaluated. One commonly used techique to monitor detached working sessions is to use second connection to poll the status (e.g. create a temporary file and return the full path before detaching thus allowing new connections to read it). @param cmd command/expression string @return session object that can be use to attach back to the session once the command completed */ public RSession voidEvalDetach(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_detachedVoidEval,cmd+"\n"); if (rp==null || !rp.isOk()) throw new RserveException(this,"detached void eval failed",rp); RSession s = new RSession(this, rp); close(); return s; } REXP parseEvalResponse(RPacket rp) throws RserveException { int rxo=0; byte[] pc=rp.getCont(); if (rsrvVersion>100) { /* since 0101 eval responds correctly by using DT_SEXP type/len header which is 4 bytes long */ rxo=4; /* we should check parameter type (should be DT_SEXP) and fail if it's not */ if (pc[0]!=RTalk.DT_SEXP && pc[0]!=(RTalk.DT_SEXP|RTalk.DT_LARGE)) throw new RserveException(this,"Error while processing eval output: SEXP (type "+RTalk.DT_SEXP+") expected but found result type "+pc[0]+"."); if (pc[0]==(RTalk.DT_SEXP|RTalk.DT_LARGE)) rxo=8; // large data need skip of 8 bytes /* warning: we are not checking or using the length - we assume that only the one SEXP is returned. This is true for the current CMD_eval implementation, but may not be in the future. */ } if (pc.length>rxo) { try { REXPFactory rx=new REXPFactory(); rx.parseREXP(pc, rxo); return rx.getREXP(); } catch (REXPMismatchException me) { me.printStackTrace(); throw new RserveException(this, "Error when parsing response: " + me.getMessage(), me); } } return null; } /** evaluates the given command and retrieves the result @param cmd command/expression string @return R-xpression or null if an error occured */ public REXP eval(String cmd) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_eval,cmd+"\n"); if (rp!=null && rp.isOk()) return parseEvalResponse(rp); throw new RserveException(this,"eval failed",rp); } /** assign a string value to a symbol in R. The symbol is created if it doesn't exist already. @param sym symbol name. Currently assign uses CMD_setSEXP command of Rserve, i.e. the symbol value is NOT parsed. It is the responsibility of the user to make sure that the symbol name is valid in R (recall the difference between a symbol and an expression!). In fact R will always create the symbol, but it may not be accessible (examples: "bar\nfoo" or "bar$foo"). @param ct contents */ public void assign(String sym, String ct) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); try { byte[] symn = sym.getBytes(transferCharset); byte[] ctn = ct.getBytes(transferCharset); int sl = symn.length + 1; int cl = ctn.length + 1; if ((sl & 3) > 0) sl = (sl & 0xfffffc) + 4; // make sure the symbol length is divisible by 4 if ((cl & 3) > 0) cl = (cl & 0xfffffc) + 4; // make sure the content length is divisible by 4 byte[] rq=new byte[sl + 4 + cl + 4]; int ic; for (ic = 0;ic < symn.length; ic++) rq[ic + 4] = symn[ic]; while (ic < sl) { rq[ic + 4] = 0; ic++; } for (ic = 0; ic < ctn.length; ic++) rq[ic + sl + 8] = ctn[ic]; while (ic < cl) { rq[ic + sl + 8] = 0; ic++; } RTalk.setHdr(RTalk.DT_STRING, sl, rq, 0); RTalk.setHdr(RTalk.DT_STRING, cl, rq, sl + 4); RPacket rp = rt.request(RTalk.CMD_setSEXP, rq); if (rp !=null && rp.isOk()) return; throw new RserveException(this, "assign failed", rp); } catch(java.io.UnsupportedEncodingException e) { throw new RserveException(this, "unsupported encoding in assign(String,String)", e); } } public REXP callOCAP(REXP call) throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); if (!isOCAP) throw new RserveException(this, "callOCAP is only available in OCAP mode"); RPacket rp = rt.request(RTalk.CMD_OCcall, call); /* process any OOB messages */ while (rp != null && rp.isOOB()) { REXP payload = parseEvalResponse(rp); if ((rp.getCmd() & 0xff000) == RTalk.OOB_SEND) { if (oob != null) oob.oobSend(rp.getCmd() & 0xfff, payload); rp = rt.response(); } else if ((rp.getCmd() & 0xff000) == RTalk.OOB_MSG) { if (oob == null) throw new RserveException(this, "OOB_MSG received, but no OOB listener registered", rp); REXP res = oob.oobMessage(rp.getCmd() & 0xfff, payload); if (res == null) throw new RserveException(this, "OOB_MSG callback returned null", rp); // FIXME: we don't have official documentation for this - what is the // correct response to OOB_MSG? rserve-js uses cmd | RESP_OK/RESP_ERR // but that mangles low two bits of the OOB code // Rserve itself doesn't care so it is technically undefined // The most senstible thing to do is to just copy the cmd since // the recieving end knows that this is a msg response rp = rt.request(rp.getCmd(), res); } else throw new RserveException(this, "Unsupported OOB command received", rp); } if (rp == null || !rp.isOk()) throw new RserveException(this,"callOCAP failed", rp); return parseEvalResponse(rp); } /** assign a content of a REXP to a symbol in R. The symbol is created if it doesn't exist already. * @param sym symbol name. Currently assign uses CMD_setSEXP command of Rserve, i.e. the symbol value is NOT parsed. It is the responsibility of the user to make sure that the symbol name is valid in R (recall the difference between a symbol and an expression!). In fact R will always create the symbol, but it may not be accessible (examples: "bar\nfoo" or "bar$foo"). * @param rexp contents */ public void assign(String sym, REXP rexp) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); try { REXPFactory r = new REXPFactory(rexp); int rl = r.getBinaryLength(); byte[] symn = sym.getBytes(transferCharset); int sl = symn.length+1; if ((sl&3)>0) sl=(sl&0xfffffc)+4; // make sure the symbol length is divisible by 4 byte[] rq=new byte[sl+rl+((rl>0xfffff0)?12:8)]; int ic; for(ic=0;ic0xfffff0)?12:8)); RPacket rp=rt.request(RTalk.CMD_setSEXP,rq); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"assign failed",rp); } catch(java.io.UnsupportedEncodingException e) { throw new RserveException(this, "unsupported encoding in assign(String,REXP)", e); } catch (REXPMismatchException me) { throw new RserveException(this, "Error creating binary representation: "+me.getMessage(), me); } } /** open a file on the Rserve for reading @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. @return input stream to be used for reading. Note that the stream is read-once only, there is no support for seek or rewind. */ public RFileInputStream openFile(String fn) throws IOException { return new RFileInputStream(rt,fn); } /** create a file on the Rserve for writing @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. @return output stream to be used for writinging. Note that the stream is write-once only, there is no support for seek or rewind. */ public RFileOutputStream createFile(String fn) throws IOException { return new RFileOutputStream(rt,fn); } /** remove a file on the Rserve @param fn file name. should not contain any path delimiters, since Rserve may restrict the access to local working directory. */ public void removeFile(String fn) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_removeFile,fn); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"removeFile failed",rp); } /** shutdown remote Rserve. Note that some Rserves cannot be shut down from the client side. */ public void shutdown() throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_shutdown); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"shutdown failed",rp); } /** Sets send buffer size of the Rserve (in bytes) for the current connection. All responses send by Rserve are stored in the send buffer before transmitting. This means that any objects you want to get from the Rserve need to fit into that buffer. By default the size of the send buffer is 2MB. If you need to receive larger objects from Rserve, you will need to use this function to enlarge the buffer. In order to save memory, you can also reduce the buffer size once it's not used anymore. Currently the buffer size is only limited by the memory available and/or 1GB (whichever is smaller). Current Rserve implementations won't go below buffer sizes of 32kb though. If the specified buffer size results in 'out of memory' on the server, the corresponding error is sent and the connection is terminated.
Note: This command may go away in future versions of Rserve which will use dynamic send buffer allocation. @param sbs send buffer size (in bytes) min=32k, max=1GB */ public void setSendBufferSize(long sbs) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_setBufferSize,(int)sbs); if (rp!=null && rp.isOk()) return; throw new RserveException(this,"setSendBufferSize failed",rp); } /** set string encoding for this session. It is strongly * recommended to make sure the encoding is always set to UTF-8 * because that is the only encoding supported by this Java * client. It can be done either by uisng the * encoding option in the server or by calling * setStringEncoding("utf8") at the beginning of a session (but * after login). @param enc name of the encoding as defined by Rserve - as of Rserve version 0.5-3 valid values are "utf8", "latin1" and "native" (case-sensitive) @since Rserve 0.5-3 */ public void setStringEncoding(String enc) throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp = rt.request(RTalk.CMD_setEncoding, enc); if (rp != null && rp.isOk()) return; throw new RserveException(this,"setStringEncoding failed", rp); } /** login using supplied user/pwd. Note that login must be the first command if used @param user username @param pwd password */ public void login(String user, String pwd) throws RserveException { if (!authReq) return; if (!connected || rt==null) throw new RserveException(this,"Not connected"); if (authType==AT_crypt) { if (Key==null) Key="rs"; RPacket rp=rt.request(RTalk.CMD_login,user+"\n"+jcrypt.crypt(Key,pwd)); if (rp!=null && rp.isOk()) return; try { s.close(); } catch(Exception e) {}; is=null; os=null; s=null; connected=false; throw new RserveException(this,"login failed",rp); } RPacket rp=rt.request(RTalk.CMD_login,user+"\n"+pwd); if (rp!=null && rp.isOk()) return; try {s.close();} catch (Exception e) {}; is=null; os=null; s=null; connected=false; throw new RserveException(this,"login failed",rp); } /** detaches the session and closes the connection (requires Rserve 0.4+). The session can be only resumed by calling @link{RSession.attach} */ public RSession detach() throws RserveException { if (!connected || rt==null) throw new RserveException(this,"Not connected"); RPacket rp=rt.request(RTalk.CMD_detachSession); if (rp==null || !rp.isOk()) throw new RserveException(this,"Cannot detach",rp); RSession s = new RSession(this, rp); close(); return s; } /** check connection state. Note that currently this state is not checked on-the-spot, that is if connection went down by an outside event this is not reflected by the flag @return true if this connection is alive */ public boolean isConnected() { return connected; } /** check authentication requirement sent by server @return true is server requires authentication. In such case first command after connecting must be {@link #login}. */ public boolean needLogin() { return authReq; } /** get last error string @return last error string */ public String getLastError() { return lastError; } /** evaluates the given command in the master server process asynchronously (control command). Note that control commands are always asynchronous, i.e., the expression is enqueued for evaluation in the master process and the method returns before the expression is evaluated (in non-parallel builds the client has to close the connection before the expression can be evaluated). There is no way to check for errors and control commands should be sent with utmost care as they can abort the server process. The evaluation has no immediate effect on the client session. * @param cmd command/expression string * @since Rserve 0.6-0 */ public void serverEval(String cmd) throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlEval, cmd+"\n"); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverEval failed",rp); } /** sources the given file (the path must be local to the server!) in the master server process asynchronously (control command). See {@link #serverEval()} for details on control commands. * @param serverFile path to a file on the server (it is recommended to always use full paths, because the server process has a different working directory than the client child process!). * @since Rserve 0.6-0 */ public void serverSource(String serverFile) throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlSource, serverFile); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverSource failed",rp); } /** attempt to shut down the server process cleanly. Note that there is a fundamental difference between the {@link shutdown()} method and this method: serverShutdown() is a proper control command and thus fully authentication controllable, whereas {@link shutdown()} is a client-side command sent to the client child process and thus relying on the ability of the client to signal the server process which may be disabled. Therefore serverShutdown() is preferred and more reliable for Rserve 0.6-0 and higher. * @since Rserve 0.6-0 */ public void serverShutdown() throws RserveException { if (!connected || rt == null) throw new RserveException(this, "Not connected"); RPacket rp = rt.request(RTalk.CMD_ctrlShutdown); if (rp != null && rp.isOk()) return; throw new RserveException(this,"serverShutdown failed",rp); } //========= REngine interface API public REXP parse(String text, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support separate parsing step."); } public REXP eval(REXP what, REXP where, boolean resolve) throws REngineException { if (!connected || rt==null) throw new RserveException(this, "Not connected"); if (where != null) throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); try { REXPFactory r = new REXPFactory(what); int rl = r.getBinaryLength(); byte[] rq = new byte[rl + ((rl > 0xfffff0) ? 8 : 4)]; RTalk.setHdr(RTalk.DT_SEXP, rl, rq, 0); r.getBinaryRepresentation(rq, ((rl > 0xfffff0) ? 8 : 4)); RPacket rp = rt.request(resolve ? RTalk.CMD_eval : RTalk.CMD_voidEval, rq); if (rp != null && rp.isOk()) return parseEvalResponse(rp); throw new RserveException(this,"eval failed", rp); } catch (REXPMismatchException me) { throw new RserveException(this, "Error creating binary representation: " + me.getMessage(), me); } } public REXP parseAndEval(String text, REXP where, boolean resolve) throws REngineException { if (where!=null) throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); try { return eval(text); } catch (RserveException re) { throw new REngineException(this, re.getMessage(), re); } } /** assign into an environment @param symbol symbol name @param value value to assign @param env environment to assign to */ public void assign(String symbol, REXP value, REXP env) throws REngineException { if (env!=null) throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); try { assign(symbol, value); } catch (RserveException re) { throw new REngineException(this, re.getMessage(), re); } } /** get a value from an environment @param symbol symbol name @param env environment @param resolve resolve the resulting REXP or just return a reference @return value */ public REXP get(String symbol, REXP env, boolean resolve) throws REngineException { if (!resolve) throw new REngineException(this, "Rserve doesn't support references"); try { return eval(new REXPSymbol(symbol), env, true); } catch (RserveException re) { throw new REngineException(this, re.getMessage()); } } /** fetch the contents of the given reference. The resulting REXP may never be REXPReference. @param ref reference to resolve @return resolved reference */ public REXP resolveReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public REXP createReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public void finalizeReference(REXP ref) throws REngineException { throw new REngineException(this, "Rserve doesn't support references"); } public REXP getParentEnvironment(REXP env, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); } public REXP newEnvironment(REXP parent, boolean resolve) throws REngineException { throw new REngineException(this, "Rserve doesn't support environments other than .GlobalEnv"); } } rJava/jri/REngine/Rserve/test/0000755000175100001440000000000015133274032015673 5ustar hornikusersrJava/jri/REngine/Rserve/test/PlotDemo.java0000644000175100001440000000757015133274032020272 0ustar hornikusers// // PlotDemo demo - REngine and graphics // // $Id$ // import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; /** A demonstration of the use of Rserver and graphics devices to create graphics in R, pull them into Java and display them. It is a really simple demo. */ public class PlotDemo extends Canvas { public static void main(String args[]) { try { String device = "jpeg"; // device we'll call (this would work with pretty much any bitmap device) // connect to Rserve (if the user specified a server at the command line, use it, otherwise connect locally) RConnection c = new RConnection((args.length>0)?args[0]:"127.0.0.1"); // if Cairo is installed, we can get much nicer graphics, so try to load it if (c.parseAndEval("suppressWarnings(require('Cairo',quietly=TRUE))").asInteger()>0) device="CairoJPEG"; // great, we can use Cairo device else System.out.println("(consider installing Cairo package for better bitmap output)"); // we are careful here - not all R binaries support jpeg // so we rather capture any failures REXP xp = c.parseAndEval("try("+device+"('test.jpg',quality=90))"); if (xp.inherits("try-error")) { // if the result is of the class try-error then there was a problem System.err.println("Can't open "+device+" graphics device:\n"+xp.asString()); // this is analogous to 'warnings', but for us it's sufficient to get just the 1st warning REXP w = c.eval("if (exists('last.warning') && length(last.warning)>0) names(last.warning)[1] else 0"); if (w.isString()) System.err.println(w.asString()); return; } // ok, so the device should be fine - let's plot - replace this by any plotting code you desire ... c.parseAndEval("data(iris); attach(iris); plot(Sepal.Length, Petal.Length, col=unclass(Species)); dev.off()"); // There is no I/O API in REngine because it's actually more efficient to use R for this // we limit the file size to 1MB which should be sufficient and we delete the file as well xp = c.parseAndEval("r=readBin('test.jpg','raw',1024*1024); unlink('test.jpg'); r"); // now this is pretty boring AWT stuff - create an image from the data and display it ... Image img = Toolkit.getDefaultToolkit().createImage(xp.asBytes()); Frame f = new Frame("Test image"); f.add(new PlotDemo(img)); f.addWindowListener(new WindowAdapter() { // just so we can close the window public void windowClosing(WindowEvent e) { System.exit(0); } }); f.pack(); f.setVisible(true); // close RConnection, we're done c.close(); } catch (RserveException rse) { // RserveException (transport layer - e.g. Rserve is not running) System.out.println(rse); } catch (REXPMismatchException mme) { // REXP mismatch exception (we got something we didn't think we get) System.out.println(mme); mme.printStackTrace(); } catch(Exception e) { // something else System.out.println("Something went wrong, but it's not the Rserve: " +e.getMessage()); e.printStackTrace(); } } Image img; public PlotDemo(Image img) { this.img=img; MediaTracker mediaTracker = new MediaTracker(this); mediaTracker.addImage(img, 0); try { mediaTracker.waitForID(0); } catch (InterruptedException ie) { System.err.println(ie); System.exit(1); } setSize(img.getWidth(null), img.getHeight(null)); } public void paint(Graphics g) { g.drawImage(img, 0, 0, null); } } rJava/jri/REngine/Rserve/test/Makefile0000644000175100001440000000213115133274037017335 0ustar hornikusersJAVA=java JAVAC=javac JFLAGS+=-encoding utf8 -source 1.6 -target 1.6 all: test PlotDemo.class StartRserve.class ../Rserve.jar: ../../REngine.jar $(MAKE) -C .. Rserve.jar ../../REngine.jar: $(MAKE) -C ../.. REngine.jar test: test.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. test test.class: test.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. test.java PlotDemo.class: PlotDemo.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. $< PlotDemo: PlotDemo.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. $@ jt: jt.class ../Rserve.jar ../../REngine.jar $(JAVA) -cp ../Rserve.jar:../../REngine.jar:. $@ jt.class: jt.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. jt.java StartRserve.class: StartRserve.java ../Rserve.jar ../../REngine.jar $(JAVAC) $(JFLAGS) -d . -cp ../Rserve.jar:../../REngine.jar:. StartRserve.java clean: rm -rf org *~ *.class .PHONY: test all clean rJava/jri/REngine/Rserve/test/test.java0000644000175100001440000003417115133274032017523 0ustar hornikusersimport org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; class TestException extends Exception { public TestException(String msg) { super(msg); } } public class test { public static void main(String[] args) { try { RConnection c = new RConnection(); // REngine is the backend-agnostic API -- using eng instead of c makes sure that we don't use Rserve extensions inadvertently REngine eng = (REngine) c; System.out.println(">>" + c.eval("R.version$version.string").asString() + "<<"); { System.out.println("* Test string and list retrieval"); RList l = c.eval("{d=data.frame(\"huhu\",c(11:20)); lapply(d,as.character)}").asList(); int cols = l.size(); int rows = l.at(0).length(); String[][] s = new String[cols][]; for (int i=0; i= 0) { String s = line.substring(i + 11).trim(); int j = s.indexOf("REG_SZ"); if (j >= 0) s = s.substring(j + 6).trim(); installPath = s; System.out.println("R InstallPath = "+s); } } else System.out.println("Rserve>" + line); } } catch (IOException e) { e.printStackTrace(); } } } /** simple class that start Rserve locally if it's not running already - see mainly checkLocalRserve method. It spits out quite some debugging outout of the console, so feel free to modify it for your application if desired.

Important: All applications should shutdown every Rserve that they started! Never leave Rserve running if you started it after your application quits since it may pose a security risk. Inform the user if you started an Rserve instance. */ public class StartRserve { /** shortcut to launchRserve(cmd, "--no-save --slave", "--no-save --slave", false) */ public static boolean launchRserve(String cmd) { return launchRserve(cmd, "--no-save --slave","--no-save --slave",false); } /** attempt to start Rserve. Note: parameters are not quoted, so avoid using any quotes in arguments @param cmd command necessary to start R @param rargs arguments are are to be passed to R @param rsrvargs arguments to be passed to Rserve @return true if Rserve is running or was successfully started, false otherwise. */ public static boolean launchRserve(String cmd, String rargs, String rsrvargs, boolean debug) { try { Process p; boolean isWindows = false; String osname = System.getProperty("os.name"); if (osname != null && osname.length() >= 7 && osname.substring(0,7).equals("Windows")) { isWindows = true; /* Windows startup */ p = Runtime.getRuntime().exec("\""+cmd+"\" -e \"library(Rserve);Rserve("+(debug?"TRUE":"FALSE")+",args='"+rsrvargs+"')\" "+rargs); } else /* unix startup */ p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "echo 'library(Rserve);Rserve("+(debug?"TRUE":"FALSE")+",args=\""+rsrvargs+"\")'|"+cmd+" "+rargs }); System.out.println("waiting for Rserve to start ... ("+p+")"); // we need to fetch the output - some platforms will die if you don't ... StreamHog errorHog = new StreamHog(p.getErrorStream(), false); StreamHog outputHog = new StreamHog(p.getInputStream(), false); if (!isWindows) /* on Windows the process will never return, so we cannot wait */ p.waitFor(); System.out.println("call terminated, let us try to connect ..."); } catch (Exception x) { System.out.println("failed to start Rserve process with "+x.getMessage()); return false; } int attempts = 5; /* try up to 5 times before giving up. We can be conservative here, because at this point the process execution itself was successful and the start up is usually asynchronous */ while (attempts > 0) { try { RConnection c = new RConnection(); System.out.println("Rserve is running."); c.close(); return true; } catch (Exception e2) { System.out.println("Try failed with: "+e2.getMessage()); } /* a safety sleep just in case the start up is delayed or asynchronous */ try { Thread.sleep(500); } catch (InterruptedException ix) { }; attempts--; } return false; } /** checks whether Rserve is running and if that's not the case it attempts to start it using the defaults for the platform where it is run on. This method is meant to be set-and-forget and cover most default setups. For special setups you may get more control over R with <launchRserve instead. */ public static boolean checkLocalRserve() { if (isRserveRunning()) return true; String osname = System.getProperty("os.name"); if (osname != null && osname.length() >= 7 && osname.substring(0,7).equals("Windows")) { System.out.println("Windows: query registry to find where R is installed ..."); String installPath = null; try { Process rp = Runtime.getRuntime().exec("reg query HKLM\\Software\\R-core\\R"); StreamHog regHog = new StreamHog(rp.getInputStream(), true); rp.waitFor(); regHog.join(); installPath = regHog.getInstallPath(); } catch (Exception rge) { System.out.println("ERROR: unable to run REG to find the location of R: "+rge); return false; } if (installPath == null) { System.out.println("ERROR: canot find path to R. Make sure reg is available and R was installed with registry settings."); return false; } return launchRserve(installPath+"\\bin\\R.exe"); } return (launchRserve("R") || /* try some common unix locations of R */ ((new File("/Library/Frameworks/R.framework/Resources/bin/R")).exists() && launchRserve("/Library/Frameworks/R.framework/Resources/bin/R")) || ((new File("/usr/local/lib/R/bin/R")).exists() && launchRserve("/usr/local/lib/R/bin/R")) || ((new File("/usr/lib/R/bin/R")).exists() && launchRserve("/usr/lib/R/bin/R")) || ((new File("/usr/local/bin/R")).exists() && launchRserve("/usr/local/bin/R")) || ((new File("/sw/bin/R")).exists() && launchRserve("/sw/bin/R")) || ((new File("/usr/common/bin/R")).exists() && launchRserve("/usr/common/bin/R")) || ((new File("/opt/bin/R")).exists() && launchRserve("/opt/bin/R")) ); } /** check whether Rserve is currently running (on local machine and default port). @return true if local Rserve instance is running, false otherwise */ public static boolean isRserveRunning() { try { RConnection c = new RConnection(); System.out.println("Rserve is running."); c.close(); return true; } catch (Exception e) { System.out.println("First connect try failed with: "+e.getMessage()); } return false; } /** just a demo main method which starts Rserve and shuts it down again */ public static void main(String[] args) { System.out.println("result="+checkLocalRserve()); try { RConnection c=new RConnection(); c.shutdown(); } catch (Exception x) {}; } } rJava/jri/REngine/Rserve/test/jt.java0000644000175100001440000000205315133274032017153 0ustar hornikusersimport java.io.*; import org.rosuda.REngine.*; import org.rosuda.REngine.Rserve.*; public class jt { public static void main(String[] args) { try { RConnection c = new RConnection((args.length>0)?args[0]:"127.0.0.1"); BufferedReader ir=new BufferedReader(new InputStreamReader(System.in)); String s=null; System.out.print("> "); while ((s=ir.readLine()).length() > 0) { if (s.equals("shutdown")) { System.out.println("Sending shutdown request"); c.shutdown(); System.out.println("Shutdown successful. Quitting console."); return; } else { REXP rx = c.parseAndEval(s); System.out.println("result(debug): "+rx.toDebugString()); } System.out.print("> "); } } catch (RserveException rse) { System.out.println(rse); /* } catch (REXPMismatchException mme) { System.out.println(mme); mme.printStackTrace(); */ } catch (Exception e) { e.printStackTrace(); } } } rJava/jri/REngine/Rserve/RserveException.java0000644000175100001440000000563115133274032020711 0ustar hornikusers// JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- // // RserveException.java // // Created by Simon Urbanek on Mon Aug 18 2003. // // $Id$ // package org.rosuda.REngine.Rserve; import org.rosuda.REngine.Rserve.protocol.RPacket; import org.rosuda.REngine.Rserve.protocol.RTalk; import org.rosuda.REngine.REngineException; public class RserveException extends REngineException { protected String err; protected int reqReturnCode; public String getRequestErrorDescription() { return getRequestErrorDescription(reqReturnCode); } public String getRequestErrorDescription(int code) { switch(code) { case 0: return "no error"; case 2: return "R parser: input incomplete"; case 3: return "R parser: syntax error"; case RTalk.ERR_auth_failed: return "authorization failed"; case RTalk.ERR_conn_broken: return "connection broken"; case RTalk.ERR_inv_cmd: return "invalid command"; case RTalk.ERR_inv_par: return "invalid parameter"; case RTalk.ERR_IOerror: return "I/O error on the server"; case RTalk.ERR_not_open: return "connection is not open"; case RTalk.ERR_access_denied: return "access denied (local to the server)"; case RTalk.ERR_unsupported_cmd: return "unsupported command"; case RTalk.ERR_unknown_cmd: return "unknown command"; case RTalk.ERR_data_overflow: return "data overflow, incoming data too big"; case RTalk.ERR_object_too_big: return "evaluation successful, but returned object is too big to transport"; case RTalk.ERR_out_of_mem: return "FATAL: Rserve ran out of memory, closing connection"; case RTalk.ERR_session_busy: return "session is busy"; case RTalk.ERR_detach_failed: return "session detach failed"; case RTalk.ERR_ctrl_closed: return "control pipe to master process is closed/broken"; } return "error code: "+code; } public String getMessage() { return super.getMessage() + ((reqReturnCode != -1) ? ", request status: " + getRequestErrorDescription() : ""); } public RserveException(RConnection c, String msg) { this(c,msg,-1); } public RserveException(RConnection c, String msg, Throwable cause) { super(c, msg, cause); reqReturnCode = -1; if (c != null) c.lastError = getMessage(); } public RserveException(RConnection c, String msg, int requestReturnCode) { super(c, msg); reqReturnCode = requestReturnCode; if (c != null) c.lastError = getMessage(); } public RserveException(RConnection c, String msg, RPacket p) { this(c, msg, (p == null) ? -1 : p.getStat()); } public int getRequestReturnCode() { return reqReturnCode; } } rJava/jri/REngine/Rserve/package-info.java0000644000175100001440000000017515133274032020106 0ustar hornikusers/** * REngine-based interface to Rserve */ package org.rosuda.REngine.Rserve ; rJava/jri/REngine/Rserve/StartRserve.java0000644000175100001440000001675515133274032020061 0ustar hornikuserspackage org.rosuda.REngine.Rserve; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; /** * helper class that consumes output of a process. In addition, it filters output * of the REG command on Windows to look for InstallPath registry entry which * specifies the location of R. */ class StreamHog extends Thread { InputStream is; boolean capture; String installPath; StreamHog(InputStream is, boolean capture) { this.is = is; this.capture = capture; start(); } public String getInstallPath() { return installPath; } public void run() { try { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = null; while ((line = br.readLine()) != null) { if (capture) { // we are supposed to capture the output from REG command int i = line.indexOf("InstallPath"); if (i >= 0) { String s = line.substring(i + 11).trim(); int j = s.indexOf("REG_SZ"); if (j >= 0) { s = s.substring(j + 6).trim(); } installPath = s; System.out.println("StartRserve: R InstallPath = " + s); } } else { System.out.println("StartRserve: Rserve>" + line); } } } catch (IOException e) { e.printStackTrace(); } } } /** * simple class that start Rserve locally if it's not running already - see * mainly checkLocalRserve method. It spits out quite some * debugging outout of the console, so feel free to modify it for your * application if desired.

* Important: All applications should shutdown every Rserve that they * started! Never leave Rserve running if you started it after your application * quits since it may pose a security risk. Inform the user if you started an * Rserve instance. */ public class StartRserve { /** * shortcut to * launchRserve(cmd, "--no-save --slave", "--no-save --slave", false) */ public static boolean launchRserve(String cmd) { return launchRserve(cmd, "--no-save --slave", "--no-save --slave", false); } /** * attempt to start Rserve. Note: parameters are not quoted, so avoid * using any quotes in arguments * * @param cmd command necessary to start R * @param rargs arguments are are to be passed to R * @param rsrvargs arguments to be passed to Rserve * @return true if Rserve is running or was successfully started, * false otherwise. */ public static boolean launchRserve(String cmd, String rargs, String rsrvargs, boolean debug) { try { Process p; boolean isWindows = false; String osname = System.getProperty("os.name"); if (osname != null && osname.length() >= 7 && osname.substring(0, 7).equals("Windows")) { isWindows = true; /* Windows startup */ p = Runtime.getRuntime().exec("\"" + cmd + "\" -e \"library(Rserve);Rserve(" + (debug ? "TRUE" : "FALSE") + ",args='" + rsrvargs + "')\" " + rargs); } else /* unix startup */ { p = Runtime.getRuntime().exec(new String[]{ "/bin/sh", "-c", "echo 'library(Rserve);Rserve(" + (debug ? "TRUE" : "FALSE") + ",args=\"" + rsrvargs + "\")'|" + cmd + " " + rargs }); } System.out.println("StartRserve: waiting for Rserve to start ... (" + p + ")"); // we need to fetch the output - some platforms will die if you don't ... StreamHog errorHog = new StreamHog(p.getErrorStream(), false); StreamHog outputHog = new StreamHog(p.getInputStream(), false); if (!isWindows) /* on Windows the process will never return, so we cannot wait */ { p.waitFor(); } System.out.println("StartRserve: call terminated, let us try to connect ..."); } catch (Exception x) { System.out.println("StartRserve: failed to start Rserve process with " + x.getMessage()); return false; } int attempts = 5; /* try up to 5 times before giving up. We can be conservative here, because at this point the process execution itself was successful and the start up is usually asynchronous */ while (attempts > 0) { try { RConnection c = new RConnection(); c.close(); return true; } catch (Exception e2) { System.out.println("StartRserve: Try failed with: " + e2.getMessage()); } /* a safety sleep just in case the start up is delayed or asynchronous */ try { Thread.sleep(500); } catch (InterruptedException ix) { }; attempts--; } return false; } /** * checks whether Rserve is running and if that's not the case it attempts to * start it using the defaults for the platform where it is run on. This * method is meant to be set-and-forget and cover most default setups. For * special setups you may get more control over R with * <launchRserve instead. */ public static boolean checkLocalRserve() { if (isRserveRunning()) { return true; } String osname = System.getProperty("os.name"); if (osname != null && osname.length() >= 7 && osname.substring(0, 7).equals("Windows")) { System.out.println("StartRserve: Windows: query registry to find where R is installed ..."); String installPath = null; try { Process rp = Runtime.getRuntime().exec("reg query HKLM\\Software\\R-core\\R"); StreamHog regHog = new StreamHog(rp.getInputStream(), true); rp.waitFor(); regHog.join(); installPath = regHog.getInstallPath(); } catch (Exception rge) { System.out.println("ERROR: unable to run REG to find the location of R: " + rge); return false; } if (installPath == null) { System.out.println("ERROR: canot find path to R. Make sure reg is available and R was installed with registry settings."); return false; } return launchRserve(installPath + "\\bin\\R.exe"); } return (launchRserve("R") || /* try some common unix locations of R */ ((new File("/Library/Frameworks/R.framework/Resources/bin/R")).exists() && launchRserve("/Library/Frameworks/R.framework/Resources/bin/R")) || ((new File("/usr/local/lib/R/bin/R")).exists() && launchRserve("/usr/local/lib/R/bin/R")) || ((new File("/usr/lib/R/bin/R")).exists() && launchRserve("/usr/lib/R/bin/R")) || ((new File("/usr/local/bin/R")).exists() && launchRserve("/usr/local/bin/R")) || ((new File("/sw/bin/R")).exists() && launchRserve("/sw/bin/R")) || ((new File("/usr/common/bin/R")).exists() && launchRserve("/usr/common/bin/R")) || ((new File("/opt/bin/R")).exists() && launchRserve("/opt/bin/R"))); } /** * check whether Rserve is currently running (on local machine and default * port). * * @return true if local Rserve instance is running, * false otherwise */ public static boolean isRserveRunning() { try { RConnection c = new RConnection(); c.close(); return true; } catch (Exception e) { System.out.println("StartRserve: first connect try failed with: " + e.getMessage()); } return false; } /** * just a demo main method which starts Rserve and shuts it down again */ public static void main(String[] args) { System.out.println("result=" + checkLocalRserve()); try { RConnection c = new RConnection(); c.shutdown(); } catch (Exception x) { }; } } rJava/jri/REngine/REngineOutputInterface.java0000644000175100001440000000143515133274032020705 0ustar hornikuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward output callbacks from R. */ public interface REngineOutputInterface { /** called when R prints output to the console. * @param eng calling engine * @param text text to display in the console * @param oType output type (0=regular, 1=error/warning) */ public void RWriteConsole(REngine eng, String text, int oType); /** called when R wants to show a warning/error message box (not console-related). * @param eng calling engine * @param text text to display in the message */ public void RShowMessage(REngine eng, String text); /** called by R to flush (display) any pending console output. * @param eng calling engine */ public void RFlushConsole(REngine eng); } rJava/jri/REngine/REXPS4.java0000644000175100001440000000027415133274032015301 0ustar hornikuserspackage org.rosuda.REngine; /** S4 REXP is a completely vanilla REXP */ public class REXPS4 extends REXP { public REXPS4() { super(); } public REXPS4(REXPList attr) { super(attr); } } rJava/jri/REngine/REXPNull.java0000644000175100001440000000174015133274032015724 0ustar hornikuserspackage org.rosuda.REngine; /** represents a NULL object in R.

Note: there is a slight asymmetry - in R NULL is represented by a zero-length pairlist. For this reason REXPNull returns true for {@link #isList()} and {@link #asList()} will return an empty list. Nonetheless REXPList of the length 0 will NOT return true in {@link #isNull()} (currently), becasue it is considered a different object in Java. These nuances are still subject to change, because it's not clear how it should be treated. At any rate use REXPNull instead of empty REXPList if NULL is the intended value. */ public class REXPNull extends REXP { public REXPNull() { super(); } public REXPNull(REXPList attr) { super(attr); } public boolean isNull() { return true; } public boolean isList() { return true; } // NULL is a list public RList asList() { return new RList(); } public Object asNativeJavaObject() { return null; } } rJava/jri/REngine/REngineStdOutput.java0000644000175100001440000000074215133274032017537 0ustar hornikuserspackage org.rosuda.REngine; /** implementation of the {@link REngineOutputInterface} which uses standard output. */ public class REngineStdOutput implements REngineCallbacks, REngineOutputInterface { public synchronized void RWriteConsole(REngine eng, String text, int oType) { ((oType == 0) ? System.out : System.err).print(text); } public void RShowMessage(REngine eng, String text) { System.err.println("*** "+text); } public void RFlushConsole(REngine eng) { } } rJava/jri/REngine/REXPInteger.java0000644000175100001440000000415715133274032016414 0ustar hornikuserspackage org.rosuda.REngine; /** REXPDouble represents a vector of integer values. */ public class REXPInteger extends REXPVector { protected int[] payload; /** NA integer value as defined in R. Unlike its real equivalent this one can be used in comparisons, although {@link #isNA(int) } is provided for consistency. */ public static final int NA = -2147483648; public static boolean isNA(int value) { return (value == NA); } /** create integer vector of the length 1 with the given value as its first (and only) element */ public REXPInteger(int load) { super(); payload=new int[] { load }; } /** create integer vector with the payload specified by load */ public REXPInteger(int[] load) { super(); payload=(load==null)?new int[0]:load; } /** create integer vector with the payload specified by load and attributes attr */ public REXPInteger(int[] load, REXPList attr) { super(attr); payload=(load==null)?new int[0]:load; } public Object asNativeJavaObject() { return payload; } public int length() { return payload.length; } public boolean isInteger() { return true; } public boolean isNumeric() { return true; } public int[] asIntegers() { return payload; } /** returns the contents of this vector as doubles */ public double[] asDoubles() { double[] d = new double[payload.length]; int i = 0; while (i < payload.length) { d[i] = (double) payload[i]; i++; } return d; } /** returns the contents of this vector as strings */ public String[] asStrings() { String[] s = new String[payload.length]; int i = 0; while (i < payload.length) { s[i] = ""+payload[i]; i++; } return s; } public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = (payload[i]==NA); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append(payload[i]); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } rJava/jri/REngine/REXPMismatchException.java0000644000175100001440000000360615133274032020441 0ustar hornikusers// REngine - generic Java/R API // // Copyright (C) 2007,2008 Simon Urbanek // --- for licensing information see LICENSE file in the distribution --- // // REXPMismatch.java // // Created by Simon Urbanek on 2007/05/03 // // $Id: REngineException.java 2555 2006-06-21 20:36:42Z urbaneks $ // package org.rosuda.REngine; /** This exception is thrown whenever the operation requested is not supported by the given R object type, e.g. using asStrings on an S4 object. Most {@link REXP} methods throw this exception. Previous R/Java interfaces were silently returning null in those cases, but using exceptions helps to write more robust code. */ public class REXPMismatchException extends Exception { REXP sender; String access; /** primary constructor. The exception message will be formed as "attempt to access <REXP-class> as <access-string>" * @param sender R object that triggered this exception (cannot be null!) * @param access assumed type of the access that was requested. It should be a simple name of the assumed type (e.g. "vector"). The type name can be based on R semantics beyond basic types reflected by REXP classes. In cases where certain assertions were not satisfied, the string should be of the form "type (assertion)" (e.g. "data frame (must have dim>0)"). */ public REXPMismatchException(REXP sender, String access) { super("attempt to access "+sender.getClass().getName()+" as "+access); this.sender = sender; this.access = access; } /** retrieve the exception sender/origin * @return REXP object that triggered the exception */ public REXP getSender() { return sender; } /** get the assumed access type that was violated by the sender. * @return string describing the access type. See {@link #REXPMismatchException} for details. */ public String getAccess() { return access; } } rJava/jri/REngine/REXPDouble.java0000644000175100001440000000556015133274032016230 0ustar hornikuserspackage org.rosuda.REngine; /** REXPDouble represents a vector of double precision floating point values. */ public class REXPDouble extends REXPVector { private double[] payload; /** NA real value as defined in R. Note: it can NOT be used in comparisons, you must use {@link #isNA(double)} instead. */ public static final double NA = Double.longBitsToDouble(0x7ff00000000007a2L); /** Java screws up the bits in NA real values, so we cannot compare to the real bits used by R (0x7ff00000000007a2L) but use this value which is obtained by passing the bits through Java's double type */ static final long NA_bits = Double.doubleToRawLongBits(Double.longBitsToDouble(0x7ff00000000007a2L)); /** checks whether a given double value is a NA representation in R. Note that NA is NaN but not all NaNs are NA. */ public static boolean isNA(double value) { /* on OS X i386 the MSB of the fraction is set even though R doesn't set it. Although this is technically a good idea (to make it a QNaN) it's not what R does and thus makes the comparison tricky */ return (Double.doubleToRawLongBits(value) & 0xfff7ffffffffffffL) == (NA_bits & 0xfff7ffffffffffffL); } /** create real vector of the length 1 with the given value as its first (and only) element */ public REXPDouble(double load) { super(); payload=new double[] { load }; } public REXPDouble(double[] load) { super(); payload=(load==null)?new double[0]:load; } public REXPDouble(double[] load, REXPList attr) { super(attr); payload=(load==null)?new double[0]:load; } public int length() { return payload.length; } public Object asNativeJavaObject() { return payload; } /** return true */ public boolean isNumeric() { return true; } /** returns the values represented by this vector */ public double[] asDoubles() { return payload; } /** converts the values of this vector into integers by cast */ public int[] asIntegers() { int[] a = new int[payload.length]; int i = 0; while (i < payload.length) { a[i] = (int) payload[i]; i++; } return a; } /** converts the values of this vector into strings */ public String[] asStrings() { String[] s = new String[payload.length]; int i = 0; while (i < payload.length) { s[i] = ""+payload[i]; i++; } return s; } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values (including NaNs) */ public boolean[] isNA() { boolean a[] = new boolean[payload.length]; int i = 0; while (i < a.length) { a[i] = isNA(payload[i]); i++; } return a; } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.length && i < maxDebugItems) { if (i>0) sb.append(","); sb.append(payload[i]); i++; } if (i < payload.length) sb.append(",.."); return sb.toString()+"}"; } } rJava/jri/REngine/REngineUIInterface.java0000644000175100001440000000146515133274032017725 0ustar hornikuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward user interface callbacks from R. */ public interface REngineUIInterface { /** called when the busy state of R changes - usual response is to change the shape of the cursor * @param eng calling engine * @param state busy state of R (0 = not busy) */ public void RBusyState (REngine eng, int state); /** called when R wants the user to choose a file. * @param eng calling engine * @param newFile if true then the user can specify a non-existing file to be created, otherwise an existing file must be selected. * @return full path and name of the selected file or null if the selection was cancelled. */ public String RChooseFile (REngine eng, boolean newFile); } rJava/jri/REngine/LICENSE0000644000175100001440000000140215133274032014450 0ustar hornikusersREngine - Java interface to R Copyright (C) 2004,5,6,7 Simon Urbanek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA rJava/jri/REngine/RFactor.java0000644000175100001440000001355115133274032015656 0ustar hornikuserspackage org.rosuda.REngine; // REngine // Copyright (C) 2007 Simon Urbanek // --- for licensing information see LICENSE file in the original distribution --- import java.util.*; /** representation of a factor variable. In R there is no actual object type called "factor", instead it is coded as an int vector with a list attribute. The parser code of REXP converts such constructs directly into the RFactor objects and defines an own XT_FACTOR type @version $Id$ */ public class RFactor { int ids[]; String levels[]; int index_base; /** create a new, empty factor var */ public RFactor() { ids=new int[0]; levels=new String[0]; } /** create a new factor variable, based on the supplied arrays. @param i array of IDs (inde_base..v.length+index_base-1) @param v values - cotegory names @param copy copy above vaules or just retain them @param index_base index of the first level element (1 for R factors, cannot be negtive) */ public RFactor(int[] i, String[] v, boolean copy, int index_base) { if (i==null) i = new int[0]; if (v==null) v = new String[0]; if (copy) { ids=new int[i.length]; System.arraycopy(i,0,ids,0,i.length); levels=new String[v.length]; System.arraycopy(v,0,levels,0,v.length); } else { ids=i; levels=v; } this.index_base = index_base; } /** create a new factor variable by factorizing a given string array. The levels will be created in the orer of appearance. @param c contents @param index_base base of the level index */ public RFactor(String c[], int index_base) { this.index_base = index_base; if (c == null) c = new String[0]; Vector lv = new Vector(); ids = new int[c.length]; int i = 0; while (i < c.length) { int ix = (c[i]==null)?-1:lv.indexOf(c[i]); if (ix<0 && c[i]!=null) { ix = lv.size(); lv.add(c[i]); } ids[i] = (ix<0)?REXPInteger.NA:(ix+index_base); i++; } levels = new String[lv.size()]; i = 0; while (i < levels.length) { levels[i] = (String) lv.elementAt(i); i++; } } /** same as RFactor(c, 1) */ public RFactor(String c[]) { this(c, 1); } /** same as RFactor(i,v, true, 1) */ public RFactor(int[] i, String[] v) { this(i, v, true, 1); } /** returns the level of a given case @param i case number @return name. may throw exception if out of range */ public String at(int i) { int li = ids[i] - index_base; return (li<0||li>levels.length)?null:levels[li]; } /** returns true if the data contain the given level index */ public boolean contains(int li) { int i = 0; while (i < ids.length) { if (ids[i] == li) return true; i++; } return false; } /** return true if the factor contains the given level (it is NOT the same as levelIndex==-1!) */ public boolean contains(String name) { int li = levelIndex(name); if (li<0) return false; int i = 0; while (i < ids.length) { if (ids[i] == li) return true; i++; } return false; } /** count the number of occurences of a given level index */ public int count(int levelIndex) { int i = 0; int ct = 0; while (i < ids.length) { if (ids[i] == levelIndex) ct++; i++; } return ct; } /** count the number of occurences of a given level name */ public int count(String name) { return count(levelIndex(name)); } /** return an array with level counts. */ public int[] counts() { int[] c = new int[levels.length]; int i = 0; while (i < ids.length) { final int li = ids[i] - index_base; if (li>=0 && lilevels.length)?null:levels[li]; } /** return the level index for a given case */ public int indexAt(int i) { return ids[i]; } /** return the factor as an array of strings */ public String[] asStrings() { String[] s = new String[ids.length]; int i = 0; while (i < ids.length) { s[i] = at(i); i++; } return s; } /** return the base of the levels index */ public int indexBase() { return index_base; } /** returns the number of cases */ public int size() { return ids.length; } public String toString() { return super.toString()+"["+ids.length+","+levels.length+",#"+index_base+"]"; } /** displayable representation of the factor variable public String toString() { //return "{"+((val==null)?";":("levels="+val.size()+";"))+((id==null)?"":("cases="+id.size()))+"}"; StringBuffer sb=new StringBuffer("{levels=("); if (val==null) sb.append("null"); else for (int i=0;i0)?",\"":"\""); sb.append((String)val.elementAt(i)); sb.append("\""); }; sb.append("),ids=("); if (id==null) sb.append("null"); else for (int i=0;i0) sb.append(","); sb.append((Integer)id.elementAt(i)); }; sb.append(")}"); return sb.toString(); } */ } rJava/jri/REngine/package-info.java0000644000175100001440000000011015133274032016625 0ustar hornikusers/** * High level java interface to R */ package org.rosuda.REngine ; rJava/jri/REngine/REngineEvalException.java0000644000175100001440000000235015133274032020327 0ustar hornikuserspackage org.rosuda.REngine ; /** * Exception thrown when an error occurs during eval. * *

* This class is a placeholder and should be extended when more information * can be extracted from R (call stack, etc ... ) *

*/ public class REngineEvalException extends REngineException { /** * Value returned by the rniEval native method when the input passed to eval * is invalid */ public static final int INVALID_INPUT = -1 ; /** * Value returned by the rniEval native method when an error occured during * eval (stop, ...) */ public static final int ERROR = -2 ; /** * Type of eval error */ protected int type ; /** * Constructor * * @param eng associated REngine * @param message error message * @param type type of error (ERROR or INVALID_INPUT) */ public REngineEvalException( REngine eng, String message, int type ){ super( eng, message ); this.type = type ; } /** * Constructor using ERROR type * * @param eng associated REngine * @param message error message */ public REngineEvalException( REngine eng, String message){ this( eng, message, ERROR ); } /** * @return the type of error (ERROR or INVALID_INPUT) */ public int getType(){ return type ; } } rJava/jri/REngine/MutableREXP.java0000644000175100001440000000016215133274032016400 0ustar hornikuserspackage org.rosuda.REngine; public interface MutableREXP { public void setAttribute(String name, REXP value); } rJava/jri/REngine/REXPUnknown.java0000644000175100001440000000175315133274032016455 0ustar hornikuserspackage org.rosuda.REngine; /** REXPUnknown is a stand-in for an object that cannot be represented in the REngine hierarchy. Usually this class can be encountered when new types are introduced in R or if a given engine doesn't support all data types. Usually REXPUnknown can only be retrieved from the engine but never assigned. */ public class REXPUnknown extends REXP { /** type of the unterlying obejct */ int type; /** creates a new unknown object of the given type * @param type internal R type code of this object */ public REXPUnknown(int type) { super(); this.type=type; } /** creates a new unknown object of the given type * @param type internal R type code of this object * @param attr attributes */ public REXPUnknown(int type, REXPList attr) { super(attr); this.type=type; } /** returns the internal R type of this unknown obejct * @return type code */ public int getType() { return type; } public String toString() { return super.toString()+"["+type+"]"; } } rJava/jri/REngine/REXPSymbol.java0000644000175100001440000000134215133274032016255 0ustar hornikuserspackage org.rosuda.REngine; /** REXPSymbol represents a symbol in R. */ public class REXPSymbol extends REXP { /** name of the symbol */ private String name; /** create a new symbol of the given name */ public REXPSymbol(String name) { super(); this.name=(name==null)?"":name; } public boolean isSymbol() { return true; } /** returns the name of the symbol * @return name of the symbol */ public String asString() { return name; } public String[] asStrings() { return new String[] { name }; } public String toString() { return getClass().getName()+"["+name+"]"; } public String toDebugString() { return super.toDebugString()+"["+name+"]"; } public Object asNativeJavaObject() { return name; } } rJava/jri/REngine/REXP.java0000644000175100001440000003676315133274032015106 0ustar hornikuserspackage org.rosuda.REngine; /** Basic class representing an object of any type in R. Each type in R in represented by a specific subclass.

This class defines basic accessor methods (asXXX), type check methods (isXXX), gives access to attributes ({@link #getAttribute}, {@link #hasAttribute}) as well as several convenience methods. If a given method is not applicable to a particular type, it will throw the {@link REXPMismatchException} exception.

This root class will throw on any accessor call and returns false for all type methods. This allows subclasses to override accessor and type methods selectively. */ public class REXP { /** attribute list. This attribute should never be accessed directly. */ protected REXPList attr; /** public root contrsuctor, same as new REXP(null) */ public REXP() { } /** public root constructor @param attr attribute list object (can be null */ public REXP(REXPList attr) { this.attr=attr; } // type checks /** check whether the REXP object is a character vector (string) @return true if the receiver is a character vector, false otherwise */ public boolean isString() { return false; } /** check whether the REXP object is a numeric vector @return true if the receiver is a numeric vector, false otherwise */ public boolean isNumeric() { return false; } /** check whether the REXP object is an integer vector @return true if the receiver is an integer vector, false otherwise */ public boolean isInteger() { return false; } /** check whether the REXP object is NULL @return true if the receiver is NULL, false otherwise */ public boolean isNull() { return false; } /** check whether the REXP object is a factor @return true if the receiver is a factor, false otherwise */ public boolean isFactor() { return false; } /** check whether the REXP object is a list (either generic vector or a pairlist - i.e. {@link #asList()} will succeed) @return true if the receiver is a generic vector or a pair-list, false otherwise */ public boolean isList() { return false; } /** check whether the REXP object is a pair-list @return true if the receiver is a pair-list, false otherwise */ public boolean isPairList() { return false; } /** check whether the REXP object is a logical vector @return true if the receiver is a logical vector, false otherwise */ public boolean isLogical() { return false; } /** check whether the REXP object is an environment @return true if the receiver is an environment, false otherwise */ public boolean isEnvironment() { return false; } /** check whether the REXP object is a language object @return true if the receiver is a language object, false otherwise */ public boolean isLanguage() { return false; } /** check whether the REXP object is an expression vector @return true if the receiver is an expression vector, false otherwise */ public boolean isExpression() { return false; } /** check whether the REXP object is a symbol @return true if the receiver is a symbol, false otherwise */ public boolean isSymbol() { return false; } /** check whether the REXP object is a vector @return true if the receiver is a vector, false otherwise */ public boolean isVector() { return false; } /** check whether the REXP object is a raw vector @return true if the receiver is a raw vector, false otherwise */ public boolean isRaw() { return false; } /** check whether the REXP object is a complex vector @return true if the receiver is a complex vector, false otherwise */ public boolean isComplex() { return false; } /** check whether the REXP object is a recursive obejct @return true if the receiver is a recursive object, false otherwise */ public boolean isRecursive() { return false; } /** check whether the REXP object is a reference to an R object @return true if the receiver is a reference, false otherwise */ public boolean isReference() { return false; } // basic accessor methods /** returns the contents as an array of Strings (if supported by the represented object) */ public String[] asStrings() throws REXPMismatchException { throw new REXPMismatchException(this, "String"); } /** returns the contents as an array of integers (if supported by the represented object) */ public int[] asIntegers() throws REXPMismatchException { throw new REXPMismatchException(this, "int"); } /** returns the contents as an array of doubles (if supported by the represented object) */ public double[] asDoubles() throws REXPMismatchException { throw new REXPMismatchException(this, "double"); } /** returns the contents as an array of bytes (if supported by the represented object) */ public byte[] asBytes() throws REXPMismatchException { throw new REXPMismatchException(this, "byte"); } /** returns the contents as a (named) list (if supported by the represented object) */ public RList asList() throws REXPMismatchException { throw new REXPMismatchException(this, "list"); } /** returns the contents as a factor (if supported by the represented object) */ public RFactor asFactor() throws REXPMismatchException { throw new REXPMismatchException(this, "factor"); } /** attempt to represent the REXP by a native Java object and return it. Note that this may lead to loss of information (e.g., factors may be returned as a string array) and attributes are ignored. Not all R types can be converted to native Java objects. Also note that R has no concept of scalars, so vectors of length 1 will always be returned as an arrays (i.e., int[1] and not Integer). */ public Object asNativeJavaObject() throws REXPMismatchException { throw new REXPMismatchException(this, "native Java Object"); } /** returns the length of a vector object. Note that we use R semantics here, i.e. a matrix will have a length of m * n since it is represented by a single vector (see {@link #dim} for retrieving matrix and multidimentional-array dimensions). * @return length (number of elements) in a vector object * @throws REXPMismatchException if this is not a vector object */ public int length() throws REXPMismatchException { throw new REXPMismatchException(this, "vector"); } /** returns a boolean vector of the same length as this vector with true for NA values and false for any other values * @return a boolean vector of the same length as this vector with true for NA values and false for any other values * @throws REXPMismatchException if this is not a vector object */ public boolean[] isNA() throws REXPMismatchException { throw new REXPMismatchException(this, "vector"); } // convenience accessor methods /** convenience method corresponding to asIntegers()[0] @return first entry returned by {@link #asInteger} */ public int asInteger() throws REXPMismatchException { int[] i = asIntegers(); return i[0]; } /** convenience method corresponding to asDoubles()[0] @return first entry returned by {@link #asDoubles} */ public double asDouble() throws REXPMismatchException { double[] d = asDoubles(); return d[0]; } /** convenience method corresponding to asStrings()[0] @return first entry returned by {@link #asStrings} */ public String asString() throws REXPMismatchException { String[] s = asStrings(); return s[0]; } // methods common to all REXPs /** retrieve an attribute of the given name from this object * @param name attribute name * @return attribute value or null if the attribute does not exist */ public REXP getAttribute(String name) { final REXPList a = _attr(); if (a==null || !a.isList()) return null; return a.asList().at(name); } /** checks whether this obejct has a given attribute * @param name attribute name * @return true if the attribute exists, false otherwise */ public boolean hasAttribute(String name) { final REXPList a = _attr(); return (a!=null && a.isList() && a.asList().at(name)!=null); } // helper methods common to all REXPs /** returns dimensions of the object (as determined by the "dim" attribute) * @return an array of integers with corresponding dimensions or null if the object has no dimension attribute */ public int[] dim() { try { return hasAttribute("dim")?_attr().asList().at("dim").asIntegers():null; } catch (REXPMismatchException me) { } return null; } /** determines whether this object inherits from a given class in the same fashion as the inherits() function in R does (i.e. ignoring S4 inheritance) * @param klass class name * @return true if this object is of the class klass, false otherwise */ public boolean inherits(String klass) { if (!hasAttribute("class")) return false; try { String c[] = getAttribute("class").asStrings(); if (c != null) { int i = 0; while (i < c.length) { if (c[i]!=null && c[i].equals(klass)) return true; i++; } } } catch (REXPMismatchException me) { } return false; } /** this method allows a limited access to object's attributes - {@link #getAttribute} should be used instead to access specific attributes!. Note that the {@link #attr} attribute should never be used directly incase the REXP implements a lazy access (e.g. via a reference) @return list of attributes or null if the object has no attributes */ public REXPList _attr() { return attr; } /** returns a string description of the object @return string describing the object - it can be of an arbitrary form and used only for debugging (do not confuse with {@link #asString()} for accessing string REXPs) */ public String toString() { return super.toString()+((attr!=null)?"+":""); } /** returns representation that it useful for debugging (e.g. it includes attributes and may include vector values -- see {@link #maxDebugItems}) @return extended description of the obejct -- it may include vector values */ public String toDebugString() { return (attr!=null)?(("<"+attr.toDebugString()+">")+super.toString()):super.toString(); } //======= complex convenience methods /** returns the content of the REXP as a matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. This means that following leads to desired results:
Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix());
@return 2D array of doubles in the form double[rows][cols] or null if the contents is no 2-dimensional matrix of doubles */ public double[][] asDoubleMatrix() throws REXPMismatchException { double[] ct = asDoubles(); REXP dim = getAttribute("dim"); if (dim == null) throw new REXPMismatchException(this, "matrix (dim attribute missing)"); int[] ds = dim.asIntegers(); if (ds.length != 2) throw new REXPMismatchException(this, "matrix (wrong dimensionality)"); int m = ds[0], n = ds[1]; double[][] r = new double[m][n]; // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4) // we need to copy everything, since we create 2d array from 1d array int k = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) r[j][i] = ct[k++]; return r; } /** creates a REXP that represents a double matrix in R based on matrix of doubles (2D-array: m[rows][cols]). This is the same form as used by popular math packages for Java, such as JAMA. The result of this function can be used in {@link REngine.assign} to store a matrix in R. @param matrix array double[rows][colums] containing the matrix to convert into a REXP. If matrix is null or either of the dimensions is 0 then the resulting matrix will have the dimensions 0 x 0 (Note: Java cannot represent 0 x n matrices for n > 0, so special matrices with one dimension of 0 can only be created by setting dimensions directly). @return REXPDouble with "dim" attribute which constitutes a matrix in R */ public static REXP createDoubleMatrix(double[][] matrix) { int m = 0, n = 0; double a[]; if (matrix != null && matrix.length != 0 && matrix[0].length != 0) { m = matrix.length; n = matrix[0].length; a = new double[m * n]; int k = 0; for (int j = 0; j < n; j++) for (int i = 0; i < m; i++) a[k++] = matrix[i][j]; } else a = new double[0]; return new REXPDouble(a, new REXPList( new RList( new REXP[] { new REXPInteger(new int[] { m, n }) }, new String[] { "dim" }) ) ); } //======= tools /** creates a data frame object from a list object using integer row names * @param l a (named) list of vectors ({@link REXPVector} subclasses), each element corresponds to a column and all elements must have the same length * @return a data frame object * @throws REXPMismatchException if the list is empty or any of the elements is not a vector */ public static REXP createDataFrame(RList l) throws REXPMismatchException { if (l == null || l.size() < 1) throw new REXPMismatchException(new REXPList(l), "data frame (must have dim>0)"); if (!(l.at(0) instanceof REXPVector)) throw new REXPMismatchException(new REXPList(l), "data frame (contents must be vectors)"); REXPVector fe = (REXPVector) l.at(0); return new REXPGenericVector(l, new REXPList( new RList( new REXP[] { new REXPString("data.frame"), new REXPString(l.keys()), new REXPInteger(new int[] { REXPInteger.NA, -fe.length() }) }, new String[] { "class", "names", "row.names" }))); } public static REXP asCall(REXP what, REXP[] args) { RList l = new RList(); l.add(what); for (int i = 0; i < args.length; i++) l.add(args[i]); return new REXPLanguage(l); } public static REXP asCall(String name, REXP[] args) { return asCall(new REXPSymbol(name), args); } public static REXP asCall(String name, REXP arg1) { return new REXPLanguage(new RList(new REXP[] { new REXPSymbol(name), arg1 })); } public static REXP asCall(String name, REXP arg1, REXP arg2) { return new REXPLanguage(new RList(new REXP[] { new REXPSymbol(name), arg1, arg2 })); } public static REXP asCall(String name, REXP arg1, REXP arg2, REXP arg3) { return new REXPLanguage(new RList(new REXP[] { new REXPSymbol(name), arg1, arg2, arg3 })); } public static REXP asCall(REXP what, REXP arg1) { return new REXPLanguage(new RList(new REXP[] { what, arg1 })); } public static REXP asCall(REXP what, REXP arg1, REXP arg2) { return new REXPLanguage(new RList(new REXP[] { what, arg1, arg2 })); } public static REXP asCall(REXP what, REXP arg1, REXP arg2, REXP arg3) { return new REXPLanguage(new RList(new REXP[] { what, arg1, arg2, arg3 })); } /** specifies how many items of a vector or list will be displayed in {@link #toDebugString} */ public static int maxDebugItems = 32; } rJava/jri/REngine/RList.java0000644000175100001440000002212515133274032015350 0ustar hornikuserspackage org.rosuda.REngine; // REngine library - Java client interface to R // Copyright (C) 2004,2007,2008 Simon Urbanek import java.util.*; /** implementation of R-lists
All lists (dotted-pair lists, language lists, expressions and vectors) are regarded as named generic vectors. Note: This implementation has changed radically in Rserve 0.5! This class inofficially implements the Map interface. Unfortunately a conflict in the Java iterface classes Map and List doesn't allow us to implement both officially. Most prominently the Map 'remove' method had to be renamed to removeByKey. @version $Id$ */ public class RList extends Vector implements List { public Vector names; /** constructs an empty list */ public RList() { super(); names=null; } /** constructs an initialized, unnamed list * @param contents - an array of {@link REXP}s to use as contents of this list */ public RList(REXP[] contents) { super(contents.length); int i=0; while (i0) { this.names=new Vector(names.length); int i = 0; while (i < names.length) this.names.add(names[i++]); while (this.names.size()0) { this.names=new Vector(names.length); int i = 0; while (i < names.length) this.names.add(names[i++]); while (this.names.size()0) { this.names=new Vector(names); while (this.names.size()true if this list is named, false otherwise */ public boolean isNamed() { return names!=null; } /** get xpression given a key @param v key @return value which corresponds to the given key or null if the list is unnamed or key not found */ public REXP at(String v) { if (names==null) return null; int i = names.indexOf(v); if (i < 0) return null; return (REXP)elementAt(i); } /** get element at the specified position @param i index @return value at the index or null if the index is out of bounds */ public REXP at(int i) { return (i>=0 && inull is the list is unnamed or the index is out of range */ public String keyAt(int i) { return (names==null || i<0 || i>=names.size())?null:(String)names.get(i); } /** set key at the given index. Using this method automatically makes the list a named one even if the key is null. Out of range operations are undefined (currently no-ops) @param i index @param value key name */ public void setKeyAt(int i, String value) { if (i < 0) return; if (names==null) names = new Vector(); if (names.size() < size()) names.setSize(size()); if (i < size()) names.set(i, value); } /** returns all keys of the list * @return array containing all keys or null if list unnamed */ public String[] keys() { if (names==null) return null; int i = 0; String k[] = new String[names.size()]; while (i < k.length) { k[i] = keyAt(i); i++; }; return k; } // --- overrides that sync names public void add(int index, Object element) { super.add(index, element); if (names==null) return; names.add(index, null); } public boolean add(Object element) { super.add(element); if (names != null) names.add(null); return true; } public boolean addAll(Collection c) { boolean ch = super.addAll(c); if (names==null) return ch; int l = size(); while (names.size() 0) names.add(index, null); return ch; } public void clear() { super.clear(); names=null; } public Object clone() { return new RList(this, names); } public Object remove(int index) { Object o = super.remove(index); if (names != null) { names.remove(index); if (size()==0) names=null; } return o; } public boolean remove(Object elem) { int i = indexOf(elem); if (i<0) return false; remove(i); if (size()==0) names=null; return true; } public boolean removeAll(Collection c) { if (names==null) return super.removeAll(c); boolean changed=false; Iterator it = c.iterator(); while (it.hasNext()) changed|=remove(it.next()); return changed; } public boolean retainAll(Collection c) { if (names==null) return super.retainAll(c); boolean rm[] = new boolean[size()]; boolean changed=false; int i = 0; while (i0) { i--; if (rm[i]) remove(i); } return changed; } // --- old API mapping public void removeAllElements() { clear(); } public void insertElementAt(Object obj, int index) { add(index, obj); } public void addElement(Object obj) { add(obj); } public void removeElementAt(int index) { remove(index); } public boolean removeElement(Object obj) { return remove(obj); } // --- Map interface public boolean containsKey(Object key) { return (names==null)?false:names.contains(key); } public boolean containsValue(Object value) { return contains(value); } /** NOTE: THIS IS UNIMPLEMENTED and always returns null! Due to the fact that R lists are not proper maps we canot maintain a set-view of the list */ public Set entrySet() { return null; } public Object get(Object key) { return at((String)key); } /** Note: sinde RList is not really a Map, the returned set is only an approximation as it cannot reference duplicate or null names that may exist in the list */ public Set keySet() { if (names==null) return null; return new HashSet(names); } public Object put(Object key, Object value) { if (key==null) { add(value); return null; } if (names != null) { int p = names.indexOf(key); if (p >= 0) return super.set(p, value); } int i = size(); super.add(value); if (names==null) names = new Vector(i+1); while (names.size() < i) names.add(null); names.add(key); return null; } public void putAll(Map t) { if (t==null) return; // NOTE: this if branch is dead since RList cannot inherit from Map if (t instanceof RList) { // we need some more sophistication for RLists as they may have null-names which we append RList l = (RList) t; if (names==null) { addAll(l); return; } int n = l.size(); int i = 0; while (i < n) { String key = l.keyAt(i); if (key==null) add(l.at(i)); else put(key, l.at(i)); i++; } } else { Set ks = t.keySet(); Iterator i = ks.iterator(); while (i.hasNext()) { Object key = i.next(); put(key, t.get(key)); } } } public void putAll(RList t) { if (t == null) return; RList l = (RList) t; if (names==null) { addAll(l); return; } int n = l.size(); int i = 0; while (i < n) { String key = l.keyAt(i); if (key == null) add(l.at(i)); else put(key, l.at(i)); i++; } } public Object removeByKey(Object key) { if (names==null) return null; int i = names.indexOf(key); if (i<0) return null; Object o = elementAt(i); removeElementAt(i); names.removeElementAt(i); return o; } public Collection values() { return this; } // other public String toString() { return "RList"+super.toString()+"{"+(isNamed()?"named,":"")+size()+"}"; } } rJava/jri/REngine/README.md0000644000175100001440000000156215133274032014731 0ustar hornikusers# REngine REngine is a general Java interface to [R](https://www.R-project.org) supporting multiple back-ends such as [JRI](https://RForge.net/rJava) and [Rserve](https://RForge.net/Rserve). It allows Java code to evaluate R expressions, push and pull data. Since it is backend-agnostic, the same code can be used to embed R into a Java process or use a cluster of R servers to perform statisical computations. The sources can be compiled simply by using make Maven is also supported (including unit tests) and can be run using `make mvn.pkg`. If you want to run `mvn` by hamd you can do so, but note that the Maven project requires a different directory structure which can be created by calling `mkmvn.sh` (unix only as it uses symlinks). [![REngine Actions Status](https://github.com/s-u/REngine/workflows/REngine/badge.svg)](https://github.com/s-u/REngine/actions) rJava/jri/REngine/REXPEnvironment.java0000644000175100001440000000654415133274032017325 0ustar hornikuserspackage org.rosuda.REngine; // environments are like REXPReferences except that they cannot be resolved /** REXPEnvironment represents an environment in R. Very much like {@link org.rosuda.REngine.REXPReference} this is a proxy object to the actual object on the R side. It provides methods for accessing the content of the environment. The actual implementation may vary by the back-end used and not all engines support environments. Check {@link org.rosuda.REngine.REngine.supportsEnvironments()} for the given engine. Environments are specific for a given engine, they cannot be passed across engines. */ public class REXPEnvironment extends REXP { /** engine associated with this environment */ REngine eng; /** transparent handle that can be used by the engine to indentify the environment. It is not used by REngine API itself. */ Object handle; /** create a new environemnt reference - this constructor should never be used directly, use {@link REngine.newEnvironment()} instead. * @param eng engine responsible for this environment * @param handle handle used by the engine to identify this environment */ public REXPEnvironment(REngine eng, Object handle) { super(); this.eng = eng; this.handle = handle; } public boolean isEnvironment() { return true; } /** returns the handle used to identify this environemnt in the engine - for internal use by engine implementations only * @return handle of this environment */ public Object getHandle() { return handle; } /** get a value from this environment * @param name name of the value * @param resolve if false returns a reference to the object, if false the reference is resolved * @return value corresponding to the symbol name or possibly null if the value is unbound (the latter is currently engine-specific) */ public REXP get(String name, boolean resolve) throws REngineException { try { return eng.get(name, this, resolve); } catch (REXPMismatchException e) { // this should never happen because this is always guaranteed to be REXPEnv throw(new REngineException(eng, "REXPMismatchException:"+e+" in get()")); } } /** get a value from this environment - equavalent to get(name, true). * @param name name of the value * @return value (see {@link #get(String,boolean)}) */ public REXP get(String name) throws REngineException { return get(name, true); } /** assigns a value to a given symbol name * @param name symbol name * @param value value */ public void assign(String name, REXP value) throws REngineException, REXPMismatchException { eng.assign(name, value, this); } /** returns the parent environment or a reference to it * @param resolve if true returns the environemnt, otherwise a reference. * @return parent environemnt (or a reference to it) */ public REXP parent(boolean resolve) throws REngineException { try { return eng.getParentEnvironment(this, resolve); } catch (REXPMismatchException e) { // this should never happen because this is always guaranteed to be REXPEnv throw(new REngineException(eng, "REXPMismatchException:"+e+" in parent()")); } } /** returns the parent environment. This is equivalent to parent(true). * @return parent environemnt */ public REXPEnvironment parent() throws REngineException { return (REXPEnvironment) parent(true); } } rJava/jri/REngine/REXPList.java0000644000175100001440000000417015133274032015725 0ustar hornikuserspackage org.rosuda.REngine; /** Represents a pairlist in R. Unlike the actual internal R implementation this one does not use CAR/CDR/TAG linked representation but a @link{RList} object. */ public class REXPList extends REXPVector { private RList payload; /* create a new pairlist with the contents of a named R list and no attributes. @param list named list with the contents */ public REXPList(RList list) { super(); payload=(list==null)?new RList():list; } /* create a new pairlist with the contents of a named R list and attributes. @param list named list with the contents @param attr attributes */ public REXPList(RList list, REXPList attr) { super(attr); payload=(list==null)?new RList():list; } /* create a pairlist containing just one pair comprising of one value and one name. This is a convenience constructor most commonly used to create attribute pairlists. @param value of the element in the pairlist (must not be null) @param name of the element in the pairlist (must not be null) */ public REXPList(REXP value, String name) { super(); payload = new RList(new REXP[] { value }, new String[] { name }); } public Object asNativeJavaObject() throws REXPMismatchException { // since REXPGenericVector does the hard work, we just cheat and use it in turn REXPGenericVector v = new REXPGenericVector(payload); return v.asNativeJavaObject(); } public int length() { return payload.size(); } public boolean isList() { return true; } public boolean isPairList() { return true; } public boolean isRecursive() { return true; } public RList asList() { return payload; } public String toString() { return super.toString()+(asList().isNamed()?"named":""); } public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); String name = payload.keyAt(i); if (name!=null) sb.append(name+"="); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } } rJava/jri/REngine/REXPExpressionVector.java0000644000175100001440000000137515133274032020340 0ustar hornikuserspackage org.rosuda.REngine; /** REXPExpressionVector represents a vector of expressions in R. It is essentially a special kind of generic vector - its elements are expected to be valid R expressions. */ public class REXPExpressionVector extends REXPGenericVector { /** create a new vector of expressions from a list of expressions. * @param list list of expressions to store in this vector */ public REXPExpressionVector(RList list) { super(list); } /** create a new vector of expressions from a list of expressions. * @param list list of expressions to store in this vector * @param attr attributes for the R object */ public REXPExpressionVector(RList list, REXPList attr) { super(list, attr); } public boolean isExpression() { return true; } } rJava/jri/REngine/REngineCallbacks.java0000644000175100001440000000025715133274032017444 0ustar hornikuserspackage org.rosuda.REngine; /** REngineCallbacks is a virtual interface that poses as a superclass of all callback delegate classes. */ public interface REngineCallbacks { } rJava/jri/REngine/REXPFactor.java0000644000175100001440000000455215133274032016234 0ustar hornikuserspackage org.rosuda.REngine; /** REXPFactor represents a factor in R. It is an integer vector with levels for each contained category. */ // FIXME: this is currently somehow screwed - the concept of RFactor and REXPFactor is duplicate - we need to remove this historical baggage public class REXPFactor extends REXPInteger { private String[] levels; private RFactor factor; /** create a new factor REXP * @param ids indices (one-based!) * @param levels levels */ public REXPFactor(int[] ids, String[] levels) { super(ids); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); } /** create a new factor REXP * @param ids indices (one-based!) * @param levels levels * @param attr attributes */ public REXPFactor(int[] ids, String[] levels, REXPList attr) { super(ids, attr); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); } /** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) */ public REXPFactor(RFactor factor) { super(factor.asIntegers(1)); this.factor = factor; this.levels = factor.levels(); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); } /** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) * @param attr attributes */ public REXPFactor(RFactor factor, REXPList attr) { super(factor.asIntegers(1), attr); this.factor = factor; this.levels = factor.levels(); } public boolean isFactor() { return true; } /** return the contents as a factor - the factor is guaranteed to have index base 1 * @return the contents as a factor */ public RFactor asFactor() { return factor; } public String[] asStrings() { return factor.asStrings(); } public Object asNativeJavaObject() { return asStrings(); } public String toString() { return super.toString()+"["+levels.length+"]"; } } rJava/jri/REngine/REngineInputInterface.java0000644000175100001440000000157315133274032020507 0ustar hornikuserspackage org.rosuda.REngine; /** interface defining delegate methods used by {@link REngine} to forward input callbacks from R. */ public interface REngineInputInterface { /** called when R enters the read stage of the event loop. *

Important: implementations should never use a direct return! That will cause a tigh-spinning event loop. Implementation must wait for input asynchronously (e.g., declare synchonized RReadConsole and use wait()) and return only when a complete line is available for processing. * @param eng calling engine * @param prompt prompt to display in the console * @param addToHistory flag indicating whether the input is transient (false) or to be recorded in the command history (true). * @return string to be processed as console input */ public String RReadConsole(REngine eng, String prompt, int addToHistory); } rJava/jri/src/0000755000175100001440000000000015133274032012706 5ustar hornikusersrJava/jri/src/Makefile.in0000644000175100001440000000077115133274032014760 0ustar hornikusers# JRI - Java/R Interface experimental! #-------------------------------------------------------------------------- #--- comment out the following for non-debug version CFLAGS+=-g CC=@CC@ CFLAGS+=-Iinclude @DEFFLAGS@ -DHAVE_CONFIG_H @CFLAGS@ @JAVA_CFLAGS@ LDFLAGS+=@LDFLAGS@ CC=@CC@ RHOME=@R_HOME@ JAVAC=@JAVAC@ JAVAH=@JAVAH@ JAVAINC=@JAVA_INC@ JAR=@JAR@ JFLAGS=@JFLAGS@ RINC=@RINC@ -I@R_INCLUDE_DIR@ RLD=@RLD@ JNILD=@JNILD@ JNISO=@JNISO@ JNIPREFIX=@JNIPREFIX@ CPICF=@CPICF@ include Makefile.all rJava/jri/src/config.h.in0000644000175100001440000000321015133274032014725 0ustar hornikusers/* src/config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDIO_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if all of the C90 standard headers exist (not just the ones required in a freestanding environment). This macro is provided for backward compatibility; new code need not use it. */ #undef STDC_HEADERS rJava/jri/src/Rcallbacks.h0000644000175100001440000000216515133274032015124 0ustar hornikusers#ifndef __R_CALLBACKS__H__ #define __R_CALLBACKS__H__ #include #include #include /* functions provided as R callbacks */ #if R_VERSION < R_Version(2,7,0) #define RCCONST #else #define RCCONST const #endif /* ReadConsole API has been changed (unannounced and undocumented!) for Windows in r81626 */ #if defined (WIN32) && (R_VERSION < R_Version(4,2,0)) #define RCSIGN #else #define RCSIGN unsigned #endif int Re_ReadConsole(RCCONST char *prompt, RCSIGN char *buf, int len, int addtohistory); void Re_Busy(int which); void Re_WriteConsole(RCCONST char *buf, int len); void Re_WriteConsoleEx(RCCONST char *buf, int len, int oType); void Re_ResetConsole(void); void Re_FlushConsole(void); void Re_ClearerrConsole(void); int Re_ChooseFile(int new, char *buf, int len); void Re_ShowMessage(RCCONST char *buf); void Re_read_history(char *buf); void Re_loadhistory(SEXP call, SEXP op, SEXP args, SEXP env); void Re_savehistory(SEXP call, SEXP op, SEXP args, SEXP env); int Re_ShowFiles(int nfile, RCCONST char **file, RCCONST char **headers, RCCONST char *wtitle, Rboolean del, RCCONST char *pager); #endif rJava/jri/src/globals.c0000644000175100001440000000010715133274032014473 0ustar hornikusers#include jobject engineObj; jclass engineClass; JNIEnv *eenv; rJava/jri/src/Rinit.c0000644000175100001440000002121215133274032014135 0ustar hornikusers#include #include #include "Rinit.h" #include "Rcallbacks.h" #include "Rdecl.h" /*-------------------------------------------------------------------* * UNIX initialization (includes Darwin/Mac OS X) * *-------------------------------------------------------------------*/ #ifndef Win32 #define R_INTERFACE_PTRS 1 #define CSTACK_DEFNS 1 #include /* and SaveAction is not officially exported */ extern SA_TYPE SaveAction; int initR(int argc, char **argv) { structRstart rp; Rstart Rp = &rp; /* getenv("R_HOME","/Library/Frameworks/R.framework/Resources",1); */ if (!getenv("R_HOME")) { fprintf(stderr, "R_HOME is not set. Please set all required environment variables before running this program.\n"); return -1; } /* this is probably unnecessary, but we could set any other parameters here */ R_DefParams(Rp); Rp->NoRenviron = 0; R_SetParams(Rp); #ifdef RIF_HAS_RSIGHAND R_SignalHandlers=0; #endif { int stat=Rf_initialize_R(argc, argv); if (stat<0) { printf("Failed to initialize embedded R! (stat=%d)\n",stat); return -1; } } #ifdef RIF_HAS_RSIGHAND R_SignalHandlers=0; #endif /* disable stack checking, because threads will thow it off */ R_CStackLimit = (uintptr_t) -1; #ifdef JGR_DEBUG printf("R primary initialization done. Setting up parameters.\n"); #endif R_Outputfile = NULL; R_Consolefile = NULL; R_Interactive = 1; SaveAction = SA_SAVEASK; /* ptr_R_Suicide = Re_Suicide; */ /* ptr_R_CleanUp = Re_CleanUp; */ ptr_R_ShowMessage = Re_ShowMessage; ptr_R_ReadConsole = Re_ReadConsole; ptr_R_WriteConsole = NULL; ptr_R_WriteConsoleEx = Re_WriteConsoleEx; ptr_R_ResetConsole = Re_ResetConsole; ptr_R_FlushConsole = Re_FlushConsole; ptr_R_ClearerrConsole = Re_ClearerrConsole; ptr_R_Busy = Re_Busy; ptr_R_ShowFiles = Re_ShowFiles; ptr_R_ChooseFile = Re_ChooseFile; ptr_R_loadhistory = Re_loadhistory; ptr_R_savehistory = Re_savehistory; #ifdef JGR_DEBUG printf("Setting up R event loop\n"); #endif setup_Rmainloop(); #ifdef JGR_DEBUG printf("R initialized.\n"); #endif return 0; } void initRinside(void) { /* disable stack checking, because threads will thow it off */ R_CStackLimit = (uintptr_t) -1; } #else /*-------------------------------------------------------------------* * Windows initialization is different and uses Startup.h * *-------------------------------------------------------------------*/ #define NONAMELESSUNION #include #include #include #include #include /* before we include RStatup.h we need to work around a bug in it for Win64: it defines wrong R_size_t if R_SIZE_T_DEFINED is not set */ #if defined(WIN64) && ! defined(R_SIZE_T_DEFINED) #include #define R_size_t uintptr_t #define R_SIZE_T_DEFINED 1 #endif #include "R_ext/RStartup.h" #ifndef WIN64 /* according to fixed/config.h Windows has uintptr_t, my windows hasn't */ #if !defined(HAVE_UINTPTR_T) && !defined(uintptr_t) && !defined(_STDINT_H) typedef unsigned uintptr_t; #endif #endif extern __declspec(dllimport) uintptr_t R_CStackLimit; /* C stack limit */ extern __declspec(dllimport) uintptr_t R_CStackStart; /* Initial stack address */ /* for signal-handling code */ /* #include "psignal.h" - it's not included, so just get SIGBREAK */ #define SIGBREAK 21 /* to readers pgrp upon background tty read */ /* one way to allow user interrupts: called in ProcessEvents */ #ifdef _MSC_VER __declspec(dllimport) int UserBreak; #else #ifndef WIN64 #define UserBreak (*_imp__UserBreak) #endif extern int UserBreak; #endif /* calls into the R DLL */ extern char *getDLLVersion(void); extern void R_DefParams(Rstart); extern void R_SetParams(Rstart); extern void setup_term_ui(void); extern void ProcessEvents(void); extern void end_Rmainloop(void), R_ReplDLLinit(void); extern int R_ReplDLLdo1(void); extern void run_Rmainloop(void); void myCallBack(void) { /* called during i/o, eval, graphics in ProcessEvents */ } #ifndef YES #define YES 1 #endif #ifndef NO #define NO -1 #endif #ifndef CANCEL #define CANCEL 0 #endif int myYesNoCancel(RCCONST char *s) { char ss[192]; RCSIGN char a[3]; unsigned int l = (unsigned int) strlen(s); if (l + 12 > sizeof(ss)) { memcpy(ss, s, sizeof(ss) - 15); strcpy(ss + sizeof(ss) - 15, "... [y/n/c]: "); } else { memcpy(ss, s, l); strcpy(ss + l, " [y/n/c]: "); } Re_ReadConsole(ss, a, 3, 0); switch (a[0]) { case 'y': case 'Y': return YES; case 'n': case 'N': return NO; default: return CANCEL; } } static void my_onintr(int sig) { UserBreak = 1; } static char Rversion[25], RUser[MAX_PATH], RHome[MAX_PATH]; int initR(int argc, char **argv) { structRstart rp; Rstart Rp = &rp; char *p; char rhb[MAX_PATH+10]; DWORD t, s = MAX_PATH; HKEY k; int cvl; snprintf(Rversion, sizeof(Rversion)-1, "%s.%s", R_MAJOR, R_MINOR); cvl=strlen(R_MAJOR)+2; if(strncmp(getDLLVersion(), Rversion, cvl) != 0) { char msg[512]; snprintf(msg, sizeof(msg)-1, "Error: R.DLL version does not match (DLL: %s, expecting: %s)\n", getDLLVersion(), Rversion); fprintf(stderr, msg); MessageBox(0, msg, "Version mismatch", MB_OK|MB_ICONERROR); return -1; } R_DefParams(Rp); if(getenv("R_HOME")) { strcpy(RHome, getenv("R_HOME")); } else { /* fetch R_HOME from the registry - try preferred architecture first */ #ifdef WIN64 const char *pref_path = "SOFTWARE\\R-core\\R64"; #else const char *pref_path = "SOFTWARE\\R-core\\R32"; #endif if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, pref_path, 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPBYTE) RHome, &s) != ERROR_SUCCESS) && (RegOpenKeyEx(HKEY_CURRENT_USER, pref_path, 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPBYTE) RHome, &s) != ERROR_SUCCESS) && (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\R-core\\R", 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPBYTE) RHome, &s) != ERROR_SUCCESS) && (RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\R-core\\R", 0, KEY_QUERY_VALUE, &k) != ERROR_SUCCESS || RegQueryValueEx(k, "InstallPath", 0, &t, (LPBYTE) RHome, &s) != ERROR_SUCCESS)) { fprintf(stderr, "R_HOME must be set or R properly installed (\\Software\\R-core\\R\\InstallPath registry entry must exist).\n"); MessageBox(0, "R_HOME must be set or R properly installed (\\Software\\R-core\\R\\InstallPath registry entry must exist).\n", "Can't find R home", MB_OK|MB_ICONERROR); return -2; } strcpy(rhb, "R_HOME="); if (strlen(RHome) > sizeof(rhb) - 9) { fprintf(stderr, "R_HOME path is too long!\n"); MessageBox(0, "R_HOME path it too long! Install R in a different location.\n", "R home path is too long", MB_OK|MB_ICONERROR); return -2; } strcpy(rhb + 7, RHome); putenv(rhb); } /* on Win32 this should set R_Home (in R_SetParams) as well */ Rp->rhome = RHome; /* * try R_USER then HOME then working directory */ if (getenv("R_USER")) { strcpy(RUser, getenv("R_USER")); } else if (getenv("HOME")) { strcpy(RUser, getenv("HOME")); } else if (getenv("HOMEDIR")) { strcpy(RUser, getenv("HOMEDIR")); strcat(RUser, getenv("HOMEPATH")); } else GetCurrentDirectory(MAX_PATH, RUser); p = RUser + (strlen(RUser) - 1); if (*p == '/' || *p == '\\') *p = '\0'; Rp->home = RUser; Rp->ReadConsole = Re_ReadConsole; Rp->WriteConsole = NULL; Rp->WriteConsoleEx = Re_WriteConsoleEx; Rp->Busy = Re_Busy; Rp->ShowMessage = Re_ShowMessage; Rp->YesNoCancel = myYesNoCancel; Rp->CallBack = myCallBack; Rp->CharacterMode = LinkDLL; Rp->R_Quiet = FALSE; Rp->R_Interactive = TRUE; Rp->RestoreAction = SA_RESTORE; Rp->SaveAction = SA_SAVEASK; /* process common command line options */ R_common_command_line(&argc, argv, Rp); /* what is left should be assigned to args */ R_set_command_line_arguments(argc, argv); R_SetParams(Rp); /* so R_ShowMessage is set */ R_SizeFromEnv(Rp); R_SetParams(Rp); /* R_SetParams implicitly calls R_SetWin32 which sets the stack start/limit which we need to override */ R_CStackLimit = (uintptr_t) -1; FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); signal(SIGBREAK, my_onintr); setup_term_ui(); setup_Rmainloop(); return 0; } void initRinside(void) { /* disable stack checking, because threads will thow it off */ R_CStackLimit = (uintptr_t) -1; } #endif rJava/jri/src/Makefile.all0000644000175100001440000000346215133274032015122 0ustar hornikusers# JRI - Java/R Interface experimental! #-------------------------------------------------------------------------- # JRI_CPPFLAGS and JRI_LIBS are additional overrides that can be supplied # by the user JRI_JSRC=$(wildcard ../*.java) TARGETS=$(JNIPREFIX)jri$(JNISO) JRI.jar all: $(TARGETS) JRI.jar: $(JRI_JSRC) $(JNIPREFIX)jri$(JNISO) $(JAVAC) $(JFLAGS) $(JRI_JFLAGS) -d . $(JRI_JSRC) $(JAR) fc $@ org $(JNIPREFIX)jri$(JNISO) org_rosuda_JRI_Rengine.h: org/rosuda/JRI/Rengine.class if [ -n "$(JAVAH)" ]; then $(JAVAH) -d . -classpath . org.rosuda.JRI.Rengine; fi Rcallbacks.o: Rcallbacks.c Rcallbacks.h globals.h rjstring.h org_rosuda_JRI_Rengine.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(JAVAINC) $(RINC) $(JRI_CPPFLAGS) rjstring.o: rjstring.c rjstring.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(JAVAINC) $(RINC) $(JRI_CPPFLAGS) Rinit.o: Rinit.c Rinit.h Rcallbacks.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(RINC) $(JRI_CPPFLAGS) globals.o: globals.c globals.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(JAVAINC) $(JRI_CPPFLAGS) rjava.o: rjava.c rjava.h $(CC) -c -o $@ $< $(CFLAGS) $(CPICF) $(JAVAINC) $(JRI_CPPFLAGS) Rengine.o: Rengine.c org_rosuda_JRI_Rengine.h globals.h Rcallbacks.h Rinit.h $(CC) -c -o $@ Rengine.c $(CFLAGS) $(CPICF) $(JAVAINC) $(RINC) $(JRI_CPPFLAGS) jri.o: jri.c $(CC) -c -o $@ jri.c $(CFLAGS) $(CPICF) $(JAVAINC) $(RINC) $(JRI_CPPFLAGS) $(JNIPREFIX)jri$(JNISO): Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o rjstring.o $(JRIDEPS) $(CC) -o $@ $^ $(LDFLAGS) $(JNILD) $(RLD) $(JRI_LIBS) win32/libjvm.dll.a: make -C win32 libjvm.dll.a org/rosuda/JRI/Rengine.class org/rosuda/JRI/REXP.class org/rosuda/JRI/Mutex.class: $(JRI_JSRC) $(JAVAC) $(JFLAGS) $(JRI_JFLAGS) -d . $^ clean: rm -rf $(TARGETS) org *.o *~ org_rosuda_JRI_Rengine.h *$(JNISO) *.class *~ .PHONY: clean all .NOTPARALLEL: rJava/jri/src/Makefile.win0000644000175100001440000000022515133274032015141 0ustar hornikusers# Windows-specific part of the Makefile include $(R_HOME)/etc$(R_ARCH)/Makeconf include Makefile.wconf include ../Makevars.win include Makefile.all rJava/jri/src/Rdecl.h0000644000175100001440000000056615133274032014117 0ustar hornikusers#ifndef __RDECL_H__ #define __RDECL_H__ /* declarations from R internals or other include files */ /* last update: R 2.4.0 */ void run_Rmainloop(void); /* main/main.c */ int R_ReadConsole(char*, unsigned char*, int, int); /* include/Defn.h */ void Rf_checkArity(SEXP, SEXP); /* include/Defn.h */ int Rf_initialize_R(int ac, char **av); /* include/Rembedded.h */ #endif rJava/jri/src/win32/0000755000175100001440000000000015133274032013650 5ustar hornikusersrJava/jri/src/win32/jvm64.def0000755000175100001440000000015515133274032015302 0ustar hornikusersLIBRARY JVM.DLL EXPORTS JNI_CreateJavaVM JNI_GetCreatedJavaVMs JNI_GetDefaultJavaVMInitArgs rJava/jri/src/win32/Makefile0000644000175100001440000000142315133274037015315 0ustar hornikusers# helper tools and libs for building and running rJava for Windows # Author: Simon Urbanek include $(R_HOME)/etc$(R_ARCH)/Makeconf TARGETS=libjvm.dll.a findjava.exe # libjvm.dll.a - wrapper lib for jvm.dll from Java # findjava.exe - helper tool to find the current JDK from the registry all: $(TARGETS) ifeq ($(strip $(shell $(R_HOME)/bin/R --slave -e 'cat(.Machine$$sizeof.pointer)')),8) JVMDEF=jvm64.def else JVMDEF=jvm.def endif libjvm.dll.a: $(JVMDEF) $(DLLTOOL) --input-def $^ --kill-at --dllname jvm.dll --output-lib $@ # compile findjava.exe from source - no magic here, no special libs necessary findjava.o: findjava.c $(CC) -O2 -c -o $@ $^ findjava.exe: findjava.o $(CC) -s -o $@ $^ # just cleanup everything clean: rm -f *.o *~ $(TARGETS) .PHONY: all clean rJava/jri/src/win32/jvm.def0000644000175100001440000000016515133274032015126 0ustar hornikusersLIBRARY JVM.DLL EXPORTS JNI_CreateJavaVM@12 JNI_GetCreatedJavaVMs@12 JNI_GetDefaultJavaVMInitArgs@4 rJava/jri/src/win32/findjava.c0000644000175100001440000000711415133274032015601 0ustar hornikusers#include #include #include static char RegStrBuf[32768], dbuf[32768]; int main(int argc, char **argv) { int i=0, doit=0; DWORD t,s=32767; HKEY k; HKEY root=HKEY_LOCAL_MACHINE; char *javakey="Software\\JavaSoft\\Java Runtime Environment"; if (argc>1 && argv[1][0]=='-' && argv[1][1]=='R') { if (getenv("R_HOME")) { strcpy(RegStrBuf,getenv("R_HOME")); } else { javakey="Software\\R-core\\R"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"InstallPath",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { if (RegOpenKeyEx(HKEY_CURRENT_USER,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"InstallPath",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "ERROR*> R - can't open registry keys.\n"); return -1; } } } } else /* JAVA_HOME can override our detection - but we still post-process it */ if (getenv("JAVA_HOME")) { strcpy(RegStrBuf,getenv("JAVA_HOME")); } else { #ifdef FINDJRE if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { javakey="Software\\JavaSoft\\JRE"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { #endif javakey="Software\\JavaSoft\\Java Development Kit"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { javakey="Software\\JavaSoft\\JDK"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "ERROR*> JavaSoft\\{JRE|JDK} can't open registry keys.\n"); /* MessageBox(wh, "Can't find Sun's Java runtime.\nPlease install Sun's J2SE JRE or JDK 1.4.2 or later (see http://java.sun.com/).","Can't find Sun's Java",MB_OK|MB_ICONERROR); */ return -1; } } #ifdef FINDJRE } } #endif RegCloseKey(k); s=32767; strcpy(dbuf,javakey); strcat(dbuf,"\\"); strcat(dbuf,RegStrBuf); javakey=(char*) malloc(strlen(dbuf)+1); strcpy(javakey, dbuf); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"JavaHome",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "There's no JavaHome value in the JDK/JRE registry key.\n"); /* MessageBox(wh, "Can't find Java home path. Maybe your JRE is too old.\nPlease install Sun's J2SE JRE or SDK 1.4.2 (see http://java.sun.com/).","Can't find Sun's Java",MB_OK|MB_ICONERROR); */ return -1; } RegCloseKey(k); } /*--- post-processing according to supplied flags --*/ /* -a = automagic, i.e. use short name only if the name contains spaces */ i=1; while (i #include "jri.h" #include "org_rosuda_JRI_Rengine.h" #include "rjava.h" #include #include #ifndef WIN32 /* this is for interrupt handing since GD uses R_interrupts_pending */ #include /* Before R 2.7.0 R_interrupts_pending was not included, though */ #if R_VERSION < R_Version(2,7,0) LibExtern int R_interrupts_pending; #endif #endif /* the # of arguments to R_ParseVector changed since R 2.5.0 */ #if R_VERSION < R_Version(2,5,0) #define RS_ParseVector R_ParseVector #else #define RS_ParseVector(A,B,C) R_ParseVector(A,B,C,R_NilValue) #endif #include "Rcallbacks.h" #include "Rinit.h" #include "globals.h" #include "Rdecl.h" #ifdef Win32 #include #ifdef _MSC_VER __declspec(dllimport) int UserBreak; #else #ifndef WIN64 #define UserBreak (*_imp__UserBreak) #endif extern int UserBreak; #endif #else /* for R_runHandlers */ #include #include #include #endif JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniGetVersion (JNIEnv *env, jclass this) { return (jlong) JRI_API; } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniSetupR (JNIEnv *env, jobject this, jobjectArray a) { int initRes; char *fallbackArgv[]={"Rengine",0}; char **argv=fallbackArgv; int argc=1; #ifdef JRI_DEBUG printf("rniSetupR\n"); #endif engineObj=(*env)->NewGlobalRef(env, this); engineClass=(*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, engineObj)); eenv=env; if (a) { /* retrieve the content of the String[] and construct argv accordingly */ int len = (int)(*env)->GetArrayLength(env, a); if (len>0) { int i=0; argv=(char**) malloc(sizeof(char*)*(len+2)); argv[0]=fallbackArgv[0]; while (i < len) { jobject o=(*env)->GetObjectArrayElement(env, a, i); i++; if (o) { const char *c; c=(*env)->GetStringUTFChars(env, o, 0); if (!c) argv[i]=""; else { argv[i] = strdup(c); (*env)->ReleaseStringUTFChars(env, o, c); } } else argv[i]=""; } argc=len+1; argv[argc]=0; } } if (argc==2 && !strcmp(argv[1],"--zero-init")) {/* special case for direct embedding (exp!) */ initRinside(); return 0; } initRes=initR(argc, argv); /* we don't release the argv in case R still needs it later (even if it shouldn't), but it's not really a significant leak */ return initRes; } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniParse (JNIEnv *env, jobject this, jstring str, jint parts) { ParseStatus ps; SEXP pstr, cv; PROTECT(cv=jri_getString(env, str)); #ifdef JRI_DEBUG printf("parsing \"%s\"\n", CHAR(STRING_ELT(cv,0))); #endif pstr=RS_ParseVector(cv, parts, &ps); #ifdef JRI_DEBUG printf("parse status=%d, result=%x, type=%d\n", ps, (int) pstr, (pstr!=0)?TYPEOF(pstr):0); #endif UNPROTECT(1); return SEXP2L(pstr); } /** * Evaluates one expression or a list of expressions * * @param exp long reflection of the expression to evaluate * @param rho long reflection of the environment where to evaluate * * @return 0 if an evaluation error ocurred or exp is 0 */ JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniEval (JNIEnv *env, jobject this, jlong exp, jlong rho) { SEXP es = R_NilValue, exps = L2SEXP(exp); SEXP eval_env = L2SEXP(rho); int er = 0; int i = 0, l; /* invalid (NULL) expression (parse error, ... ) */ if (!exp) return 0; if (TYPEOF(exps) == EXPRSXP) { /* if the object is a list of exps, eval them one by one */ l = LENGTH(exps); while (i < l) { es = R_tryEval(VECTOR_ELT(exps,i), eval_env, &er); /* an error occured, no need to continue */ if (er) return 0; i++; } } else es = R_tryEval(exps, eval_env, &er); /* er is just a flag - on error return 0 */ if (er) return 0; return SEXP2L(es); } struct safeAssign_s { SEXP sym, val, rho; }; static void safeAssign(void *data) { struct safeAssign_s *s = (struct safeAssign_s*) data; defineVar(s->sym, s->val, s->rho); } JNIEXPORT jboolean JNICALL Java_org_rosuda_JRI_Rengine_rniAssign (JNIEnv *env, jobject this, jstring symName, jlong valL, jlong rhoL) { struct safeAssign_s s; s.sym = jri_installString(env, symName); if (!s.sym || s.sym == R_NilValue) return JNI_FALSE; s.rho = rhoL ? L2SEXP(rhoL) : R_GlobalEnv; s.val = valL ? L2SEXP(valL) : R_NilValue; /* we have to use R_ToplevelExec because defineVar may fail on locked bindings */ return R_ToplevelExec(safeAssign, (void*) &s) ? JNI_TRUE : JNI_FALSE; } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniProtect (JNIEnv *env, jobject this, jlong exp) { PROTECT(L2SEXP(exp)); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniUnprotect (JNIEnv *env, jobject this, jint count) { UNPROTECT(count); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniRelease (JNIEnv *env, jobject this, jlong exp) { if (exp) R_ReleaseObject(L2SEXP(exp)); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniPreserve (JNIEnv *env, jobject this, jlong exp) { if (exp) R_PreserveObject(L2SEXP(exp)); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniPrintValue (JNIEnv *env, jobject this, jlong exp) { Rf_PrintValue(exp ? L2SEXP(exp) : R_NilValue); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniParentEnv (JNIEnv *env, jobject this, jlong exp) { return SEXP2L(ENCLOS(exp ? L2SEXP(exp) : R_GlobalEnv)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniFindVar (JNIEnv *env, jobject this, jstring symName, jlong rho) { SEXP sym = jri_installString(env, symName); if (!sym || sym == R_NilValue) return 0; return SEXP2L(Rf_findVar(sym, rho ? L2SEXP(rho) : R_GlobalEnv)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniListEnv (JNIEnv *env, jobject this, jlong rho, jboolean all) { return SEXP2L(R_lsInternal(rho ? L2SEXP(rho) : R_GlobalEnv, all)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniSpecialObject (JNIEnv *env, jobject this, jint which) { switch (which) { case 0: return SEXP2L(R_NilValue); case 1: return SEXP2L(R_GlobalEnv); case 2: return SEXP2L(R_EmptyEnv); case 3: return SEXP2L(R_BaseEnv); case 4: return SEXP2L(R_UnboundValue); case 5: return SEXP2L(R_MissingArg); case 6: return SEXP2L(R_NaString); case 7: return SEXP2L(R_BlankString); } return 0; } JNIEXPORT jobject JNICALL Java_org_rosuda_JRI_Rengine_rniXrefToJava (JNIEnv *env, jobject this, jlong exp) { SEXP xp = L2SEXP(exp); if (TYPEOF(xp) != EXTPTRSXP) return 0; return (jobject) EXTPTR_PTR(xp); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniJavaToXref (JNIEnv *env, jobject this, jobject o) { /* this is pretty much from Rglue.c of rJava */ jobject go = (*env)->NewGlobalRef(env, o); return SEXP2L(R_MakeExternalPtr(go, R_NilValue, R_NilValue)); } JNIEXPORT jstring JNICALL Java_org_rosuda_JRI_Rengine_rniGetString (JNIEnv *env, jobject this, jlong exp) { return jri_putString(env, L2SEXP(exp), 0); } JNIEXPORT jobjectArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetStringArray (JNIEnv *env, jobject this, jlong exp) { return jri_putStringArray(env, L2SEXP(exp)); } JNIEXPORT jintArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetIntArray (JNIEnv *env, jobject this, jlong exp) { return jri_putIntArray(env, L2SEXP(exp)); } JNIEXPORT jbyteArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetRawArray (JNIEnv *env, jobject this, jlong exp) { return jri_putByteArray(env, L2SEXP(exp)); } JNIEXPORT jintArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetBoolArrayI (JNIEnv *env, jobject this, jlong exp) { return jri_putBoolArrayI(env, L2SEXP(exp)); } JNIEXPORT jintArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetDoubleArray (JNIEnv *env, jobject this, jlong exp) { return jri_putDoubleArray(env, L2SEXP(exp)); } JNIEXPORT jlongArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetVector (JNIEnv *env, jobject this, jlong exp) { return jri_putSEXPLArray(env, L2SEXP(exp)); } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniExpType (JNIEnv *env, jobject this, jlong exp) { return exp ? TYPEOF(L2SEXP(exp)) : 0; } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniIdle (JNIEnv *env, jobject this) { #ifdef Win32 if(!UserBreak)R_ProcessEvents(); #else R_runHandlers(R_InputHandlers, R_checkActivity(0, 1)); #endif } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniRunMainLoop (JNIEnv *env, jobject this) { run_Rmainloop(); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutString (JNIEnv *env, jobject this, jstring s) { return SEXP2L(jri_getString(env, s)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutStringArray (JNIEnv *env, jobject this, jobjectArray a) { return SEXP2L(jri_getStringArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutIntArray (JNIEnv *env, jobject this, jintArray a) { return SEXP2L(jri_getIntArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutRawArray (JNIEnv *env, jobject this, jbyteArray a) { return SEXP2L(jri_getByteArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutBoolArrayI (JNIEnv *env, jobject this, jintArray a) { return SEXP2L(jri_getBoolArrayI(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutBoolArray (JNIEnv *env, jobject this, jbooleanArray a) { return SEXP2L(jri_getBoolArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutDoubleArray (JNIEnv *env, jobject this, jdoubleArray a) { return SEXP2L(jri_getDoubleArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutVector (JNIEnv *env, jobject this, jlongArray a) { return SEXP2L(jri_getSEXPLArray(env, a)); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniGetAttr (JNIEnv *env, jobject this, jlong exp, jstring name) { SEXP an = jri_installString(env, name); if (!an || an==R_NilValue || exp==0 || L2SEXP(exp)==R_NilValue) return 0; { SEXP a = getAttrib(L2SEXP(exp), an); return (a==R_NilValue)?0:SEXP2L(a); } } JNIEXPORT jobjectArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetAttrNames (JNIEnv *env, jobject this, jlong exp) { SEXP o = L2SEXP(exp); SEXP att = ATTRIB(o), ah = att; unsigned int ac = 0; jobjectArray sa; if (att == R_NilValue) return 0; /* count the number of attributes */ while (ah != R_NilValue) { ac++; ah = CDR(ah); } /* allocate Java array */ sa = (*env)->NewObjectArray(env, ac, (*env)->FindClass(env, "java/lang/String"), 0); if (!sa) return 0; ac = 0; ah = att; /* iterate again and set create the strings */ while (ah != R_NilValue) { SEXP t = TAG(ah); if (t != R_NilValue) { jobject s = (*env)->NewStringUTF(env, CHAR_UTF8(PRINTNAME(t))); (*env)->SetObjectArrayElement(env, sa, ac, s); } ac++; ah = CDR(ah); } return sa; } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniSetAttr (JNIEnv *env, jobject this, jlong exp, jstring aName, jlong attr) { SEXP an = jri_installString(env, aName); if (!an || an==R_NilValue || exp==0 || L2SEXP(exp)==R_NilValue) return; setAttrib(L2SEXP(exp), an, (attr==0)?R_NilValue:L2SEXP(attr)); /* BTW: we don't need to adjust the object bit for "class", setAttrib does that already */ /* this is not official API, but whoever uses this should know what he's doing it's ok for directly constructing attr lists, and that's what it should be used for SET_ATTRIB(L2SEXP(exp), (attr==0)?R_NilValue:L2SEXP(attr)); */ } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniInstallSymbol (JNIEnv *env, jobject this, jstring s) { return SEXP2L(jri_installString(env, s)); } JNIEXPORT jstring JNICALL Java_org_rosuda_JRI_Rengine_rniGetSymbolName (JNIEnv *env, jobject this, jlong exp) { return jri_putSymbolName(env, L2SEXP(exp)); } JNIEXPORT jboolean JNICALL Java_org_rosuda_JRI_Rengine_rniInherits (JNIEnv *env, jobject this, jlong exp, jstring s) { jboolean res = 0; const char *c; c=(*env)->GetStringUTFChars(env, s, 0); if (c) { if (inherits(L2SEXP(exp), (char*)c)) res = 1; (*env)->ReleaseStringUTFChars(env, s, c); } return res; } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniCons (JNIEnv *env, jobject this, jlong head, jlong tail, jlong tag, jboolean lang) { SEXP l; if (lang) l = LCONS((head==0)?R_NilValue:L2SEXP(head), (tail==0)?R_NilValue:L2SEXP(tail)); else l = CONS((head==0)?R_NilValue:L2SEXP(head), (tail==0)?R_NilValue:L2SEXP(tail)); if (tag) SET_TAG(l, L2SEXP(tag)); return SEXP2L(l); } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniCAR (JNIEnv *env, jobject this, jlong exp) { if (exp) { SEXP r = CAR(L2SEXP(exp)); return (r==R_NilValue)?0:SEXP2L(r); } return 0; } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniCDR (JNIEnv *env, jobject this, jlong exp) { if (exp) { SEXP r = CDR(L2SEXP(exp)); return (r==R_NilValue)?0:SEXP2L(r); } return 0; } JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniTAG (JNIEnv *env, jobject this, jlong exp) { if (exp) { SEXP r = TAG(L2SEXP(exp)); return (r==R_NilValue)?0:SEXP2L(r); } return 0; } /* creates a list from SEXPs provided in long[] */ JNIEXPORT jlong JNICALL Java_org_rosuda_JRI_Rengine_rniPutList (JNIEnv *env, jobject this, jlongArray o) { SEXP t=R_NilValue; int l,i=0; jlong *ap; if (!o) return 0; l=(int)(*env)->GetArrayLength(env, o); if (l<1) return SEXP2L(CONS(R_NilValue, R_NilValue)); ap=(jlong*)(*env)->GetLongArrayElements(env, o, 0); if (!ap) return 0; while(iReleaseLongArrayElements(env, o, ap, 0); return SEXP2L(t); } /* retrieves a list (shallow copy) and returns the SEXPs in long[] */ JNIEXPORT jlongArray JNICALL Java_org_rosuda_JRI_Rengine_rniGetList (JNIEnv *env, jobject this, jlong exp) { SEXP e=L2SEXP(exp); if (exp==0 || e==R_NilValue) return 0; { unsigned len=0; SEXP t=e; while (t!=R_NilValue) { t=CDR(t); len++; }; { jlongArray da=(*env)->NewLongArray(env,len); jlong *dae; if (!da) return 0; if (len>0) { int i=0; dae=(*env)->GetLongArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("rniGetList: newLongArray.GetLongArrayElements failed"); return 0; } t=e; while (t!=R_NilValue && iReleaseLongArrayElements(env, da, dae, 0); } return da; } } } /* by default those are disabled as it's a problem on Win32 ... */ #ifdef JRI_ENV_CALLS JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniSetEnv (JNIEnv *env, jclass this, jstring key, jstring val) { const char *cKey, *cVal; if (!key || !val) return; cKey=(*env)->GetStringUTFChars(env, key, 0); cVal=(*env)->GetStringUTFChars(env, val, 0); if (!cKey || !cVal) { jri_error("rniSetEnv: can't retrieve key/value content"); return; } #ifdef Win32 SetEnvironmentVariable(cKey, cVal); #else setenv(cKey, cVal, 1); #endif (*env)->ReleaseStringUTFChars(env, key, cKey); (*env)->ReleaseStringUTFChars(env, val, cVal); } JNIEXPORT jstring JNICALL Java_org_rosuda_JRI_Rengine_rniGetEnv (JNIEnv *env, jclass this, jstring key) { const char *cKey, *cVal; if (!key) return; cKey=(*env)->GetStringUTFChars(env, key, 0); if (!cKey) { jri_error("rniSetEnv: can't retrieve key/value content"); return; } cVal=getenv(cKey); (*env)->ReleaseStringUTFChars(env, key, cKey); if (!cVal) return 0; return (*env)->NewStringUTF(env, cVal); } #endif JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniSetupRJava (JNIEnv *env, jobject this, jint _in, jint _out) { RJava_setup(_in, _out); return 0; } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniRJavaLock (JNIEnv *env, jobject this) { return RJava_request_lock(); } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniRJavaUnlock (JNIEnv *env, jobject this) { return RJava_clear_lock(); } JNIEXPORT void JNICALL Java_org_rosuda_JRI_Rengine_rniPrint (JNIEnv *env, jobject this, jstring s, jint oType) { if (s) { const char *c = (*env)->GetStringUTFChars(env, s, 0); if (c) { if (oType) REprintf("%s", c); else Rprintf("%s", c); } (*env)->ReleaseStringUTFChars(env, s, c); } } JNIEXPORT jint JNICALL Java_org_rosuda_JRI_Rengine_rniStop (JNIEnv *env, jobject this, jint flag) { #ifdef Win32 UserBreak=1; #else /* there are three choices now: 0 = cooperative (requires external interrupt of ReadConsole!) 1 = SIGINT for compatibility with old rniStop() 2 = R's onintr but that one works *only* if used on the R thread (which renders is essentially useless unless used in some synchronous interrupt handler). */ if (flag == 0) R_interrupts_pending = 1; else if (flag == 1) kill(getpid(), SIGINT); else Rf_onintr(); #endif return 0; } rJava/jri/src/globals.h0000644000175100001440000000022315133274032014477 0ustar hornikusers#ifndef __GLOBALS__H__ #define __GLOBALS__H__ #include extern jobject engineObj; extern jclass engineClass; extern JNIEnv *eenv; #endif rJava/jri/src/jri.h0000644000175100001440000000516015133274032013645 0ustar hornikusers#ifndef __JRI_H__ #define __JRI_H__ #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include /* the viewpoint is from R, i.e. "get" means "Java->R" whereas "put" means "R->Java" */ #define JRI_VERSION 0x0507 /* JRI v0.5-7 */ #define JRI_API 0x010a /* API-version 1.10 */ #ifdef __cplusplus extern "C" { #endif /* jlong can always hold a pointer to avoid warnings we go ptr->size_t->jlong */ #define SEXP2L(s) ((jlong)((size_t)(s))) #define L2SEXP(s) ((SEXP)((jlong)((size_t)(s)))) jstring jri_callToString(JNIEnv *env, jobject o); SEXP jri_getDoubleArray(JNIEnv *env, jarray o); SEXP jri_getIntArray(JNIEnv *env, jarray o); SEXP jri_getByteArray(JNIEnv *env, jarray o); SEXP jri_getBoolArrayI(JNIEnv *env, jarray o); SEXP jri_getBoolArray(JNIEnv *env, jarray o); SEXP jri_getObjectArray(JNIEnv *env, jarray o); SEXP jri_getString(JNIEnv *env, jstring s); SEXP jri_getStringArray(JNIEnv *env, jarray o); SEXP jri_getSEXPLArray(JNIEnv *env, jarray o); SEXP jri_installString(JNIEnv *env, jstring s); /* as Rf_install, just for Java strings */ jarray jri_putDoubleArray(JNIEnv *env, SEXP e); jarray jri_putIntArray(JNIEnv *env, SEXP e); jarray jri_putBoolArrayI(JNIEnv *env, SEXP e); jarray jri_putByteArray(JNIEnv *env, SEXP e); jstring jri_putString(JNIEnv *env, SEXP e, int ix); /* ix=index, 0=1st */ jarray jri_putStringArray(JNIEnv *env, SEXP e); jarray jri_putSEXPLArray(JNIEnv *env, SEXP e); /* SEXPs are strored as "long"s */ jstring jri_putSymbolName(JNIEnv *env, SEXP e); void jri_checkExceptions(JNIEnv *env, int describe); void jri_error(char *fmt, ...); /* define mkCharUTF8 in a compatible fashion */ #if R_VERSION < R_Version(2,7,0) #define mkCharUTF8(X) mkChar(X) #define CHAR_UTF8(X) CHAR(X) #else #define mkCharUTF8(X) mkCharCE(X, CE_UTF8) #define CHAR_UTF8(X) jri_char_utf8(X) const char *jri_char_utf8(SEXP); #endif #ifdef __cplusplus } #endif #endif /* API version changes: ----------------------- 1.3 (initial public API version) [ 1.4 never publicly released - added put/getenv but was abandoned ] 1.5 JRI 0.3-0 + rniGetTAG + rniInherits + rniGetSymbolName + rniInstallSymbol + rniJavaToXref, rniXrefToJava 1.6 JRI 0.3-2 + rniPutBoolArray, rniPutBoolArrayI, rniGetBoolArrayI 1.7 JRI 0.3-7 + rniCons(+2 args) 1.8 JRI 0.4-0 + rniPrint 1.9 JRI 0.4-3 + rniPreserve, rniRelease + rniParentEnv, rniFindVar, rniListEnv + rniSpecialObject(0-7) + rniPrintValue 1.10 JRI 0.5-1 * rniAssign returns jboolean instead of void */ rJava/jri/src/rjstring.h0000644000175100001440000000147115133274032014724 0ustar hornikusers#ifndef RJ_STRING_H__ #define RJ_STRING_H__ #include /* for jchar */ #include /* for SEXP */ /* --- API --- */ /* Returns static content for short strings so don't re-use. For dynamic strings uses R_alloc */ int rj_char_utf16(const char *c, int len, jchar **buf, const char *ifrom, int can_error); /* wrappers for above to use with CHARSXP to detect proper ifrom */ int rj_rchar_utf16(SEXP s, jchar **buf); int rj_rchar_utf16_noerr(SEXP s, jchar **buf); /* return jstring, but do NOT check exceptions */ jstring rj_newJavaString(JNIEnv *env, SEXP sChar); jstring rj_newNativeJavaString(JNIEnv *env, const char *str, int len); /* takes modified UTF-8 from Java, creates CHARSXP with valid UTF8 */ SEXP rj_mkCharUTF8(const char *src); SEXP rj_mkCharUTF8_noerr(const char *src); #endif rJava/jri/src/rjava.h0000644000175100001440000000104715133274032014164 0ustar hornikusers#ifndef __CALLBACK_H__ #define __CALLBACK_H__ #define RJavaActivity 16 /* all IPC messages are long-alligned */ #define IPCC_LOCK_REQUEST 1 #define IPCC_LOCK_GRANTED 2 /* reponse on IPCC_LOCK_REQUEST */ #define IPCC_CLEAR_LOCK 3 #define IPCC_CALL_REQUEST 4 /* pars: */ #define IPCC_CONTROL_ADDR 5 /* ipc: request, res: */ int RJava_request_lock(void); int RJava_clear_lock(void); /* int RJava_request_callback(callbackfn *fn, void *data); */ void RJava_setup(int _in, int _out); void RJava_init_ctrl(void); #endif rJava/jri/src/jri.c0000644000175100001440000003424115133274032013642 0ustar hornikusers#define USE_RINTERNALS 1 /* for efficiency */ #include "jri.h" #include #include #include #include #include #include /* debugging output (enable with -DRJ_DEBUG) */ #ifdef RJ_DEBUG static void rjprintf(char *fmt, ...) { va_list v; va_start(v,fmt); vprintf(fmt,v); va_end(v); } #define _dbg(X) X #else #define _dbg(X) #endif void jri_error(char *fmt, ...) { va_list v; va_start(v,fmt); vprintf(fmt,v); va_end(v); } /* profiling code (enable with -DRJ_PROFILE) */ #ifdef RJ_PROFILE #include static long time_ms() { #ifdef Win32 return 0; /* in Win32 we have no gettimeofday :( */ #else struct timeval tv; gettimeofday(&tv,0); return (tv.tv_usec/1000)+(tv.tv_sec*1000); #endif } long profilerTime; #define profStart() profilerTime=time_ms() static void profReport(char *fmt, ...) { long npt=time_ms(); va_list v; va_start(v,fmt); vprintf(fmt,v); va_end(v); printf(" %ld ms\n",npt-profilerTime); profilerTime=npt; } #define _prof(X) X #else #define profStart() #define _prof(X) #endif jstring jri_putString(JNIEnv *env, SEXP e, int ix) { return (TYPEOF(e) != STRSXP || LENGTH(e) <= ix || STRING_ELT(e, ix) == R_NaString) ? 0 : (*env)->NewStringUTF(env, CHAR_UTF8(STRING_ELT(e, ix))); } jarray jri_putStringArray(JNIEnv *env, SEXP e) { if (TYPEOF(e) != STRSXP) return 0; { int j = 0; jobjectArray sa = (*env)->NewObjectArray(env, LENGTH(e), (*env)->FindClass(env, "java/lang/String"), 0); if (!sa) { jri_error("Unable to create string array."); return 0; } while (j < LENGTH(e)) { SEXP elt = STRING_ELT(e, j); jobject s = (elt == R_NaString) ? 0 : (*env)->NewStringUTF(env, CHAR_UTF8(STRING_ELT(e,j))); _dbg(if (s) rjprintf (" [%d] \"%s\"\n",j,CHAR_UTF8(STRING_ELT(e,j))); else rjprintf(" [%d] NA\n", j)); (*env)->SetObjectArrayElement(env, sa, j, s); j++; } return sa; } } jarray jri_putIntArray(JNIEnv *env, SEXP e) { if (TYPEOF(e)!=INTSXP) return 0; _dbg(rjprintf(" integer vector of length %d\n",LENGTH(e))); { unsigned len=LENGTH(e); jintArray da=(*env)->NewIntArray(env,len); jint *dae; if (!da) { jri_error("newIntArray.new(%d) failed",len); return 0; } if (len>0) { dae=(*env)->GetIntArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("newIntArray.GetIntArrayElements failed"); return 0; } memcpy(dae,INTEGER(e),sizeof(jint)*len); (*env)->ReleaseIntArrayElements(env, da, dae, 0); } return da; } } jarray jri_putByteArray(JNIEnv *env, SEXP e) { if (TYPEOF(e) != RAWSXP) return 0; _dbg(rjprintf(" raw vector of length %d\n", LENGTH(e))); { unsigned len = LENGTH(e); jbyteArray da = (*env)->NewByteArray(env,len); jbyte *dae; if (!da) { jri_error("newByteArray.new(%d) failed",len); return 0; } if (len > 0) { dae = (*env)->GetByteArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env, da); jri_error("newByteArray.GetByteArrayElements failed"); return 0; } memcpy(dae, RAW(e), len); (*env)->ReleaseByteArrayElements(env, da, dae, 0); } return da; } } jarray jri_putBoolArrayI(JNIEnv *env, SEXP e) { if (TYPEOF(e)!=LGLSXP) return 0; _dbg(rjprintf(" integer vector of length %d\n",LENGTH(e))); { unsigned len=LENGTH(e); jintArray da=(*env)->NewIntArray(env,len); jint *dae; if (!da) { jri_error("newIntArray.new(%d) failed",len); return 0; } if (len>0) { dae=(*env)->GetIntArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("newIntArray.GetIntArrayElements failed"); return 0; } memcpy(dae,INTEGER(e),sizeof(jint)*len); (*env)->ReleaseIntArrayElements(env, da, dae, 0); } return da; } } jarray jri_putSEXPLArray(JNIEnv *env, SEXP e) { _dbg(rjprintf(" general vector of length %d\n",LENGTH(e))); { unsigned len=LENGTH(e); jlongArray da=(*env)->NewLongArray(env,len); jlong *dae; if (!da) { jri_error("newLongArray.new(%d) failed",len); return 0; } if (len>0) { int i=0; dae=(*env)->GetLongArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("newLongArray.GetLongArrayElements failed"); return 0; } while (iReleaseLongArrayElements(env, da, dae, 0); } return da; } } jarray jri_putDoubleArray(JNIEnv *env, SEXP e) { if (TYPEOF(e)!=REALSXP) return 0; _dbg(rjprintf(" real vector of length %d\n",LENGTH(e))); { unsigned len=LENGTH(e); jdoubleArray da=(*env)->NewDoubleArray(env,len); jdouble *dae; if (!da) { jri_error("newDoubleArray.new(%d) failed",len); return 0; } if (len>0) { dae=(*env)->GetDoubleArrayElements(env, da, 0); if (!dae) { (*env)->DeleteLocalRef(env,da); jri_error("newDoubleArray.GetDoubleArrayElements failed"); return 0; } memcpy(dae,REAL(e),sizeof(jdouble)*len); (*env)->ReleaseDoubleArrayElements(env, da, dae, 0); } return da; } } /** jobjRefInt object : string */ SEXP jri_getString(JNIEnv *env, jstring s) { SEXP r; const char *c; if (!s) return ScalarString(R_NaString); profStart(); c = (*env)->GetStringUTFChars(env, s, 0); if (!c) { jri_error("jri_getString: can't retrieve string content"); return R_NilValue; } PROTECT(r = allocVector(STRSXP,1)); SET_STRING_ELT(r, 0, mkCharUTF8(c)); UNPROTECT(1); (*env)->ReleaseStringUTFChars(env, s, c); _prof(profReport("jri_getString:")); return r; } SEXP jri_installString(JNIEnv *env, jstring s) { SEXP r; const char *c; if (!s) return R_NilValue; profStart(); c=(*env)->GetStringUTFChars(env, s, 0); if (!c) { jri_error("jri_getString: can't retrieve string content"); return R_NilValue; } r = install(c); (*env)->ReleaseStringUTFChars(env, s, c); _prof(profReport("jri_getString:")); return r; } jstring jri_putSymbolName(JNIEnv *env, SEXP e) { SEXP pn; if (TYPEOF(e)!=SYMSXP) return 0; pn=PRINTNAME(e); return (TYPEOF(pn)!=CHARSXP)?0:(*env)->NewStringUTF(env, CHAR_UTF8(pn)); } /** calls .toString() of the object and returns the corresponding string java object */ jstring jri_callToString(JNIEnv *env, jobject o) { jclass cls; jmethodID mid; cls=(*env)->GetObjectClass(env,o); if (!cls) { jri_error("RtoString: can't determine class of the object"); return 0; } mid=(*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); if (!mid) { jri_error("RtoString: toString not found for the object"); return 0; } return (jstring)(*env)->CallObjectMethod(env, o, mid); } /* FIXME: this should never be used as 64-bit platforms can't stuff a pointer in any R type (save for raw which must be interpreted accordingly) */ SEXP jri_getObjectArray(JNIEnv *env, jarray o) { SEXP ar; int l,i; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert object array of length %d\n",l)); if (l<1) return R_NilValue; PROTECT(ar=allocVector(INTSXP,l)); i=0; while (i < l) { /* to avoid warnings we cast ptr -> size_t -> int with loss of precision */ INTEGER(ar)[i] = (int)(size_t)(*env)->GetObjectArrayElement(env, o, i); i++; } UNPROTECT(1); _prof(profReport("RgetObjectArrayCont[%d]:",o)); return ar; } /** get contents of the object array in the form of int* */ SEXP jri_getStringArray(JNIEnv *env, jarray o) { SEXP ar; int l, i; const char *c; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l = (int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert string array of length %d\n",l)); PROTECT(ar = allocVector(STRSXP,l)); for (i = 0; i < l; i++) { jobject sobj = (*env)->GetObjectArrayElement(env, o, i); c = 0; if (sobj) { /* we could (should?) check the type here ... if (!(*env)->IsInstanceOf(env, sobj, javaStringClass)) { printf(" not a String\n"); } else */ c = (*env)->GetStringUTFChars(env, sobj, 0); } if (!c) SET_STRING_ELT(ar, i, R_NaString); /* this is probably redundant since the vector is pre-filled with NAs, but just in case ... */ else { SET_STRING_ELT(ar, i, mkCharUTF8(c)); (*env)->ReleaseStringUTFChars(env, sobj, c); } } UNPROTECT(1); _prof(profReport("RgetStringArrayCont[%d]:",o)); return ar; } /** get contents of the integer array object (int) */ SEXP jri_getIntArray(JNIEnv *env, jarray o) { SEXP ar; int l; jint *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert int array of length %d\n",l)); if (l<1) return R_NilValue; ap=(jint*)(*env)->GetIntArrayElements(env, o, 0); if (!ap) { jri_error("RgetIntArrayCont: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(INTSXP,l)); memcpy(INTEGER(ar),ap,sizeof(jint)*l); UNPROTECT(1); (*env)->ReleaseIntArrayElements(env, o, ap, 0); _prof(profReport("RgetIntArrayCont[%d]:",o)); return ar; } /** get contents of the integer array object (int) */ SEXP jri_getByteArray(JNIEnv *env, jarray o) { SEXP ar; int l; jbyte *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l = (int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert byte array of length %d\n",l)); if (l < 1) return R_NilValue; ap = (jbyte*)(*env)->GetByteArrayElements(env, o, 0); if (!ap) { jri_error("jri_getByteArray: can't fetch array contents"); return 0; } ar = allocVector(RAWSXP, l); memcpy(RAW(ar), ap, l); (*env)->ReleaseByteArrayElements(env, o, ap, 0); _prof(profReport("RgetByteArrayCont[%d]:",o)); return ar; } /** get contents of the integer array object (int) into a logical R vector */ SEXP jri_getBoolArrayI(JNIEnv *env, jarray o) { SEXP ar; int l; jint *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert int array of length %d into R bool\n",l)); if (l<1) return R_NilValue; ap=(jint*)(*env)->GetIntArrayElements(env, o, 0); if (!ap) { jri_error("RgetBoolArrayICont: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(LGLSXP,l)); memcpy(LOGICAL(ar),ap,sizeof(jint)*l); UNPROTECT(1); (*env)->ReleaseIntArrayElements(env, o, ap, 0); _prof(profReport("RgetBoolArrayICont[%d]:",o)); return ar; } /** get contents of the boolean array object into a logical R vector */ SEXP jri_getBoolArray(JNIEnv *env, jarray o) { SEXP ar; int l; jboolean *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert boolean array of length %d into R bool\n",l)); if (l<1) return R_NilValue; ap=(jboolean*)(*env)->GetBooleanArrayElements(env, o, 0); if (!ap) { jri_error("RgetBoolArrayCont: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(LGLSXP,l)); { int i=0; int *lgl = LOGICAL(ar); while (iReleaseBooleanArrayElements(env, o, ap, 0); _prof(profReport("RgetBoolArrayCont[%d]:",o)); return ar; } SEXP jri_getSEXPLArray(JNIEnv *env, jarray o) { SEXP ar; int l,i=0; jlong *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert SEXPL array of length %d\n",l)); if (l<1) return R_NilValue; ap=(jlong*)(*env)->GetLongArrayElements(env, o, 0); if (!ap) { jri_error("getSEXPLArray: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(VECSXP,l)); while (iReleaseLongArrayElements(env, o, ap, 0); _prof(profReport("jri_getSEXPLArray[%d]:",o)); return ar; } /** get contents of the double array object (int) */ SEXP jri_getDoubleArray(JNIEnv *env, jarray o) { SEXP ar; int l; jdouble *ap; profStart(); _dbg(rjprintf(" jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf("convert double array of length %d\n",l)); if (l<1) return R_NilValue; ap=(jdouble*)(*env)->GetDoubleArrayElements(env, o, 0); if (!ap) { jri_error("RgetDoubleArrayCont: can't fetch array contents"); return 0; } PROTECT(ar=allocVector(REALSXP,l)); memcpy(REAL(ar),ap,sizeof(jdouble)*l); UNPROTECT(1); (*env)->ReleaseDoubleArrayElements(env, o, ap, 0); _prof(profReport("RgetDoubleArrayCont[%d]:",o)); return ar; } #if R_VERSION >= R_Version(2,7,0) /* returns string from a CHARSXP making sure that the result is in UTF-8 */ const char *jri_char_utf8(SEXP s) { if (Rf_getCharCE(s) == CE_UTF8) return CHAR(s); return Rf_reEnc(CHAR(s), getCharCE(s), CE_UTF8, 1); /* subst. invalid chars: 1=hex, 2=., 3=?, other=skip */ } #endif void jri_checkExceptions(JNIEnv *env, int describe) { jthrowable t=(*env)->ExceptionOccurred(env); if (t) { #ifndef JRI_DEBUG if (describe) #endif (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); } } rJava/jri/src/rjstring.c0000644000175100001440000001624015133274032014717 0ustar hornikusers#include "rjstring.h" #include #include #include #include #ifdef WIN32 /* -- currently unused - was used to mimick reEnc() extern unsigned int localeCP; static char cpbuf[16]; */ #endif static jchar js_zero[2] = { 0, 0 }; static jchar js_buf[128]; /* if len = -1 then c is assumed to be NUL terminated */ int rj_char_utf16(const char *c, int len, jchar **buf, const char *ifrom, int can_error) { void *ih; const char *ce = (len < 0) ? strchr(c, 0) : (c + len); if (ce == c) { buf[0] = js_zero; return 0; } size_t osize = sizeof(jchar) * (ce - c + 1), isize = ce - c; jchar *js = buf[0] = (osize < sizeof(js_buf)) ? js_buf : (jchar*) R_alloc(sizeof(jchar), ce - c + 1); char *dst = (char*) js; int end_test = 1, is_le = (((char*)&end_test)[0] == 1) ? 1 : 0; if (!ifrom) ifrom = ""; #ifdef DEBUG_ENCODING fprintf(stderr, "rJava.rj_char_utf16_native:"); { const char *c0 = c; while (*c0) fprintf(stderr, " %02x", (int)((unsigned char)*(c0++))); } fprintf(stderr, "\n"); #endif ih = Riconv_open(is_le ? "UTF-16LE" : "UTF-16BE", ifrom); if (ih == (void *)(-1)) { if (can_error) Rf_error("Unable to start conversion to UTF-16"); return -1; } while (c < ce) { size_t res = Riconv(ih, &c, &isize, &dst, &osize); /* this should never happen since we allocated far more than needed */ if (res == -1 && errno == E2BIG) { if (can_error) Rf_error("Conversion to UTF-16 failed due to unexpectedly large buffer requirements."); return -1; } else if(res == -1 && (errno == EILSEQ || errno == EINVAL)) { /* invalid char */ if (is_le) { *(dst++) = '?'; *(dst++) = 0; } else { *(dst++) = 0; *(dst++) = '?'; } osize -= 2; c++; isize--; } } Riconv_close(ih); #ifdef DEBUG_ENCODING { const jchar *j = js; while (j < (const jchar*)dst) fprintf(stderr, " %04x", (unsigned int)*(j++)); } fprintf(stderr, "\n"); #endif return dst - (char*) js; } /* returns string from a CHARSXP making sure that the result is in UTF-16. the buffer is owned by the function and may be static, so copy after use. Returns the length of the resulting string or -1 on error (if can_error is 0). */ static int rj_CHARSXP_utf16_(SEXP s, jchar **buf, int can_error) { cetype_t ce_in = getCharCE(s); const char *ifrom = "", *c = CHAR(s), *ce = strchr(c, 0); if (ce == c) { buf[0] = js_zero; return 0; } switch (ce_in) { #ifdef WIN32 case CE_NATIVE: /* reEnc uses this, but translateCharUtf8 uses "" so let's go with "" sprintf(cpbuf, "CP%d", localeCP); ifrom = cpbuf; */ break; case CE_LATIN1: ifrom = "CP1252"; break; #else case CE_NATIVE: break; /* is already "" */ case CE_LATIN1: ifrom = "latin1"; break; #endif default: ifrom = "UTF-8"; break; } return rj_char_utf16(c, ce - c, buf, ifrom, can_error); } int rj_rchar_utf16(SEXP s, jchar **buf) { return rj_CHARSXP_utf16_(s, buf, 1); } int rj_rchar_utf16_noerr(SEXP s, jchar **buf) { return rj_CHARSXP_utf16_(s, buf, 0); } /* FIXME: we should probably deprecate this as well and use UTF-16 instead. The only reason not to is that we would have to fully implement a full UTF-16 -> UTF-8 conversion including surrogate pairs ... */ /* Java returns *modified* UTF-8 which is incompatible with UTF-8, so we have to detect the illegal surrgoate pairs and convert them */ SEXP rj_mkCharUTF8_(const char *src, int can_error) { const unsigned char *s = (const unsigned char*) src; const unsigned char *c = (const unsigned char*) s; /* check if the string contains any surrogate pairs, i.e. Unicode in the range 0xD800-0xDFFF We want this to be fast since in 99.99% of cases it will be false */ while (*c) { if (c[0] == 0xED && (c[1] & 0xE0) == 0xA0) break; c++; } if (*c) { /* yes, we have to convert them */ SEXP res; const unsigned char *e = (const unsigned char*) strchr((const char*)s, 0); /* find the end for size */ unsigned char *dst = 0, *d, sbuf[64]; if (!e) /* should never occur */ return mkChar(""); /* we use static buffer for small strings and dynamic alloc for large */ if (e - s >= sizeof(sbuf)) { /* allocate temp buffer since our input is const */ d = dst = (unsigned char *) malloc(e - s + 1); if (!dst) { if (can_error) Rf_error("Cannot allocate memory for surrogate pair conversion"); return 0; } } else d = (unsigned char *)sbuf; if (c - s > 0) { memcpy(d, s, c - s); d += c - s; } while (*c) { unsigned int u1, u; *(d++) = *(c++); /* start of a sequence ? */ if ((c[-1] & 0xC0) != 0xC0) continue; if ((c[-1] & 0xE0) == 0xC0) { /* 2-byte, not a surrogate pair */ if ((c[0] & 0xC0) != 0x80) { if (dst) free(dst); if (can_error) Rf_error("illegal 2-byte sequence in Java string"); return 0; } *(d++) = *(c++); continue; } if ((c[-1] & 0xF0) != 0xE0) { /* must be 3-byte */ if (dst) free(dst); if (can_error) Rf_error("illegal multi-byte seqeunce in Java string (>3-byte)"); return 0; } if (((c[0] & 0xC0) != 0x80 || (c[1] & 0xC0) != 0x80)) { if (dst) free(dst); if (can_error) Rf_error("illegal 3-byte sequence in Java string"); return 0; } u1 = ((((unsigned int)c[-1]) & 0x0F) << 12) | ((((unsigned int)c[0]) & 0x3F) << 6) | (((unsigned int)c[1]) & 0x3F); if (u1 < 0xD800 || u1 > 0xDBFF) { /* not a surrogate pair -> regular copy */ *(d++) = *(c++); *(d++) = *(c++); continue; } if (u1 >= 0xDC00 && u1 <= 0xDFFF) { /* low surrogate pair ? */ if (dst) free(dst); if (can_error) Rf_error("illegal sequence in Java string: low surrogate pair without a high one"); return 0; } c += 2; /* move to the low pair */ if (c[0] != 0xED || (c[1] & 0xF0) != 0xB0 || (c[2] & 0xC0) != 0x80) { if (dst) free(dst); if (can_error) Rf_error("illegal sequence in Java string: high surrogate pair not followed by low one"); return 0; } /* the actually encoded unicode character */ u = ((((unsigned int)c[1]) & 0x0F) << 6) | (((unsigned int)c[2]) & 0x3F); u |= (u1 & 0x03FF) << 10; u += 0x10000; c += 3; /* it must be <= 0x10FFFF by design (each surrogate has 10 bits) */ d[-1] = (unsigned char) (((u >> 18) & 0x0F) | 0xF0); *(d++) = (unsigned char) (((u >> 12) & 0x3F) | 0x80); *(d++) = (unsigned char) (((u >> 6) & 0x3F) | 0x80); *(d++) = (unsigned char) ((u & 0x3F) | 0x80); } res = mkCharLenCE((const char*) (dst ? dst : sbuf), dst ? (d - dst) : (d - sbuf), CE_UTF8); if (dst) free(dst); return res; } return mkCharLenCE(src, c - s, CE_UTF8); } SEXP rj_mkCharUTF8(const char *src) { return rj_mkCharUTF8_(src, 0); } SEXP rj_mkCharUTF8_noerr(const char *src) { return rj_mkCharUTF8_(src, 1); } jstring rj_newJavaString(JNIEnv *env, SEXP sChar) { jchar *s; int len = rj_rchar_utf16(sChar, &s); return (*env)->NewString(env, s, (len + 1) >> 1); } jstring rj_newNativeJavaString(JNIEnv *env, const char *str, int len) { jchar *s; int rlen = rj_char_utf16(str, len, &s, "", 0); return (rlen < 0) ? 0 : (*env)->NewString(env, s, (rlen + 1) >> 1); } rJava/jri/src/Rinit.h0000644000175100001440000000015715133274032014147 0ustar hornikusers#ifndef __R_INIT__H__ #define __R_INIT__H__ int initR(int argc, char **argv); void initRinside(void); #endif rJava/jri/src/rjava.c0000644000175100001440000000240015133274032014151 0ustar hornikusers#include "rjava.h" #include #ifdef _WIN64 typedef long long ptrlong; #else typedef long ptrlong; #endif int ipcout; int resin; int *rjctrl = 0; typedef void(callbackfn)(void *); int RJava_request_lock(void) { ptrlong buf[4]; int n; if (rjctrl && *rjctrl) return 2; buf[0] = IPCC_LOCK_REQUEST; if (write(ipcout, buf, sizeof(ptrlong)) < sizeof(ptrlong)) return 0; n = read(resin, buf, sizeof(ptrlong)); return (n == sizeof(ptrlong) && buf[0] == IPCC_LOCK_GRANTED) ? 1 : 0; } int RJava_clear_lock(void) { ptrlong buf[4]; buf[0] = IPCC_CLEAR_LOCK; return (write(ipcout, buf, sizeof(ptrlong)) == sizeof(ptrlong)) ? 1 : 0; } int RJava_request_callback(callbackfn *fn, void *data) { ptrlong buf[4]; buf[0] = IPCC_CALL_REQUEST; buf[1] = (ptrlong) fn; buf[2] = (ptrlong) data; return (write(ipcout, buf, sizeof(ptrlong) * 3) == sizeof(ptrlong) * 3) ? 1 : 0; } void RJava_setup(int _in, int _out) { /* ptrlong buf[4]; */ ipcout = _out; resin = _in; } void RJava_init_ctrl(void) { ptrlong buf[4]; buf[0] = IPCC_CONTROL_ADDR; if (write(ipcout, buf, sizeof(ptrlong)) == sizeof(ptrlong) && read(resin, buf, sizeof(ptrlong) * 2) == sizeof(ptrlong) * 2 && buf[0] == IPCC_CONTROL_ADDR) { rjctrl= (int*) buf[1]; } } rJava/jri/src/Rcallbacks.c0000644000175100001440000002653215133274032015123 0ustar hornikusers#include #include #include "jri.h" #include "globals.h" #include "Rdecl.h" #include "Rcallbacks.h" #include "rjstring.h" #include "org_rosuda_JRI_Rengine.h" #include #ifndef Win32 #include #endif #ifdef Win32 #include #else /* from Defn.h (do we still need it? Re_CleanUp is commented out ...) extern Rboolean R_Interactive; */ #endif #if R_VERSION < R_Version(2,6,0) #ifndef checkArity #define checkArity Rf_checkArity #endif #else #define checkArity(X,Y) #endif #ifndef errorcall #define errorcall Rf_errorcall #endif /* this method is used rather for debugging purposes - it finds the correct JNIEnv for the current thread. we still have some threading issues to solve, becuase eenv!=env should never happen (uncontrolled), because concurrency issues arise */ static JavaVM *jvm=0; JNIEnv *checkEnvironment(void) { JNIEnv *env; jsize l; jint res; if (!jvm) { /* we're hoping that the JVM pointer won't change :P we fetch it just once */ res= JNI_GetCreatedJavaVMs(&jvm, 1, &l); if (res!=0) { fprintf(stderr, "JNI_GetCreatedJavaVMs failed! (%d)\n",(int)res); return 0; } if (l<1) { fprintf(stderr, "JNI_GetCreatedJavaVMs said there's no JVM running!\n"); return 0; } } res = (*jvm)->AttachCurrentThread(jvm, (void*) &env, 0); if (res!=0) { fprintf(stderr, "AttachCurrentThread failed! (%d)\n",(int)res); return 0; } #ifdef JRI_DEBUG if (eenv!=env) fprintf(stderr, "Warning! eenv=%x, but env=%x - different environments encountered!\n", eenv, env); #endif return env; } int Re_ReadConsole(RCCONST char *prompt, RCSIGN char *buf, int len, int addtohistory) { jstring r, s; jmethodID mid; JNIEnv *lenv=checkEnvironment(); const void *vmax = 0; int ret = -1; const char *c = 0; if (!lenv || !engineObj) return -1; jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(eenv, engineClass, "jriReadConsole", "(Ljava/lang/String;I)Ljava/lang/String;"); #ifdef JRI_DEBUG printf("jriReadconsole mid=%x\n", mid); #endif jri_checkExceptions(lenv, 0); if (!mid) return -1; vmax = vmaxget(); s = rj_newNativeJavaString(lenv, prompt, -1); vmaxset(vmax); if (!s) return -1; r = (jstring) (*lenv)->CallObjectMethod(lenv, engineObj, mid, s, addtohistory); jri_checkExceptions(lenv, 1); (*lenv)->DeleteLocalRef(lenv, s); jri_checkExceptions(lenv, 0); while (r) { /* get string in Java UTF-8 */ c = (*lenv)->GetStringUTFChars(lenv, r, 0); if (!c) break; vmax = vmaxget(); /* convert from Java UTF-8 to real UTF-8 in a CHARSXP */ SEXP sRes = rj_mkCharUTF8_noerr(c); if (!sRes) { vmaxset(vmax); break; } /* UTF8 -> native */ const char *rc = Rf_translateChar(sRes); int l = strlen(rc); strncpy((char*)buf, rc, (l > len - 1) ? len - 1 : l); vmaxset(vmax); /* truncate if needed */ buf[(l > len - 1) ? len - 1 : l] = 0; #ifdef JRI_DEBUG printf("Re_ReadConsole succeeded: \"%s\"\n", buf); #endif ret = 1; break; } if (r) { if (c) (*lenv)->ReleaseStringUTFChars(lenv, r, c); (*lenv)->DeleteLocalRef(lenv, r); } return ret; } void Re_Busy(int which) { jmethodID mid; JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(lenv, engineClass, "jriBusy", "(I)V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriBusy mid=%x\n", mid); #endif if (!mid) return; (*lenv)->CallVoidMethod(lenv, engineObj, mid, which); jri_checkExceptions(lenv, 1); } void Re_WriteConsoleEx(RCCONST char *buf, int len, int oType) { JNIEnv *lenv = checkEnvironment(); jri_checkExceptions(lenv, 1); const void *vmax = vmaxget(); jstring s = rj_newNativeJavaString(lenv, buf, len); vmaxset(vmax); if (!s) { #ifdef JRI_DEBUG printf("jriWriteConsole rj_newNativeJavaString() FAILED!\n"); #endif return; } jmethodID mid = (*lenv)->GetMethodID(lenv, engineClass, "jriWriteConsole", "(Ljava/lang/String;I)V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriWriteConsole mid=%x\n", mid); #endif if (!mid) return; (*lenv)->CallVoidMethod(lenv, engineObj, mid, s, oType); jri_checkExceptions(lenv, 1); (*lenv)->DeleteLocalRef(lenv, s); } /* old-style WriteConsole (for old R versions only) */ void Re_WriteConsole(RCCONST char *buf, int len) { Re_WriteConsoleEx(buf, len, 0); } /* Indicate that input is coming from the console */ void Re_ResetConsole(void) { } /* Stdio support to ensure the console file buffer is flushed */ void Re_FlushConsole(void) { JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); { jmethodID mid=(*lenv)->GetMethodID(lenv, engineClass, "jriFlushConsole", "()V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriFlushConsole mid=%x\n", mid); #endif if (!mid) return; (*lenv)->CallVoidMethod(lenv, engineObj, mid); jri_checkExceptions(lenv, 1); } } /* Reset stdin if the user types EOF on the console. */ void Re_ClearerrConsole(void) { } int Re_ChooseFile(int new, char *buf, int len) { JNIEnv *lenv=checkEnvironment(); if (lenv && engineObj) { jmethodID mid; jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(eenv, engineClass, "jriChooseFile", "(I)Ljava/lang/String;"); #ifdef JRI_DEBUG printf("jriChooseFile mid=%x\n", mid); #endif jri_checkExceptions(lenv, 0); if (mid) { jstring r=(jstring) (*lenv)->CallObjectMethod(lenv, engineObj, mid, new); jri_checkExceptions(lenv, 1); if (r) { int slen=0; const char *c=(*lenv)->GetStringUTFChars(lenv, r, 0); if (c) { slen=strlen(c); strncpy(buf, c, (slen>len-1)?len-1:slen); buf[(slen>len-1)?len-1:slen]=0; #ifdef JRI_DEBUG printf("Re_ChooseFile succeeded: \"%s\"\n",buf); #endif } (*lenv)->ReleaseStringUTFChars(lenv, r, c); (*lenv)->DeleteLocalRef(lenv, r); jri_checkExceptions(lenv, 0); return slen; } else return 0; } } /* "native" fallback if there's no such method */ { int namelen; char *bufp; R_ReadConsole("Enter file name: ", (unsigned char *)buf, len, 0); namelen = strlen(buf); bufp = &buf[namelen - 1]; while (bufp >= buf && isspace((int)*bufp)) *bufp-- = '\0'; return strlen(buf); } } void Re_ShowMessage(RCCONST char *buf) { jstring s; jmethodID mid; JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); s=(*lenv)->NewStringUTF(lenv, buf); mid=(*lenv)->GetMethodID(lenv, engineClass, "jriShowMessage", "(Ljava/lang/String;)V"); jri_checkExceptions(lenv, 0); #ifdef JGR_DEBUG printf("jriShowMessage mid=%x\n", mid); #endif if (mid) (*lenv)->CallVoidMethod(eenv, engineObj, mid, s); jri_checkExceptions(lenv, 0); if (s) (*lenv)->DeleteLocalRef(eenv, s); } void Re_read_history(char *buf) { } void Re_loadhistory(SEXP call, SEXP op, SEXP args, SEXP env) { jmethodID mid; jstring s; JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(lenv, engineClass, "jriLoadHistory", "(Ljava/lang/String;)V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriLoadHistory mid=%x\n", mid); #endif if (!mid) { #ifdef JRI_DEBUG printf("can't find jriLoadHistory method\n"); #endif return; } { SEXP sfile; const char *p; checkArity(op, args); sfile = CAR(args); if (!isString(sfile) || LENGTH(sfile) < 1) errorcall(call, "invalid file argument"); p = R_ExpandFileName((char*)CHAR(STRING_ELT(sfile, 0))); if(strlen(p) > PATH_MAX - 1) errorcall(call, "file argument is too long"); s=(*lenv)->NewStringUTF(lenv, p); } (*lenv)->CallVoidMethod(lenv, engineObj, mid, s); jri_checkExceptions(lenv, 1); if (s) (*lenv)->DeleteLocalRef(lenv, s); } void Re_savehistory(SEXP call, SEXP op, SEXP args, SEXP env) { jmethodID mid; jstring s; JNIEnv *lenv=checkEnvironment(); jri_checkExceptions(lenv, 1); mid=(*lenv)->GetMethodID(lenv, engineClass, "jriSaveHistory", "(Ljava/lang/String;)V"); jri_checkExceptions(lenv, 0); #ifdef JRI_DEBUG printf("jriSaveHistory mid=%x\n", mid); #endif if (!mid) errorcall(call, "can't find jriSaveHistory method"); { SEXP sfile; const char *p; checkArity(op, args); sfile = CAR(args); if (!isString(sfile) || LENGTH(sfile) < 1) errorcall(call, "invalid file argument"); p = R_ExpandFileName(CHAR(STRING_ELT(sfile, 0))); if(strlen(p) > PATH_MAX - 1) errorcall(call, "file argument is too long"); s=(*lenv)->NewStringUTF(lenv, p); } (*lenv)->CallVoidMethod(lenv, engineObj, mid, s); jri_checkExceptions(lenv, 1); if (s) (*lenv)->DeleteLocalRef(lenv, s); /* strcpy(file, p); write_history(file); history_truncate_file(file, R_HistorySize); */ } /* R_CleanUp is invoked at the end of the session to give the user the option of saving their data. If ask == SA_SAVEASK the user should be asked if possible (and this option should not occur in non-interactive use). If ask = SA_SAVE or SA_NOSAVE the decision is known. If ask = SA_DEFAULT use the SaveAction set at startup. In all these cases run .Last() unless quitting is cancelled. If ask = SA_SUICIDE, no save, no .Last, possibly other things. */ /* void Re_CleanUp(SA_TYPE saveact, int status, int runLast) { unsigned char buf[1024]; char * tmpdir; if(saveact == SA_DEFAULT) saveact = SaveAction; if(saveact == SA_SAVEASK) { if(R_Interactive) { qask: R_ClearerrConsole(); R_FlushConsole(); R_ReadConsole("Save workspace image? [y/n/c]: ", buf, 128, 0); switch (buf[0]) { case 'y': case 'Y': saveact = SA_SAVE; break; case 'n': case 'N': saveact = SA_NOSAVE; break; case 'c': case 'C': jump_to_toplevel(); break; default: goto qask; } } else saveact = SaveAction; } switch (saveact) { case SA_SAVE: if(runLast) R_dot_Last(); if(R_DirtyImage) R_SaveGlobalEnv(); stifle_history(R_HistorySize); write_history(R_HistoryFile); break; case SA_NOSAVE: if(runLast) R_dot_Last(); break; case SA_SUICIDE: default: break; } R_RunExitFinalizers(); CleanEd(); if(saveact != SA_SUICIDE) KillAllDevices(); if((tmpdir = getenv("R_SESSION_TMPDIR"))) { snprintf((char *)buf, 1024, "rm -rf %s", tmpdir); R_system((char *)buf); } if(saveact != SA_SUICIDE && R_CollectWarnings) PrintWarnings(); fpu_setup(FALSE); exit(status); } void Rstd_Suicide(char *s) { REprintf("Fatal error: %s\n", s); R_CleanUp(SA_SUICIDE, 2, 0); } */ int Re_ShowFiles(int nfile, /* number of files */ RCCONST char **file, /* array of filenames */ RCCONST char **headers,/* the `headers' args of file.show. Printed before each file. */ RCCONST char *wtitle, /* title for window = `title' arg of file.show */ Rboolean del, /* should files be deleted after use? */ RCCONST char *pager) /* pager to be used */ { return 1; } rJava/jri/src/h2ic0000755000175100001440000000201015133274032013452 0ustar hornikusers#!/usr/bin/perl $fn=shift; print "#include \"$fn\"\n#include \n\n"; open IN, $fn; $fn=~s/\..*?$//; $fn=$1 if ($fn=~/\/([^\/]+)$/); $pre=$fn; while () { if (/^JNIEXPORT ([a-z]+) JNICALL ([a-zA-Z0-9_]+)/) { $ret=$1; $fn=$2; $a=; if ($a=~/\((JNIEnv.*)\)/) { $par=$1; @p=split /,/,$par; $i=0; undef @pc; foreach (@p) { $_.=" par$i"; push @pc, "par$i"; $i++; } $parn=join ',',@p; $parc=join ', ',@pc; $rc = ($ret eq 'void')?'':'return '; print "typedef $ret(*c_${fn}_t)($par);\nc_${fn}_t Call_$fn;\n"; print "JNIEXPORT $ret JNICALL $fn\n ($parn) {\n $rc Call_$fn($parc);\n }\n\n"; push @fnl, $fn; } } } print "void Setup_$pre(void **ptrs) {\n"; $i=0; foreach (@fnl) { print "Call_$_ = (c_${_}_t) ptrs[$i];\n"; $i++; } print "}\n\n"; $i=0; print "void **GetRef_$pre() { void **ptrs = (void**) malloc(sizeof(void*) * ( $#fnl + 2 ) ); "; foreach (@fnl) { print "ptrs[$i] = (void*) Call_$_;\n"; $i++; } print "ptrs[$i] = (void*) 0;\nreturn ptrs;\n}\n"; rJava/jri/Mutex.java0000644000175100001440000001327115133274032014070 0ustar hornikuserspackage org.rosuda.JRI; /** This class implements a (not so) simple mutex. The initial state of the mutex is unlocked. */ public class Mutex { public static boolean verbose=false; /** defines the current mutex state */ private boolean locked=false; /** thread that locked this mutex (used for simple deadlock-detection) */ private Thread lockedBy=null; /** locks the mutex. If the mutex is already locked, waits until the mutex becomes free. Make sure the same thread doesn't issue two locks, because that will cause a deadlock. Use {@link #safeLock()} instead if you wish to detect such deadlocks. */ public synchronized void lock() { while (locked) { if (lockedBy==Thread.currentThread()) System.err.println("FATAL ERROR: org.rosuda.JRI.Mutex detected a deadlock! The application is likely to hang indefinitely!"); if (verbose) System.out.println("INFO: "+toString()+" is locked by "+lockedBy+", but "+Thread.currentThread()+" waits for release (no timeout)"); try { wait(); } catch (InterruptedException e) { if (verbose) System.out.println("INFO: "+toString()+" caught InterruptedException"); } } locked=true; lockedBy=Thread.currentThread(); if (verbose) System.out.println("INFO: "+toString()+" locked by "+lockedBy); } /** locks the mutex. If the mutex is already locked, waits until the mutex becomes free. Make sure the same thread doesn't issue two locks, because that will cause a deadlock. @param to timeout in milliseconds, see {@link #wait()}. @return true if the lock was successful, false if not */ public synchronized boolean lockWithTimeout(long to) { if (locked) { if (lockedBy==Thread.currentThread()) System.err.println("FATAL ERROR: org.rosuda.JRI.Mutex detected a deadlock! The application is likely to hang indefinitely!"); if (verbose) System.out.println("INFO: "+toString()+" is locked by "+lockedBy+", but "+Thread.currentThread()+" waits for release (timeout "+to+" ms)"); try { wait(to); } catch (InterruptedException e) { if (verbose) System.out.println("INFO: "+toString()+" caught InterruptedException"); } } if (!locked) { locked=true; lockedBy=Thread.currentThread(); if (verbose) System.out.println("INFO: "+toString()+" locked by "+lockedBy); return true; } if (verbose) System.out.println("INFO: "+toString()+" timeout, failed to obtain lock for "+Thread.currentThread()); return false; } /** attempts to lock the mutex and returns information about its success. @return 0 if the mutex was locked sucessfully
1 if the mutex is already locked by another thread
-1 is the mutex is already locked by the same thread (hence a call to {@link #lock()} would cause a deadlock). */ public synchronized int tryLock() { if (verbose) System.out.println("INFO: "+toString()+" tryLock by "+Thread.currentThread()); if (locked) return (lockedBy==Thread.currentThread())?-1:1; locked=true; lockedBy=Thread.currentThread(); if (verbose) System.out.println("INFO: "+toString()+" locked by "+lockedBy); return 0; } /** Locks the mutex. It works like {@link #lock()} except that it returns immediately if the same thread already owns the lock. It is safer to use this function rather than {@link #lock()}, because lock can possibly cause a deadlock which won't be resolved. @return true is the mutex was successfully locked, false if deadlock was detected (i.e. the same thread has already the lock). */ public synchronized boolean safeLock() { if (locked && lockedBy==Thread.currentThread()) { if (verbose) System.out.println("INFO: "+toString()+" unable to provide safe lock for "+Thread.currentThread()); return false; } lock(); return true; } /** Locks the mutex. It works like {@link #lockWithTimeout(long)} except that it returns immediately if the same thread already owns the lock. It is safer to use this function rather than {@link #lockWithTimeout(long)}, because lock can possibly cause a deadlock which won't be resolved. @return true is the mutex was successfully locked, false if deadlock was detected or timeout elapsed. */ public synchronized boolean safeLockWithTimeout(long to) { if (locked && lockedBy==Thread.currentThread()) { if (verbose) System.out.println("INFO: "+toString()+" unable to provide safe lock (deadlock detected) for "+Thread.currentThread()); return false; } return lockWithTimeout(to); } /** unlocks the mutex. It is possible to unlock an unlocked mutex, but a warning may be issued. */ public synchronized void unlock() { if (locked && lockedBy!=Thread.currentThread()) System.err.println("WARNING: org.rosuda.JRI.Mutex was unlocked by other thread than locked! This may soon lead to a crash..."); locked=false; if (verbose) System.out.println("INFO: "+toString()+" unlocked by "+Thread.currentThread()); // notify just 1 in case more of them are waiting notify(); } public String toString() { return super.toString()+"["+((locked)?"":"un")+"locked"+((!locked)?"":(", by "+((lockedBy==Thread.currentThread())?"current":"another")+" thread"))+"]"; } } rJava/jri/RConsoleOutputStream.java0000644000175100001440000000324715133274032017111 0ustar hornikusers// RConsoleOutputStream, part of Java/R Interface // // (C)Copyright 2007 Simon Urbanek // // For licensing terms see LICENSE in the root if the JRI distribution package org.rosuda.JRI; import java.io.OutputStream; import java.io.IOException; /** RConsoleOutputStream provides an OutputStream which causes its output to be written to the R console. It is a pseudo-stream as there is no real descriptor connected to the R console and thusly it is legal to have multiple console streams open. The synchonization happens at the RNI level.

Note that stdout/stderr are not connected to the R console by default, so one way of using this stream is to re-route Java output to R console:

System.setOut(new PrintStream(new RConsoleOutputStream(engine, 0)));
System.setErr(new PrintStream(new RConsoleOutputStream(engine, 1)));
@since JRI 0.4-0 */ public class RConsoleOutputStream extends OutputStream { Rengine eng; int oType; boolean isOpen; /** opens a new output stream to R console @param eng R engine @param oType output type (0=regular, 1=error/warning) */ public RConsoleOutputStream(Rengine eng, int oType) { this.eng = eng; this.oType = oType; isOpen = true; } public void write(byte[] b, int off, int len) throws IOException { if (!isOpen) throw new IOException("cannot write to a closed stream"); if (eng == null) throw new IOException("missing R engine"); String s = new String(b, off, len); eng.rniPrint(s, oType); } public void write(byte[] b) throws IOException { write(b, 0, b.length); } public void write(int b) throws IOException { write(new byte[] { (byte)(b&255) }); } public void close() throws IOException { isOpen=false; eng=null; } } rJava/jri/RVector.java0000644000175100001440000000253215133274032014350 0ustar hornikuserspackage org.rosuda.JRI; import java.util.Vector; import java.util.Enumeration; /** class encapsulating named generic vectors in R - do NOT use add/remove directly as names are not synchronized with the contents. The reason for this implementation is for historical compatibility and it may change in the future.

It is now used in REXP where Vector type was used previously for contents storage. @since JRI 0.3 */ public class RVector extends java.util.Vector { Vector names = null; public RVector() { super(); } /** replace the names vector - do NOT use directly! @param nam list of names */ public void setNames(String[] nam) { names=new Vector(nam.length); int i=0; while (inull if not found @param name key (name) @return contents or null if not found */ public REXP at(String name) { if (names==null) return null; int i=0; for (Enumeration e = names.elements() ; e.hasMoreElements() ;) { String n = (String)e.nextElement(); if (n.equals(name)) return (REXP) elementAt(i); i++; } return null; } public REXP at(int i) { return (REXP)elementAt(i); } } rJava/jri/LICENSE0000644000175100001440000000146215133274032013127 0ustar hornikusers JRI - Java/R Interface Copyright (C) 2004-2007 Simon Urbanek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library (LGPL.txt); if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA rJava/jri/RFactor.java0000644000175100001440000000564715133274032014336 0ustar hornikuserspackage org.rosuda.JRI; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; /** representation of a factor variable. In R there is no actual xpression type called "factor", instead it is coded as an int vector with a list attribute. The parser code of REXP converts such constructs directly into the RFactor objects and defines an own XT_FACTOR type @version $Id: RFactor.java 2909 2008-07-15 15:06:49Z urbanek $ */ public class RFactor extends Object { /** IDs (content: Integer) each entry corresponds to a case, ID specifies the category */ Vector id; /** values (content: String), ergo category names */ Vector val; /** create a new, empty factor var */ public RFactor() { id=new Vector(); val=new Vector(); } /** create a new factor variable, based on the supplied arrays. @param i array of IDs (0..v.length-1) @param v values - category names */ public RFactor(int[] i, String[] v) { this(i, v, 0); } /** create a new factor variable, based on the supplied arrays. @param i array of IDs (base .. v.length-1+base) @param v values - cotegory names @param base of the indexing */ RFactor(int[] i, String[] v, int base) { id=new Vector(); val=new Vector(); int j; if (i!=null && i.length>0) for(j=0;j0) for(j=0;j= id.size()) return null; int j = ((Integer)id.elementAt(i)).intValue(); /* due to the index shift NA (INT_MIN) will turn into INT_MAX if base is 1 */ return (j < 0 || j > 2147483640) ? null : ((String)val.elementAt(j)); } /** returns the number of caes */ public int size() { return id.size(); } /** displayable representation of the factor variable */ public String toString() { //return "{"+((val==null)?";":("levels="+val.size()+";"))+((id==null)?"":("cases="+id.size()))+"}"; StringBuffer sb=new StringBuffer("{levels=("); if (val==null) sb.append("null"); else for (int i=0;i0)?",\"":"\""); sb.append((String)val.elementAt(i)); sb.append("\""); }; sb.append("),ids=("); if (id==null) sb.append("null"); else for (int i=0;i0) sb.append(","); sb.append((Integer)id.elementAt(i)); }; sb.append(")}"); return sb.toString(); } } rJava/jri/package-info.java0000644000175100001440000000010115133274032015276 0ustar hornikusers/** * low level Java/R Interface */ package org.rosuda.JRI ; rJava/jri/configure.ac0000644000175100001440000003064215133274032014412 0ustar hornikusersAC_INIT([JRI],[0.3],[simon.urbanek@r-project.org]) AC_CONFIG_SRCDIR([src/jri.h]) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_AUX_DIR([tools]) AC_CANONICAL_BUILD AC_CANONICAL_HOST # find R home : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi # we attempt to use the same compiler as R did RBIN="${R_HOME}/bin/R" R_CC=`"${RBIN}" CMD config CC` ## CPP is now deprecated R_CPP="${R_CC} -E" R_CFLAGS=`"${RBIN}" CMD config CFLAGS` # find R_SHARE_DIR : ${R_SHARE_DIR=`"${RBIN}" CMD sh -c 'echo $R_SHARE_DIR'`} if test -z "${R_SHARE_DIR}"; then echo "could not determine R_SHARE_DIR" exit 1 fi # find R_DOC_DIR : ${R_DOC_DIR=`"${RBIN}" CMD sh -c 'echo $R_DOC_DIR'`} if test -z "${R_DOC_DIR}"; then echo "could not determine R_DOC_DIR" exit 1 fi # find R_INCLUDE_DIR : ${R_INCLUDE_DIR=`"${RBIN}" CMD sh -c 'echo $R_INCLUDE_DIR'`} if test -z "${R_INCLUDE_DIR}"; then echo "could not determine R_INCLUDE_DIR" exit 1 fi # if user did not specify CC then we use R's settings. # if CC was set then user is responsible for CFLAGS as well! if test -z "${CC}"; then CC="${R_CC}" CPP="${R_CPP}" CFLAGS="${R_CFLAGS}" fi RINC=`"${RBIN}" CMD config --cppflags` RLD=`"${RBIN}" CMD config --ldflags` if test -z "$RLD"; then AC_MSG_ERROR([R was not compiled with --enable-R-shlib *** You must have libR.so or equivalent in order to use JRI *** ]) fi AC_SUBST(R_HOME) AC_SUBST(R_SHARE_DIR) AC_SUBST(R_DOC_DIR) AC_SUBST(R_INCLUDE_DIR) AC_LANG(C) AC_PROG_CC ## we need HAVE_..._H for R-ext/eventloop.h which requires ## defines from R's config.h which are not shipped with R AC_CHECK_HEADERS([sys/time.h sys/types.h sys/select.h]) ## RUN_JAVA(variable for the result, parameters) ## ---------- ## runs the java interpreter ${JAVA_PROG} with specified parameters and ## saves the output to the supplied variable. The exit value is ignored. AC_DEFUN([RUN_JAVA], [ acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java $2" >&AS_MESSAGE_LOG_FD else echo "$as_me:$LINENO: running ${JAVA_PROG} $2" >&AS_MESSAGE_LOG_FD acx_java_result=`${JAVA_PROG} $2 2>&AS_MESSAGE_LOG_FD` echo "$as_me:$LINENO: output: '$acx_java_result'" >&AS_MESSAGE_LOG_FD fi $1=$acx_java_result ]) if test -n "${CONFIGURED}"; then ## re-map variables that don't match JAVA_PROG="${JAVA}" JAVA_INC="${JAVA_CPPFLAGS}" JAVA_LD_PATH="${JAVA_LD_LIBRARY_PATH}" else ## find java compiler binaries if test -z "${JAVA_HOME}" ; then JAVA_PATH=${PATH} else JAVA_PATH=${JAVA_HOME}:${JAVA_HOME}/jre/bin:${JAVA_HOME}/bin:${JAVA_HOME}/../bin:${PATH} fi ## if 'java' is not on the PATH or JAVA_HOME, add some guesses as of ## where java could live JAVA_PATH=${JAVA_PATH}:/usr/java/bin:/usr/jdk/bin:/usr/lib/java/bin:/usr/lib/jdk/bin:/usr/local/java/bin:/usr/local/jdk/bin:/usr/local/lib/java/bin:/usr/local/lib/jdk/bin AC_PATH_PROGS(JAVA_PROG,java,,${JAVA_PATH}) ## FIXME: we may want to check for jikes, kaffe and others... AC_PATH_PROGS(JAVAC,javac,,${JAVA_PATH}) AC_PATH_PROGS(JAVAH,javah,,${JAVA_PATH}) AC_PATH_PROGS(JAR,jar,,${JAVA_PATH}) fi AC_MSG_CHECKING([Java version]) JVER=`"$JAVA" -version 2>&1 | sed -n 's:^.* version "::p' | sed 's:".*::'` AC_MSG_RESULT([$JVER]) if test -z "$JVER"; then AC_MSG_WARN([**** Cannot detect Java version - the java -version output is unknown! ****]) else AC_MSG_CHECKING([Java compatibility version (integer)]) ## .. Oracle decided to completely screw up Java version so have to try extract something meaningful .. if echo $JVER | grep '^1\.' >/dev/null; then ## old style 1.X JMVER=`echo $JVER | sed 's:^..::' | sed 's:\..*::'` else ## new stype omitting the major version JMVER=`echo $JVER | sed 's:\..*::'` fi ## strip -.* for versions like 13-ea JMVER=`echo $JMVER | sed 's:-.*::'` AC_MSG_RESULT([$JMVER]) fi AC_MSG_CHECKING([whether $JAVAH actually works]) if "$JAVAH" -version >/dev/null 2>&1; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) JAVAH= fi have_all_java=yes ## Java 1.10 has no javah anymore -- it uses javac -h . instaead if test -z "$JAVAH"; then AC_MSG_CHECKING([whether javah was replaced by javac -h]) if test "$JMVER" -gt 9; then AC_MSG_RESULT([yes]) ## create headres in the compile step instead JFLAGS=' -h .' else AC_MSG_RESULT([no]) have_all_java=no; fi fi if test -z "$JAVA_PROG"; then have_all_java=no; fi if test -z "$JAVAC"; then have_all_java=no; fi if test -z "$JAR"; then have_all_java=no; fi if test ${have_all_java} = no; then AC_MSG_ERROR([one or more Java tools are missing. *** JDK is incomplete! Please make sure you have a complete JDK. JRE is *not* sufficient.]) fi AC_MSG_CHECKING([for target flags]) ## set JFLAGS target -- depends on the JDK version if echo $JFLAGS | grep '[[-]]target' >/dev/null; then AC_MSG_RESULT([user-supplied: $JFLAGS]) else if test "$JMVER" -lt 9; then JFLAGS="$JFLAGS -target 1.4 -source 1.4" else if test "$JMVER" -lt 12; then JFLAGS="$JFLAGS -target 1.6 -source 1.6" else JFLAGS="$JFLAGS -target 1.8 -source 1.8" fi fi AC_MSG_RESULT([$JFLAGS]) fi ## this is where our test-class lives getsp_cp=tools AC_MSG_CHECKING([whether Java interpreter works]) acx_java_works=no if test -n "${JAVA_PROG}" ; then RUN_JAVA(acx_jc_result,[-classpath ${getsp_cp} getsp -test]) if test "${acx_jc_result}" = "Test1234OK"; then acx_java_works=yes fi acx_jc_result= fi if test "x`uname -s 2>/dev/null`" = xDarwin; then ## we need to pull that out of R in case re-export fails (which is does on 10.11) DYLD_FALLBACK_LIBRARY_PATH=`"${RBIN}" --slave --vanilla -e 'cat(Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH"))'` export DYLD_FALLBACK_LIBRARY_PATH fi if test -z "${CONFIGURED}"; then if test ${acx_java_works} = yes; then AC_MSG_RESULT([yes]) AC_MSG_CHECKING([for Java environment]) ## retrieve JAVA_HOME from Java itself if not set if test -z "${JAVA_HOME}" ; then RUN_JAVA(JAVA_HOME,[-classpath ${getsp_cp} getsp java.home]) fi ## the availability of JAVA_HOME will tell us whether it's supported if test -z "${JAVA_HOME}" ; then if test x$acx_java_env_msg != xyes; then AC_MSG_RESULT([not found]) fi else AC_MSG_RESULT([in ${JAVA_HOME}]) case "${host_os}" in darwin*) if [ -z "${JAVA_LIBS}" ]; then JAVA_LIBS="-framework JavaVM" JAVA_LD_PATH= fi ;; *) RUN_JAVA(JAVA_LIBS, [-classpath ${getsp_cp} getsp -libs]) JAVA_LIBS="${JAVA_LIBS} -ljvm" RUN_JAVA(JAVA_LD_PATH, [-classpath ${getsp_cp} getsp java.library.path]) ;; esac ## note that we actually don't test JAVA_LIBS - we hope that the detection ## was correct. We should also test the functionality for javac. have_java=yes fi else AC_MSG_RESULT([no]) AC_MSG_ERROR([Java not found. Please install JDK 1.4 or later, make sure that the binaries are on the PATH and re-try. If that doesn't work, set JAVA_HOME correspondingly.]) fi AC_CHECK_FILE(${JAVA_HOME}/include/jni.h, [JNI_H="${JAVA_HOME}/include"], [AC_CHECK_FILE(${JAVA_HOME}/jni.h, [JNI_H="${JAVA_HOME}"], [AC_CHECK_FILE(${JAVA_HOME}/../include/jni.h, [JNI_H="${JAVA_HOME}/../include"], [AC_MSG_ERROR([Cannot compile JNI programs, check jri/config.log for details. Please make sure you have a proper JDK installed. Use --disable-jri when you install rJava and don't need JRI. ]) ]) ]) ]) JAVA_INC="-I${JNI_H}" : ${JAVA_CFLAGS=-D_REENTRANT} # Sun's JDK needs jni_md.h in in addition to jni.h and unfortunately it's stored somewhere else ... # this should be become more general at some point - so far we're checking linux and solaris only # (well, those are presumably the only platforms supported by Sun's JDK and others don't need this # at least as of now - 01/2004) jac_found_md=no for mddir in . linux solaris ppc irix alpha aix hp-ux genunix cygwin win32 freebsd; do AC_CHECK_FILE(${JNI_H}/$mddir/jni_md.h,[JAVA_INC="${JAVA_INC} -I${JNI_H}/$mddir" jac_found_md=yes]) if test ${jac_found_md} = yes; then break; fi done fi ## the configure variables may contain $(JAVA_HOME) which for testing needs to be replaced by the real path if test `echo foo | sed -e 's:foo:bar:'` = bar; then JAVA_INC0=`echo ${JAVA_INC} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LD_PATH0=`echo ${JAVA_LD_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` else AC_MSG_WARN([sed is not working properly - the configuration may fail]) JAVA_INC0="${JAVA_INC}" JAVA_LIBS0="${JAVA_LIBS}" JAVA_LD_PATH0="${JAVA_LD_PATH}" fi LIBS="${LIBS} ${JAVA_LIBS0}" CFLAGS="${CFLAGS} ${JAVA_CFLAGS} ${JAVA_INC0}" AC_MSG_CHECKING([whether JNI programs can be compiled]) AC_LINK_IFELSE([AC_LANG_SOURCE([[ #include int main(void) { jobject o; return 0; } ]])],[AC_MSG_RESULT(yes)], [AC_MSG_ERROR([Cannot compile a simple JNI program. See config.log for details.])]) LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${JAVA_LD_PATH0} export LD_LIBRARY_PATH AC_MSG_CHECKING([whether JNI programs can be run]) AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include int main(void) { jobject o; return 0; } ]])],[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) AC_MSG_ERROR([Cannot run a simple JNI program - probably your jvm library is in non-standard location or JVM is unsupported. See config.log for details.])]) AC_MSG_CHECKING([JNI data types]) AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include int main(void) { return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1; } ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.])],[]) JNIPREFIX=lib CPICF=`"${RBIN}" CMD config CPICFLAGS` JNISO=.so JNILD=`"${RBIN}" CMD config SHLIB_LDFLAGS`" ${JAVA_LIBS}" # we need to adjust a few things according to OS .. case "${host_os}" in darwin*) JNISO=.jnilib JNILD="-dynamiclib $JNILD" CPICF=-fno-common if test -e "${R_HOME}/lib/i386" -a -e "${R_HOME}/lib/ppc" -a -e "${R_HOME}/lib/libR.dylib"; then # we have an universal framework, so we will use stubs and fat lib RLD="-framework R" RINC="-I${R_HOME}/include" # we can even cross-compile, maybe if test -z "${FORCE_NATIVE}"; then # find out the archs of JavaVM and build all of them jarchs=`file -L /System/Library/Frameworks/JavaVM.framework/JavaVM 2>/dev/null | sed -n 's/.*for architecture //p' | sed 's:).*::' | sed 's:ppc7.*:ppc:' | tr '\n' ' '` jrarchs='' ## ok, we have Java archs, but R may not be available for all of those for a in ${jarchs}; do if test -e "${R_HOME}/lib/$a"; then jrarchs="${jrarchs} $a"; fi done ## if have have more than one arch, display info and add -arch flags if test -n "${jrarchs}"; then echo "*** building fat JNI with gcc for architectures: ${jrarchs} ***" echo "*** use FORCE_NATIVE=yes to avoid this and use R settings ***" CFLAGS="" LDFLAGS="" CC="gcc" for a in ${jrarchs}; do CC="${CC} -arch $a"; done fi fi fi ;; *) ;; esac origCFLAGS=$CFLAGS CFLAGS="${CFLAGS} ${R_CFLAGS} ${RINC}" AC_MSG_CHECKING([whether Rinterface.h exports R_CStackXXX variables]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #define CSTACK_DEFNS #include #include int main(void) { return R_CStackLimit?0:1; } ])],[AC_MSG_RESULT(yes) DEFFLAGS="${DEFFLAGS} -DRIF_HAS_CSTACK"], [AC_MSG_RESULT(no)]) AC_MSG_CHECKING([whether Rinterface.h exports R_SignalHandlers]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include #include int main(void) { return R_SignalHandlers; } ])],[AC_MSG_RESULT(yes) DEFFLAGS="${DEFFLAGS} -DRIF_HAS_RSIGHAND"], [AC_MSG_RESULT(no)]) CFLAGS=${origCFLAGS} AC_SUBST(JAVA_HOME) AC_SUBST(JAVA_PROG) AC_SUBST(JAVA_LD_PATH) AC_SUBST(JAVA_LIBS) AC_SUBST(JAVA_INC) AC_SUBST(JAVA_CFLAGS) AC_SUBST(JAVAC) AC_SUBST(JAVAH) AC_SUBST(JFLAGS) AC_SUBST(JAR) AC_SUBST(JNILD) AC_SUBST(JNISO) AC_SUBST(JNIPREFIX) AC_SUBST(CPICF) AC_SUBST(CFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(RINC) AC_SUBST(RLD) AC_SUBST(CC) AC_SUBST(DEFFLAGS) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([run], [chmod +x run]) AC_OUTPUT rJava/jri/tools/0000755000175100001440000000000015133274032013257 5ustar hornikusersrJava/jri/tools/getsp.class0000644000175100001440000000317315133274032015434 0ustar hornikusersÊþº¾.h )* +, -./ 01234 -56 +7 +8 +9:; ) < =>? +@AB +C +D EFGHIJK()VCodeLineNumberTablemain([Ljava/lang/String;)V SourceFile getsp.java !"-testL MNO PQ Test1234OKR ST-libs-Ljava.library.path UVpath.separator WX YZ [\.java/lang/StringBuffer ]^ _` -minver ab java.version1. cd [ef gNjava/lang/Exceptionyesnogetspjava/lang/Objectjava/lang/String compareTo(Ljava/lang/String;)Ijava/lang/SystemoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)V getProperty&(Ljava/lang/String;)Ljava/lang/String;length()IcharAt(I)C substring(II)Ljava/lang/String;append,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString()Ljava/lang/String;equals(Ljava/lang/Object;)Z startsWith(Ljava/lang/String;)Z(I)Ljava/lang/String;java/lang/IntegerparseInt! !"#*·±$ %&#< |*Æz*¾žu*2¶š²¶§_*2¶šÂL*¾¤*2L ¸ M>6: ¸ ::6ƶ ž ¶ 6,¶ 6£kŸ ,¶  U,¶: `6 ¶™=Ç»Y·+¶ ¶¶§ »Y·¶¶+¶ ¶¶:„§ÿ•Æ ²¶§•*2¶™~<¸ M,¶™ ,¶M>,¶ ¢,¶ 0¡,¶ 9¢ „§ÿá,¶M*¾¤*2¸6,¸6¡§<§N²™§¶§²*2¸ ¶± WZ$¦) *- 7 = B ELPekqŠ™ÓÙæéôöü ! # $)%/&6'<(D)J*W-Z,[.l/o0{2'(rJava/jri/tools/mkinstalldirs0000755000175100001440000000667215133274032016100 0ustar hornikusers#! /bin/sh # mkinstalldirs --- make directory hierarchy scriptversion=2020-07-26.22; # UTC # Original author: Noah Friedman # Created: 1993-05-16 # Public domain. # # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' IFS=" "" $nl" errstatus=0 dirmode= usage="\ Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... Create each directory DIR (with mode MODE, if specified), including all leading file name components. Report bugs to ." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" exit $? ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --version) echo "$0 $scriptversion" exit $? ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and # mkdir -p a/c at the same time, both will detect that a is missing, # one will create a, then the other will try to create a and die with # a "File exists" error. This is a problem when calling mkinstalldirs # from a parallel make. We use --version in the probe to restrict # ourselves to GNU mkdir, which is thread-safe. case $dirmode in '') if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" else # On NextStep and OpenStep, the 'mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because '.' already # exists. test -d ./-p && rmdir ./-p test -d ./--version && rmdir ./--version fi ;; *) if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "umask 22" umask 22 echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" else # Clean up after NextStep and OpenStep mkdir. for d in ./-m ./-p ./--version "./$dirmode"; do test -d $d && rmdir $d done fi ;; esac echo "umask 22" umask 22 for file do case $file in /*) pathcomp=/ ;; *) pathcomp= ;; esac oIFS=$IFS IFS=/ set fnord $file shift IFS=$oIFS for d do test "x$d" = x && continue pathcomp=$pathcomp$d case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp=$pathcomp/ done if test ! -z "$dirmode"; then echo "chmod $dirmode $file" chmod "$dirmode" "$file" || errstatus=$? fi done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: rJava/jri/tools/install-sh0000755000175100001440000003577615133274032015305 0ustar hornikusers#!/bin/sh # install - install a program, script, or datafile scriptversion=2020-11-14.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 # Create dirs (including intermediate dirs) using mode 755. # This is like GNU 'install' as of coreutils 8.32 (2020). mkdir_umask=22 backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -p pass -p to $cpprog. -s $stripprog installed files. -S SUFFIX attempt to back up existing files, with suffix SUFFIX. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG By default, rm is invoked with -f; when overridden with RMPROG, it's up to you to specify -f if you want it. If -S is not specified, no backups are attempted. Email bug reports to bug-automake@gnu.org. Automake home page: https://www.gnu.org/software/automake/ " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -p) cpprog="$cpprog -p";; -s) stripcmd=$stripprog;; -S) backupsuffix="$2" shift;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? # Don't chown directories that already exist. if test $dstdir_status = 0; then chowncmd="" fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dstbase=`basename "$src"` case $dst in */) dst=$dst$dstbase;; *) dst=$dst/$dstbase;; esac dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi case $dstdir in */) dstdirslash=$dstdir;; *) dstdirslash=$dstdir/;; esac obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false # The $RANDOM variable is not portable (e.g., dash). Use it # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap ' ret=$? rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null exit $ret ' 0 # Because "mkdir -p" follows existing symlinks and we likely work # directly in world-writeable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p'. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=${dstdirslash}_inst.$$_ rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && { test -z "$stripcmd" || { # Create $dsttmp read-write so that cp doesn't create it read-only, # which would cause strip to fail. if test -z "$doit"; then : >"$dsttmp" # No need to fork-exec 'touch'. else $doit touch "$dsttmp" fi } } && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # If $backupsuffix is set, and the file being installed # already exists, attempt a backup. Don't worry if it fails, # e.g., if mv doesn't support -f. if test -n "$backupsuffix" && test -f "$dst"; then $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null fi # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: rJava/jri/tools/config.guess0000755000175100001440000013761315133274032015612 0ustar hornikusers#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2020 Free Software Foundation, Inc. timestamp='2020-11-07' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . me=$(echo "$0" | sed -e 's,.*/,,') usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. tmp= # shellcheck disable=SC2172 trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 set_cc_for_build() { # prevent multiple calls if $tmp is already set test "$tmp" && return 0 : "${TMPDIR=/tmp}" # shellcheck disable=SC2039 { tmp=$( (umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null) && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } dummy=$tmp/dummy case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ,,) echo "int x;" > "$dummy.c" for driver in cc gcc c89 c99 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$driver" break fi done if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac } # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=$( (uname -m) 2>/dev/null) || UNAME_MACHINE=unknown UNAME_RELEASE=$( (uname -r) 2>/dev/null) || UNAME_RELEASE=unknown UNAME_SYSTEM=$( (uname -s) 2>/dev/null) || UNAME_SYSTEM=unknown UNAME_VERSION=$( (uname -v) 2>/dev/null) || UNAME_VERSION=unknown case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu set_cc_for_build cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else #include #ifdef __DEFINED_va_list LIBC=musl #else LIBC=gnu #endif #endif EOF eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g')" ;; esac # Note: order is significant - the case branches are not exclusive. case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \ "/sbin/$sysctl" 2>/dev/null || \ "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)) case "$UNAME_MACHINE_ARCH" in aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=$(echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,') endian=$(echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p') machine="${arch}${endian}"-unknown ;; *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=$(echo "$UNAME_MACHINE_ARCH" | sed -e "$expr") ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) release=$(echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2) ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=$(arch | sed 's/Bitrig.//') echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=$(arch | sed 's/OpenBSD.//') echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=$(arch | sed 's/^.*BSD\.//') echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" exit ;; *:MidnightBSD:*:*) echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; *:OS108:*:*) echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) echo "$UNAME_MACHINE"-unknown-sortix exit ;; *:Twizzler:*:*) echo "$UNAME_MACHINE"-unknown-twizzler exit ;; *:Redox:*:*) echo "$UNAME_MACHINE"-unknown-redox exit ;; mips:OSF1:*.*) echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $3}') ;; *5.*) UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $4}') ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=$(/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1) case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo "$UNAME_MACHINE"-dec-osf"$(echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "$( (/bin/universe) 2>/dev/null)" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case $(/usr/bin/uname -p) in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo "$UNAME_MACHINE"-ibm-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')" exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi echo "$SUN_ARCH"-pc-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" exit ;; sun4*:SunOS:*:*) case "$(/usr/bin/arch -k)" in Series*|S4*) UNAME_RELEASE=$(uname -v) ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/')" exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=$( (sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null) test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "$(/bin/arch)" in sun3) echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=$(echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p') && SYSTEM_NAME=$("$dummy" "$dummyarg") && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=$(/usr/bin/uname -p) if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ test "$TARGET_BINARY_INTERFACE"x = x then echo m88k-dg-dgux"$UNAME_RELEASE" else echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/g')" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'$(uname -s)'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if test -x /usr/bin/oslevel ; then IBM_REV=$(/usr/bin/oslevel) else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=$(/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }') if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if test -x /usr/bin/lslpp ; then IBM_REV=$(/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/) else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') case "$UNAME_MACHINE" in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if test -x /usr/bin/getconf; then sc_cpu_version=$(/usr/bin/getconf SC_CPU_VERSION 2>/dev/null) sc_kernel_bits=$(/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null) case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if test "$HP_ARCH" = ""; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=$("$dummy") test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if test "$HP_ARCH" = hppa2.0w then set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if test -x /usr/sbin/sysversion ; then echo "$UNAME_MACHINE"-unknown-osf1mk else echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=$(uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz) FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///') FUJITSU_REL=$(echo "$UNAME_RELEASE" | sed -e 's/ /_/') echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///') FUJITSU_REL=$(echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/') echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; arm:FreeBSD:*:*) UNAME_PROCESSOR=$(uname -p) set_cc_for_build if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabi else echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabihf fi exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=$(/usr/bin/uname -p) case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac echo "$UNAME_PROCESSOR"-unknown-freebsd"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" exit ;; i*:CYGWIN*:*) echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) case "$UNAME_MACHINE" in x86) echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; i*:UWIN*:*) echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" exit ;; *:GNU:*:*) # the GNU system echo "$(echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,')-unknown-$LIBC$(echo "$UNAME_RELEASE"|sed -e 's,/.*$,,')" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo "$UNAME_MACHINE-unknown-$(echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]")$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')-$LIBC" exit ;; *:Minix:*:*) echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case $(sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null) in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) set_cc_for_build IS_GLIBC=0 test x"${LIBC}" = xgnu && IS_GLIBC=1 sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef mips #undef mipsel #undef mips64 #undef mips64el #if ${IS_GLIBC} && defined(_ABI64) LIBCABI=gnuabi64 #else #if ${IS_GLIBC} && defined(_ABIN32) LIBCABI=gnuabin32 #else LIBCABI=${LIBC} #endif #endif #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa64r6 #else #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa32r6 #else #if defined(__mips64) CPU=mips64 #else CPU=mips #endif #endif #endif #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) MIPS_ENDIAN= #else MIPS_ENDIAN= #endif #endif EOF eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI')" test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case $(grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2) in PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) set_cc_for_build LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_X32 >/dev/null then LIBCABI="$LIBC"x32 fi fi echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" exit ;; xtensa*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; i*86:*:4.*:*) UNAME_REL=$(echo "$UNAME_RELEASE" | sed 's/\/MP$//') if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case $(/bin/uname -X | grep "^Machine") in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=$(sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=$( (/bin/uname -X|grep Release|sed -e 's/.*= //')) (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=$( (uname -p) 2>/dev/null) echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if test -d /usr/nec; then echo mips-nec-sysv"$UNAME_RELEASE" else echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; arm64:Darwin:*:*) echo aarch64-apple-darwin"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=$(uname -p) case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac if command -v xcode-select > /dev/null 2> /dev/null && \ ! xcode-select --print-path > /dev/null 2> /dev/null ; then # Avoid executing cc if there is no toolchain installed as # cc will be a stub that puts up a graphical alert # prompting the user to install developer tools. CC_FOR_BUILD=no_compiler_found else set_cc_for_build fi if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then # uname -m returns i386 or x86_64 UNAME_PROCESSOR=$UNAME_MACHINE fi echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=$(uname -p) if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk"$UNAME_RELEASE" exit ;; NSV-*:NONSTOP_KERNEL:*:*) echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. # shellcheck disable=SC2154 if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) echo "$UNAME_MACHINE"-unknown-dragonfly"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" exit ;; *:*VMS:*:*) UNAME_MACHINE=$( (uname -p) 2>/dev/null) case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo "$UNAME_MACHINE"-pc-skyos"$(echo "$UNAME_RELEASE" | sed -e 's/ .*$//')" exit ;; i*86:rdos:*:*) echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; *:Unleashed:*:*) echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" exit ;; esac # No uname command or uname output not recognized. set_cc_for_build cat > "$dummy.c" < #include #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #include #if defined(_SIZE_T_) || defined(SIGLOST) #include #endif #endif #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=$( (hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null); if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) #include #if defined (BSD) #if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); #else #if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); #else printf ("vax-dec-bsd\n"); exit (0); #endif #endif #else printf ("vax-dec-bsd\n"); exit (0); #endif #else #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname un; uname (&un); printf ("vax-dec-ultrix%s\n", un.release); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname *un; uname (&un); printf ("mips-dec-ultrix%s\n", un.release); exit (0); #else printf ("mips-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=$($dummy) && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } echo "$0: unable to guess system type" >&2 case "$UNAME_MACHINE:$UNAME_SYSTEM" in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 <&2 </dev/null || echo unknown) uname -r = $( (uname -r) 2>/dev/null || echo unknown) uname -s = $( (uname -s) 2>/dev/null || echo unknown) uname -v = $( (uname -v) 2>/dev/null || echo unknown) /usr/bin/uname -p = $( (/usr/bin/uname -p) 2>/dev/null) /bin/uname -X = $( (/bin/uname -X) 2>/dev/null) hostinfo = $( (hostinfo) 2>/dev/null) /bin/universe = $( (/bin/universe) 2>/dev/null) /usr/bin/arch -k = $( (/usr/bin/arch -k) 2>/dev/null) /bin/arch = $( (/bin/arch) 2>/dev/null) /usr/bin/oslevel = $( (/usr/bin/oslevel) 2>/dev/null) /usr/convex/getsysinfo = $( (/usr/convex/getsysinfo) 2>/dev/null) UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF fi exit 1 # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: rJava/jri/tools/config.sub0000755000175100001440000010264415133274032015251 0ustar hornikusers#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2020 Free Software Foundation, Inc. timestamp='2020-11-07' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=$(echo "$0" | sed -e 's,.*/,,') usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. echo "$1" exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Split fields of configuration type # shellcheck disable=SC2162 IFS="-" read field1 field2 field3 field4 <&2 exit 1 ;; *-*-*-*) basic_machine=$field1-$field2 basic_os=$field3-$field4 ;; *-*-*) # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two # parts maybe_os=$field2-$field3 case $maybe_os in nto-qnx* | linux-* | uclinux-uclibc* \ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ | storm-chaos* | os2-emx* | rtmk-nova*) basic_machine=$field1 basic_os=$maybe_os ;; android-linux) basic_machine=$field1-unknown basic_os=linux-android ;; *) basic_machine=$field1-$field2 basic_os=$field3 ;; esac ;; *-*) # A lone config we happen to match not fitting any pattern case $field1-$field2 in decstation-3100) basic_machine=mips-dec basic_os= ;; *-*) # Second component is usually, but not always the OS case $field2 in # Prevent following clause from handling this valid os sun*os*) basic_machine=$field1 basic_os=$field2 ;; # Manufacturers dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ | unicom* | ibm* | next | hp | isi* | apollo | altos* \ | convergent* | ncr* | news | 32* | 3600* | 3100* \ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ | ultra | tti* | harris | dolphin | highlevel | gould \ | cbm | ns | masscomp | apple | axis | knuth | cray \ | microblaze* | sim | cisco \ | oki | wec | wrs | winbond) basic_machine=$field1-$field2 basic_os= ;; *) basic_machine=$field1 basic_os=$field2 ;; esac ;; esac ;; *) # Convert single-component short-hands not valid as part of # multi-component configurations. case $field1 in 386bsd) basic_machine=i386-pc basic_os=bsd ;; a29khif) basic_machine=a29k-amd basic_os=udi ;; adobe68k) basic_machine=m68010-adobe basic_os=scout ;; alliant) basic_machine=fx80-alliant basic_os= ;; altos | altos3068) basic_machine=m68k-altos basic_os= ;; am29k) basic_machine=a29k-none basic_os=bsd ;; amdahl) basic_machine=580-amdahl basic_os=sysv ;; amiga) basic_machine=m68k-unknown basic_os= ;; amigaos | amigados) basic_machine=m68k-unknown basic_os=amigaos ;; amigaunix | amix) basic_machine=m68k-unknown basic_os=sysv4 ;; apollo68) basic_machine=m68k-apollo basic_os=sysv ;; apollo68bsd) basic_machine=m68k-apollo basic_os=bsd ;; aros) basic_machine=i386-pc basic_os=aros ;; aux) basic_machine=m68k-apple basic_os=aux ;; balance) basic_machine=ns32k-sequent basic_os=dynix ;; blackfin) basic_machine=bfin-unknown basic_os=linux ;; cegcc) basic_machine=arm-unknown basic_os=cegcc ;; convex-c1) basic_machine=c1-convex basic_os=bsd ;; convex-c2) basic_machine=c2-convex basic_os=bsd ;; convex-c32) basic_machine=c32-convex basic_os=bsd ;; convex-c34) basic_machine=c34-convex basic_os=bsd ;; convex-c38) basic_machine=c38-convex basic_os=bsd ;; cray) basic_machine=j90-cray basic_os=unicos ;; crds | unos) basic_machine=m68k-crds basic_os= ;; da30) basic_machine=m68k-da30 basic_os= ;; decstation | pmax | pmin | dec3100 | decstatn) basic_machine=mips-dec basic_os= ;; delta88) basic_machine=m88k-motorola basic_os=sysv3 ;; dicos) basic_machine=i686-pc basic_os=dicos ;; djgpp) basic_machine=i586-pc basic_os=msdosdjgpp ;; ebmon29k) basic_machine=a29k-amd basic_os=ebmon ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson basic_os=ose ;; gmicro) basic_machine=tron-gmicro basic_os=sysv ;; go32) basic_machine=i386-pc basic_os=go32 ;; h8300hms) basic_machine=h8300-hitachi basic_os=hms ;; h8300xray) basic_machine=h8300-hitachi basic_os=xray ;; h8500hms) basic_machine=h8500-hitachi basic_os=hms ;; harris) basic_machine=m88k-harris basic_os=sysv3 ;; hp300 | hp300hpux) basic_machine=m68k-hp basic_os=hpux ;; hp300bsd) basic_machine=m68k-hp basic_os=bsd ;; hppaosf) basic_machine=hppa1.1-hp basic_os=osf ;; hppro) basic_machine=hppa1.1-hp basic_os=proelf ;; i386mach) basic_machine=i386-mach basic_os=mach ;; isi68 | isi) basic_machine=m68k-isi basic_os=sysv ;; m68knommu) basic_machine=m68k-unknown basic_os=linux ;; magnum | m3230) basic_machine=mips-mips basic_os=sysv ;; merlin) basic_machine=ns32k-utek basic_os=sysv ;; mingw64) basic_machine=x86_64-pc basic_os=mingw64 ;; mingw32) basic_machine=i686-pc basic_os=mingw32 ;; mingw32ce) basic_machine=arm-unknown basic_os=mingw32ce ;; monitor) basic_machine=m68k-rom68k basic_os=coff ;; morphos) basic_machine=powerpc-unknown basic_os=morphos ;; moxiebox) basic_machine=moxie-unknown basic_os=moxiebox ;; msdos) basic_machine=i386-pc basic_os=msdos ;; msys) basic_machine=i686-pc basic_os=msys ;; mvs) basic_machine=i370-ibm basic_os=mvs ;; nacl) basic_machine=le32-unknown basic_os=nacl ;; ncr3000) basic_machine=i486-ncr basic_os=sysv4 ;; netbsd386) basic_machine=i386-pc basic_os=netbsd ;; netwinder) basic_machine=armv4l-rebel basic_os=linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony basic_os=newsos ;; news1000) basic_machine=m68030-sony basic_os=newsos ;; necv70) basic_machine=v70-nec basic_os=sysv ;; nh3000) basic_machine=m68k-harris basic_os=cxux ;; nh[45]000) basic_machine=m88k-harris basic_os=cxux ;; nindy960) basic_machine=i960-intel basic_os=nindy ;; mon960) basic_machine=i960-intel basic_os=mon960 ;; nonstopux) basic_machine=mips-compaq basic_os=nonstopux ;; os400) basic_machine=powerpc-ibm basic_os=os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson basic_os=ose ;; os68k) basic_machine=m68k-none basic_os=os68k ;; paragon) basic_machine=i860-intel basic_os=osf ;; parisc) basic_machine=hppa-unknown basic_os=linux ;; psp) basic_machine=mipsallegrexel-sony basic_os=psp ;; pw32) basic_machine=i586-unknown basic_os=pw32 ;; rdos | rdos64) basic_machine=x86_64-pc basic_os=rdos ;; rdos32) basic_machine=i386-pc basic_os=rdos ;; rom68k) basic_machine=m68k-rom68k basic_os=coff ;; sa29200) basic_machine=a29k-amd basic_os=udi ;; sei) basic_machine=mips-sei basic_os=seiux ;; sequent) basic_machine=i386-sequent basic_os= ;; sps7) basic_machine=m68k-bull basic_os=sysv2 ;; st2000) basic_machine=m68k-tandem basic_os= ;; stratus) basic_machine=i860-stratus basic_os=sysv4 ;; sun2) basic_machine=m68000-sun basic_os= ;; sun2os3) basic_machine=m68000-sun basic_os=sunos3 ;; sun2os4) basic_machine=m68000-sun basic_os=sunos4 ;; sun3) basic_machine=m68k-sun basic_os= ;; sun3os3) basic_machine=m68k-sun basic_os=sunos3 ;; sun3os4) basic_machine=m68k-sun basic_os=sunos4 ;; sun4) basic_machine=sparc-sun basic_os= ;; sun4os3) basic_machine=sparc-sun basic_os=sunos3 ;; sun4os4) basic_machine=sparc-sun basic_os=sunos4 ;; sun4sol2) basic_machine=sparc-sun basic_os=solaris2 ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun basic_os= ;; sv1) basic_machine=sv1-cray basic_os=unicos ;; symmetry) basic_machine=i386-sequent basic_os=dynix ;; t3e) basic_machine=alphaev5-cray basic_os=unicos ;; t90) basic_machine=t90-cray basic_os=unicos ;; toad1) basic_machine=pdp10-xkl basic_os=tops20 ;; tpf) basic_machine=s390x-ibm basic_os=tpf ;; udi29k) basic_machine=a29k-amd basic_os=udi ;; ultra3) basic_machine=a29k-nyu basic_os=sym1 ;; v810 | necv810) basic_machine=v810-nec basic_os=none ;; vaxv) basic_machine=vax-dec basic_os=sysv ;; vms) basic_machine=vax-dec basic_os=vms ;; vsta) basic_machine=i386-pc basic_os=vsta ;; vxworks960) basic_machine=i960-wrs basic_os=vxworks ;; vxworks68) basic_machine=m68k-wrs basic_os=vxworks ;; vxworks29k) basic_machine=a29k-wrs basic_os=vxworks ;; xbox) basic_machine=i686-pc basic_os=mingw32 ;; ymp) basic_machine=ymp-cray basic_os=unicos ;; *) basic_machine=$1 basic_os= ;; esac ;; esac # Decode 1-component or ad-hoc basic machines case $basic_machine in # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) cpu=hppa1.1 vendor=winbond ;; op50n) cpu=hppa1.1 vendor=oki ;; op60c) cpu=hppa1.1 vendor=oki ;; ibm*) cpu=i370 vendor=ibm ;; orion105) cpu=clipper vendor=highlevel ;; mac | mpw | mac-mpw) cpu=m68k vendor=apple ;; pmac | pmac-mpw) cpu=powerpc vendor=apple ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) cpu=m68000 vendor=att ;; 3b*) cpu=we32k vendor=att ;; bluegene*) cpu=powerpc vendor=ibm basic_os=cnk ;; decsystem10* | dec10*) cpu=pdp10 vendor=dec basic_os=tops10 ;; decsystem20* | dec20*) cpu=pdp10 vendor=dec basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) cpu=m68k vendor=motorola ;; dpx2*) cpu=m68k vendor=bull basic_os=sysv3 ;; encore | umax | mmax) cpu=ns32k vendor=encore ;; elxsi) cpu=elxsi vendor=elxsi basic_os=${basic_os:-bsd} ;; fx2800) cpu=i860 vendor=alliant ;; genix) cpu=ns32k vendor=ns ;; h3050r* | hiux*) cpu=hppa1.1 vendor=hitachi basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) cpu=m68000 vendor=hp ;; hp9k3[2-9][0-9]) cpu=m68k vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) cpu=hppa1.1 vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp cpu=hppa1.1 vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp cpu=hppa1.1 vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) cpu=hppa1.1 vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; i*86v32) cpu=$(echo "$1" | sed -e 's/86.*/86/') vendor=pc basic_os=sysv32 ;; i*86v4*) cpu=$(echo "$1" | sed -e 's/86.*/86/') vendor=pc basic_os=sysv4 ;; i*86v) cpu=$(echo "$1" | sed -e 's/86.*/86/') vendor=pc basic_os=sysv ;; i*86sol2) cpu=$(echo "$1" | sed -e 's/86.*/86/') vendor=pc basic_os=solaris2 ;; j90 | j90-cray) cpu=j90 vendor=cray basic_os=${basic_os:-unicos} ;; iris | iris4d) cpu=mips vendor=sgi case $basic_os in irix*) ;; *) basic_os=irix4 ;; esac ;; miniframe) cpu=m68000 vendor=convergent ;; *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) cpu=m68k vendor=atari basic_os=mint ;; news-3600 | risc-news) cpu=mips vendor=sony basic_os=newsos ;; next | m*-next) cpu=m68k vendor=next case $basic_os in openstep*) ;; nextstep*) ;; ns2*) basic_os=nextstep2 ;; *) basic_os=nextstep3 ;; esac ;; np1) cpu=np1 vendor=gould ;; op50n-* | op60c-*) cpu=hppa1.1 vendor=oki basic_os=proelf ;; pa-hitachi) cpu=hppa1.1 vendor=hitachi basic_os=hiuxwe2 ;; pbd) cpu=sparc vendor=tti ;; pbb) cpu=m68k vendor=tti ;; pc532) cpu=ns32k vendor=pc532 ;; pn) cpu=pn vendor=gould ;; power) cpu=power vendor=ibm ;; ps2) cpu=i386 vendor=ibm ;; rm[46]00) cpu=mips vendor=siemens ;; rtpc | rtpc-*) cpu=romp vendor=ibm ;; sde) cpu=mipsisa32 vendor=sde basic_os=${basic_os:-elf} ;; simso-wrs) cpu=sparclite vendor=wrs basic_os=vxworks ;; tower | tower-32) cpu=m68k vendor=ncr ;; vpp*|vx|vx-*) cpu=f301 vendor=fujitsu ;; w65) cpu=w65 vendor=wdc ;; w89k-*) cpu=hppa1.1 vendor=winbond basic_os=proelf ;; none) cpu=none vendor=none ;; leon|leon[3-9]) cpu=sparc vendor=$basic_machine ;; leon-*|leon[3-9]-*) cpu=sparc vendor=$(echo "$basic_machine" | sed 's/-.*//') ;; *-*) # shellcheck disable=SC2162 IFS="-" read cpu vendor <&2 exit 1 ;; esac ;; esac # Here we canonicalize certain aliases for manufacturers. case $vendor in digital*) vendor=dec ;; commodore*) vendor=cbm ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if test x$basic_os != x then # First recognize some ad-hoc caes, or perhaps split kernel-os, or else just # set os. case $basic_os in gnu/linux*) kernel=linux os=$(echo $basic_os | sed -e 's|gnu/linux|gnu|') ;; os2-emx) kernel=os2 os=$(echo $basic_os | sed -e 's|os2-emx|emx|') ;; nto-qnx*) kernel=nto os=$(echo $basic_os | sed -e 's|nto-qnx|qnx|') ;; *-*) # shellcheck disable=SC2162 IFS="-" read kernel os <&2 exit 1 ;; esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. case $kernel-$os in linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) ;; uclinux-uclibc* ) ;; -dietlibc* | -newlib* | -musl* | -uclibc* ) # These are just libc implementations, not actual OSes, and thus # require a kernel. echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 exit 1 ;; kfreebsd*-gnu* | kopensolaris*-gnu*) ;; nto-qnx*) ;; os2-emx) ;; *-eabi* | *-gnueabi*) ;; -*) # Blank kernel with real OS is always fine. ;; *-*) echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 exit 1 ;; esac # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. case $vendor in unknown) case $cpu-$os in *-riscix*) vendor=acorn ;; *-sunos*) vendor=sun ;; *-cnk* | *-aix*) vendor=ibm ;; *-beos*) vendor=be ;; *-hpux*) vendor=hp ;; *-mpeix*) vendor=hp ;; *-hiux*) vendor=hitachi ;; *-unos*) vendor=crds ;; *-dgux*) vendor=dg ;; *-luna*) vendor=omron ;; *-genix*) vendor=ns ;; *-clix*) vendor=intergraph ;; *-mvs* | *-opened*) vendor=ibm ;; *-os400*) vendor=ibm ;; s390-* | s390x-*) vendor=ibm ;; *-ptx*) vendor=sequent ;; *-tpf*) vendor=ibm ;; *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; *-aux*) vendor=apple ;; *-hms*) vendor=hitachi ;; *-mpw* | *-macos*) vendor=apple ;; *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; *-vos*) vendor=stratus ;; esac ;; esac echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: rJava/jri/tools/getsp.java0000644000175100001440000000262115133274032015245 0ustar hornikuserspublic class getsp { public static void main(String[] args) { if (args!=null && args.length>0) { if (args[0].compareTo("-test")==0) { System.out.println("Test1234OK"); } else if (args[0].compareTo("-libs")==0) { String prefix="-L"; if (args.length>1) prefix=args[1]; String lp=System.getProperty("java.library.path"); // we're not using StringTokenizer in case the JVM is very crude int i=0,j,k=0; String r=null; String pss=System.getProperty("path.separator"); char ps=':'; if (pss!=null && pss.length()>0) ps=pss.charAt(0); j=lp.length(); while (i<=j) { if (i==j || lp.charAt(i)==ps) { String lib=lp.substring(k,i); k=i+1; if (lib.compareTo(".")!=0) r=(r==null)?(prefix+lib):(r+" "+prefix+lib); } i++; } if (r!=null) System.out.println(r); } else if (args[0].equals("-minver")) { boolean meets = false; String jv = System.getProperty("java.version"); if (jv.startsWith("1.")) jv = jv.substring(2); try { int i = 0; while (i < jv.length() && jv.charAt(i) >= '0' && jv.charAt(i) < '9') i++; jv = jv.substring(0, i); if (args.length > 1) { int req = Integer.parseInt(args[1]); int cv = Integer.parseInt(jv); meets = cv >= req; } } catch (Exception e) { } System.out.println(meets ? "yes" : "no"); } else System.out.println(System.getProperty(args[0])); } } } rJava/jri/REXP.java0000644000175100001440000005074515133274032013553 0ustar hornikuserspackage org.rosuda.JRI; import java.util.Vector; /** * This class encapsulates and caches R objects as returned from R. Currently it * only converts certain SEXPs references from R into Java obejcts, but * eventually bi-directional support should be added. The currently supported * objects are string, integer and numeric vectors. All other types can be * accessed only using {@link #xp} reference and RNI methods. */ public class REXP { /** xpression type: NULL */ public static final int XT_NULL = 0; /** xpression type: integer */ public static final int XT_INT = 1; /** xpression type: double */ public static final int XT_DOUBLE = 2; /** xpression type: String */ public static final int XT_STR = 3; /** xpression type: language construct (currently content is same as list) */ public static final int XT_LANG = 4; /** xpression type: symbol (content is symbol name: String) */ public static final int XT_SYM = 5; /** xpression type: RBool */ public static final int XT_BOOL = 6; /** xpression type: Vector */ public static final int XT_VECTOR = 16; /** xpression type: RList */ public static final int XT_LIST = 17; /** * xpression type: closure (there is no java class for that type (yet?). * currently the body of the closure is stored in the content part of the * REXP. Please note that this may change in the future!) */ public static final int XT_CLOS = 18; /** xpression type: int[] */ public static final int XT_ARRAY_INT = 32; /** xpression type: double[] */ public static final int XT_ARRAY_DOUBLE = 33; /** xpression type: String[] (currently not used, Vector is used instead) */ public static final int XT_ARRAY_STR = 34; /** internal use only! this constant should never appear in a REXP */ public static final int XT_ARRAY_BOOL_UA = 35; /** xpression type: RBool[] */ public static final int XT_ARRAY_BOOL = 36; /** xpression type: int[] to be interpreted as boolean */ public static final int XT_ARRAY_BOOL_INT = 37; /** xpression type: unknown; no assumptions can be made about the content */ public static final int XT_UNKNOWN = 48; /** xpression type: pure reference, no internal type conversion performed */ public static final int XT_NONE = -1; /** * xpression type: RFactor; this XT is internally generated (ergo is does * not come from Rsrv.h) to support RFactor class which is built from * XT_ARRAY_INT */ public static final int XT_FACTOR = 127; /* internal SEXP types in R - taken directly from Rinternals.h */ public static final int NILSXP = 0; /* nil = NULL */ public static final int SYMSXP = 1; /* symbols */ public static final int LISTSXP = 2; /* lists of dotted pairs */ public static final int CLOSXP = 3; /* closures */ public static final int ENVSXP = 4; /* environments */ public static final int PROMSXP = 5; /* * promises: [un]evaluated closure * arguments */ public static final int LANGSXP = 6; /* * language constructs (special * lists) */ public static final int SPECIALSXP = 7; /* special forms */ public static final int BUILTINSXP = 8; /* builtin non-special forms */ public static final int CHARSXP = 9; /* * "scalar" string type (internal * only) */ public static final int LGLSXP = 10; /* logical vectors */ public static final int INTSXP = 13; /* integer vectors */ public static final int REALSXP = 14; /* real variables */ public static final int CPLXSXP = 15; /* complex variables */ public static final int STRSXP = 16; /* string vectors */ public static final int DOTSXP = 17; /* dot-dot-dot object */ public static final int ANYSXP = 18; /* make "any" args work */ public static final int VECSXP = 19; /* generic vectors */ public static final int EXPRSXP = 20; /* expressions vectors */ public static final int BCODESXP = 21; /* byte code */ public static final int EXTPTRSXP = 22; /* external pointer */ public static final int WEAKREFSXP = 23; /* weak reference */ public static final int RAWSXP = 24; /* raw bytes */ public static final int S4SXP = 25; /* S4 object */ public static final int FUNSXP = 99; /* Closure or Builtin */ /** * Engine which this EXP was obtained from. EXPs are valid only for the * engine they were obtained from - it's illegal to mix EXP between engines. * There is a speacial case when the engine may be null - if a REXP creating * was requested but deferred until an engine is available. */ Rengine eng; /** * native reference to the SEXP represented in R. It's usually a pointer, * but can be any handle obtained from the engine. This reference can be * used when calling RNI commands directly. */ public long xp; /** * native type of the represented expression (see ...SXP constants in R). * Please note that this type is cached and may have changed in the * meantime. If the possibility of changing type exists (mainly list/lang) * then use rniExpType to make sure */ public int rtype; /** * create a REXP directly from a R SEXP reference. SEXP types STRSXP, INTSXP * and REALSXP are automatically converted. All others are represented as * SEXP references only. */ public REXP(Rengine re, long exp) { this(re, exp, true); } protected void finalize() throws Throwable { try { if (Xt == XT_NONE && xp != 0 && eng != null) // release underlying R obejct if it was preserved eng.rniRelease(xp); } finally { super.finalize(); } } public REXP(Rengine re, long exp, boolean convert) { eng = re; xp = exp; rtype = re.rniExpType(xp); //System.out.println("["+rtype+"@"+exp+","+convert+"]"); if (!convert) { Xt = XT_NONE; if (re != null && xp != 0) re.rniPreserve(xp); // preserve the object so it doesn't get garbage-collected while we are referencing it return; } if (rtype == STRSXP) { String[] s = re.rniGetStringArray(xp); if (s != null && s.length == 1) { cont = s[0]; Xt = XT_STR; } else { cont = s; Xt = XT_ARRAY_STR; } } else if (rtype == INTSXP) { cont = null; if (re.rniInherits(xp, "factor")) { long levx = re.rniGetAttr(xp, "levels"); if (levx != 0) { String[] levels = null; // we're using low-lever calls here (FIXME?) int rlt = re.rniExpType(levx); if (rlt == STRSXP) { levels = re.rniGetStringArray(levx); int[] ids = re.rniGetIntArray(xp); cont = new RFactor(ids, levels, 1); Xt = XT_FACTOR; } } } // if it's not a factor, then we use int[] instead if (cont == null ) { cont = re.rniGetIntArray(xp); Xt = XT_ARRAY_INT; } } else if (rtype == REALSXP) { cont = re.rniGetDoubleArray(xp); Xt = XT_ARRAY_DOUBLE; } else if (rtype == LGLSXP) { cont = re.rniGetBoolArrayI(xp); Xt = XT_ARRAY_BOOL_INT; } else if (rtype == VECSXP) { long[] l = re.rniGetVector(xp); cont = new RVector(); int i = 0; //System.out.println("VECSXP, length="+l.length); Xt = XT_VECTOR; while (i < l.length) ((RVector)cont).addElement(new REXP(re, l[i++])); long na = re.rniGetAttr(xp, "names"); if (na!=0 && re.rniExpType(na)==STRSXP) ((RVector)cont).setNames(re.rniGetStringArray(na)); } else if (rtype == LISTSXP) { long car = re.rniCAR(xp); long cdr = re.rniCDR(xp); long tag = re.rniTAG(xp); REXP cdrx = (cdr==0 || re.rniExpType(cdr)!=LISTSXP)?null:new REXP(re,re.rniCDR(xp)); cont = new RList(new REXP(re,car), (tag==0)?null:new REXP(re,tag), cdrx); Xt = XT_LIST; } else if (rtype == SYMSXP) { cont = re.rniGetSymbolName(xp); Xt = XT_SYM; } else Xt = XT_NULL; //System.out.println("new REXP: "+toString()); } /** xpression type */ int Xt; /** attribute xpression or null if none */ REXP attr; /** content of the xpression - its object type is dependent of {@link #Xt} */ Object cont; /** cached binary length; valid only if positive */ long cachedBinaryLength = -1; /** construct a new, empty (NULL) expression w/o attribute */ public REXP() { Xt = XT_NULL; attr = null; cont = null; } /** * construct a new xpression of type t and content o, but no attribute * * @param t * xpression type (XT_...) * @param o * content */ public REXP(int t, Object o) { Xt = t; cont = o; attr = null; } /** * construct a new xpression of type t, content o and attribute at * * @param t * xpression type * @param o * content * @param at * attribute */ public REXP(int t, Object o, REXP at) { Xt = t; cont = o; attr = at; } /** * construct a new xpression of type XT_ARRAY_DOUBLE and content val * * @param val * array of doubles to store in the REXP */ public REXP(double[] val) { this(XT_ARRAY_DOUBLE, val); } /** * construct a new xpression of type XT_ARRAY_INT and content val * * @param val * array of integers to store in the REXP */ public REXP(int[] val) { this(XT_ARRAY_INT, val); } /** * construct a new xpression of type XT_ARRAY_INT and content val * * @param val * array of integers to store in the REXP */ public REXP(String[] val) { this(XT_ARRAY_STR, val); } /** construct new expression with the contents of a boolean vector @since JRI 0.3-2 @param val contents */ public REXP(boolean[] val) { Xt = XT_ARRAY_BOOL_INT; if (val==null) { cont = new int[0]; } else { int [] ic = new int[val.length]; int i=0; while (inull if there is none associated @since JRI 0.3, replaces getAttribute() but should be avoided if possible - use {@link #getAttribute(String)} instead. */ public REXP getAttributes() { return attr; } /** retrieve a specific attribute.
Note: the current representation fetches the attribute ad-hoc, so it breaks the assumption that the expression is no longer accessed after the constructor was called. This should change in the future. @param name name of the attribute @return REXP containing the attribute or null if the attribute doesn't exist. The conversion flag is inherited from this REXP. @since JRI 0.3 */ public REXP getAttribute(String name) { // FIXME: we could do some caching if attr is not null ... long aref = eng.rniGetAttr(xp, name); if (aref==0) return null; return new REXP(eng, aref, (Xt != XT_NONE)); } /** * get raw content. Use as... methods to retrieve contents of known type. * * @return content of the REXP */ public Object getContent() { return cont; } /** * get xpression type (see XT_.. constants) of the content. It defines the * type of the content object. * * @return xpression type */ public int getType() { return Xt; } /** * Obtains R engine object which supplied this REXP. * * @returns {@link Rengine} object */ Rengine getEngine() { return eng; }; /** return the first element of a character vector if this REXP is a character vector of length 1 or more, return null otherwise */ public String asString() { if (cont == null) return null; if (Xt == XT_STR) return (String) cont; if (Xt == XT_ARRAY_STR) { String[] sa = (String[]) cont; return (sa.length > 0) ? sa[0] : null; } return null; } /** return the name of the symbol represented by this REXP if is it a symbol or null otherwise */ public String asSymbolName() { return (Xt == XT_SYM)?((String) cont):null; } /** return the contents of this REXP as an array of strings if this REXP is a character vector, return null otherwise */ public String[] asStringArray() { if (cont == null) return null; if (Xt == XT_STR) { String[] sa = new String[1]; sa[0] = (String) cont; return sa; } if (Xt == XT_ARRAY_STR) return (String[]) cont; return null; } /** * get content of the REXP as int (if it is one) * * @return int content or 0 if the REXP is no integer */ public int asInt() { if (Xt == XT_ARRAY_INT) { int i[] = (int[]) cont; if (i != null && i.length > 0) return i[0]; } return (Xt == XT_INT) ? ((Integer) cont).intValue() : 0; } /** * get content of the REXP as double (if it is one) * * @return double content or 0.0 if the REXP is no double */ public double asDouble() { if (Xt == XT_ARRAY_DOUBLE) { double d[] = (double[]) cont; if (d != null && d.length > 0) return d[0]; } return (Xt == XT_DOUBLE) ? ((Double) cont).doubleValue() : 0.0; } /** * get content of the REXP as {@link Vector} (if it is one) * * @return Vector content or null if the REXP is no Vector */ public RVector asVector() { return (Xt == XT_VECTOR) ? (RVector) cont : null; } /** * get content of the REXP as {@link RFactor} (if it is one) * * @return {@link RFactor} content or null if the REXP is no * factor */ public RFactor asFactor() { return (Xt == XT_FACTOR) ? (RFactor) cont : null; } /** * get content of the REXP as {@link RList} if the contents is a list or a generic vector * * @return {@link RList} content or null if the REXP is neither a list nor a generic vector */ public RList asList() { return (Xt == XT_LIST) ? (RList) cont : ( // for compatibility with Rserve we convert vectors to lists (Xt == XT_VECTOR) ? new RList((RVector)cont) : null ); } /** * get content of the REXP as {@link RBool} (if it is one) * * @return {@link RBool} content or null if the REXP is no * logical value */ public RBool asBool() { if (Xt == XT_ARRAY_BOOL_INT) { int [] ba = (int[]) cont; return (ba!=null && ba.length>0)?new RBool(ba[0]):null; } return (Xt == XT_BOOL) ? (RBool) cont : null; } /** * get content of the REXP as an array of doubles. Array of integers, single * double and single integer are automatically converted into such an array * if necessary. * * @return double[] content or null if the REXP is not a * array of doubles or integers */ public double[] asDoubleArray() { if (Xt == XT_ARRAY_DOUBLE) return (double[]) cont; if (Xt == XT_DOUBLE) { double[] d = new double[1]; d[0] = asDouble(); return d; } if (Xt == XT_INT) { double[] d = new double[1]; d[0] = ((Integer) cont).doubleValue(); return d; } if (Xt == XT_ARRAY_INT) { int[] i = asIntArray(); if (i == null) return null; double[] d = new double[i.length]; int j = 0; while (j < i.length) { d[j] = (double) i[j]; j++; } return d; } return null; } /** * get content of the REXP as an array of integers. Unlike * {@link #asDoubleArray} NO automatic conversion is done if the * content is not an array of the correct type, because there is no * canonical representation of doubles as integers. A single integer is * returned as an array of the length 1. This method can be also used * to access a logical array in its integer form (0=FALSE, 1=TRUE, 2=NA). * * @return int[] content or null if the REXP is not a * array of integers */ public int[] asIntArray() { if (Xt == XT_ARRAY_INT || Xt == XT_ARRAY_BOOL_INT) return (int[]) cont; if (Xt == XT_INT) { int[] i = new int[1]; i[0] = asInt(); return i; } return null; } /** * returns the content of the REXP as a matrix of doubles (2D-array: * m[rows][cols]). This is the same form as used by popular math packages * for Java, such as JAMA. This means that following leads to desired * results:
* Matrix m=new Matrix(c.eval("matrix(c(1,2,3,4,5,6),2,3)").asDoubleMatrix()); * * @return 2D array of doubles in the form double[rows][cols] or * null if the contents is no 2-dimensional matrix of * doubles */ public double[][] asDoubleMatrix() { double[] ct = asDoubleArray(); if (ct==null) return null; REXP dim = getAttribute("dim"); if (dim == null || dim.Xt != XT_ARRAY_INT) return null; // we need dimension attr int[] ds = dim.asIntArray(); if (ds == null || ds.length != 2) return null; // matrix must be 2-dimensional int m = ds[0], n = ds[1]; double[][] r = new double[m][n]; if (ct == null) return null; // R stores matrices as matrix(c(1,2,3,4),2,2) = col1:(1,2), col2:(3,4) // we need to copy everything, since we create 2d array from 1d array int i = 0, k = 0; while (i < n) { int j = 0; while (j < m) { r[j++][i] = ct[k++]; } i++; } return r; } /** this is just an alias for {@link #asDoubleMatrix()}. */ public double[][] asMatrix() { return asDoubleMatrix(); } /** * displayable contents of the expression. The expression is traversed * recursively if aggregation types are used (Vector, List, etc.) * * @return String descriptive representation of the xpression */ public String toString() { StringBuffer sb = new StringBuffer("[" + xtName(Xt) + " "); if (attr != null) sb.append("\nattr=" + attr + "\n "); if (Xt == XT_DOUBLE) sb.append((Double) cont); if (Xt == XT_INT) sb.append((Integer) cont); if (Xt == XT_BOOL) sb.append((RBool) cont); if (Xt == XT_FACTOR) sb.append((RFactor) cont); if (Xt == XT_ARRAY_DOUBLE) { double[] d = (double[]) cont; sb.append("("); for (int i = 0; i < d.length; i++) { sb.append(d[i]); if (i < d.length - 1) sb.append(", "); if (i == 99) { sb.append("... (" + (d.length - 100) + " more values follow)"); break; } } sb.append(")"); } if (Xt == XT_ARRAY_INT) { int[] d = (int[]) cont; sb.append("("); for (int i = 0; i < d.length; i++) { sb.append(d[i]); if (i < d.length - 1) sb.append(", "); if (i == 99) { sb.append("... (" + (d.length - 100) + " more values follow)"); break; } } sb.append(")"); } if (Xt == XT_ARRAY_BOOL) { RBool[] d = (RBool[]) cont; sb.append("("); for (int i = 0; i < d.length; i++) { sb.append(d[i]); if (i < d.length - 1) sb.append(", "); } sb.append(")"); } if (Xt == XT_ARRAY_STR) { String[] d = (String[]) cont; sb.append("("); for (int i = 0; i < d.length; i++) { sb.append((d[i] == null) ? "NA" : ("\"" + d[i] + "\"")); if (i < d.length - 1) sb.append(", "); if (i == 10 && d.length > 14) { sb.append("... (" + (d.length - 10) + " more values follow)"); break; } } sb.append(")"); } if (Xt == XT_VECTOR) { Vector v = (Vector) cont; sb.append("("); for (int i = 0; i < v.size(); i++) { sb.append(((REXP) v.elementAt(i)).toString()); if (i < v.size() - 1) sb.append(", "); } sb.append(")"); } if (Xt == XT_STR) { if (cont == null) sb.append("NA"); else { sb.append("\""); sb.append((String) cont); sb.append("\""); } } if (Xt == XT_SYM) { sb.append((String) cont); } if (Xt == XT_LIST || Xt == XT_LANG) { RList l = (RList) cont; sb.append(l.head); sb.append(":"); sb.append(l.tag); sb.append(",("); sb.append(l.body); sb.append(")"); } if (Xt == XT_NONE) { sb.append("{"+rtype+"}"); } if (Xt == XT_UNKNOWN) sb.append((Integer) cont); sb.append("]"); return sb.toString(); } public static String quoteString(String s) { // this code uses API introdiced in 1.4 so it needs to be re-written for // earlier JDKs if (s.indexOf('\\') >= 0) s.replaceAll("\\", "\\\\"); if (s.indexOf('"') >= 0) s.replaceAll("\"", "\\\""); return "\"" + s + "\""; } /** returns human-readable name of the xpression type as string. Arrays are denoted by a trailing asterisk (*). @param xt xpression type @return name of the xpression type */ public static String xtName(int xt) { if (xt==XT_NULL) return "NULL"; if (xt==XT_INT) return "INT"; if (xt==XT_STR) return "STRING"; if (xt==XT_DOUBLE) return "REAL"; if (xt==XT_BOOL) return "BOOL"; if (xt==XT_ARRAY_INT) return "INT*"; if (xt==XT_ARRAY_STR) return "STRING*"; if (xt==XT_ARRAY_DOUBLE) return "REAL*"; if (xt==XT_ARRAY_BOOL) return "BOOL*"; if (xt==XT_ARRAY_BOOL_INT) return "BOOLi*"; if (xt==XT_SYM) return "SYMBOL"; if (xt==XT_LANG) return "LANG"; if (xt==XT_LIST) return "LIST"; if (xt==XT_CLOS) return "CLOS"; if (xt==XT_VECTOR) return "VECTOR"; if (xt==XT_FACTOR) return "FACTOR"; if (xt==XT_UNKNOWN) return "UNKNOWN"; if (xt==XT_NONE) return "(SEXP)"; return ""; } } rJava/jri/RList.java0000644000175100001440000001043015133274032014015 0ustar hornikuserspackage org.rosuda.JRI; // JRclient library - client interface to Rserve, see http://www.rosuda.org/Rserve/ // Copyright (C) 2004 Simon Urbanek // --- for licensing information see LICENSE file in the original JRclient distribution --- import java.util.*; /** implementation of R-lists
This is rather preliminary and may change in future since it's not really proper. The point is that the parser tries to interpret lists to be of the form entry=value, where entry is stored in the "head" part, and value is stored in the "body" part. Then using {@link #at(String)} it is possible to fetch "body" for a specific "head". The terminology used is partly from hash fields - "keys" are the elements in "head" and values are in "body" (see {@link #keys}).

On the other hand, R uses lists to store complex internal structures, which are not parsed according to the structure - in that case "head" and "body" have to be evaluated separately according to their meaning in that context. @version $Id: RList.java 2720 2007-03-15 17:35:42Z urbanek $ */ public class RList extends Object { /** xpressions containing head, body and tag. The terminology is a bit misleading (for historical reasons) - head corresponds to CAR, body to CDR and finally tag is TAG. */ public REXP head, body, tag; /** cached keys (from TAG) */ String[] keys = null; /** cached values(from CAR) */ REXP[] values = null; /** flag denoting whether we need to re-fetch the cached values.

the current assumption is that the contents don't change after first retrieval - there is currently no recursive check! */ boolean dirtyCache = true; /** constructs an empty list */ public RList() { head=body=tag=null; } /** fake constructor to keep compatibility with Rserve (for now, will be gone soon) */ public RList(RVector v) { Vector n = v.getNames(); if (n != null) { keys = new String[n.size()]; n.copyInto(keys); } values=new REXP[v.size()]; v.copyInto(values); dirtyCache=false; // head,tail,tag are all invalid! } /** constructs an initialized list @param h head xpression @param b body xpression */ public RList(REXP h, REXP b) { head=h; body=b; tag=null; } /** constructs an initialized list @param h head xpression (CAR) @param t tag xpression (TAG) @param b body/tail xpression (CDR) */ public RList(REXP h, REXP t, REXP b) { head=h; body=b; tag=t; } /** get head xpression (CAR) @return head xpression */ public REXP getHead() { return head; } /** get body xpression (CDR) @return body xpression */ public REXP getBody() { return body; } /** get tag xpression @return tag xpression */ public REXP getTag() { return tag; } /** internal function that updates cached vectors @return true if the conversion was successful */ boolean updateVec() { if (!dirtyCache) return true; // we do NOT run it recursively, because in most cases only once instance is asked RList cur = this; int l = 0; while (cur!=null) { l++; REXP bd = cur.getBody(); cur = (bd==null)?null:bd.asList(); } keys=new String[l]; values=new REXP[l]; cur = this; l=0; while (cur != null) { REXP x = cur.getTag(); if (x!=null) keys[l]=x.asSymbolName(); values[l] = cur.getHead(); REXP bd = cur.getBody(); cur = (bd==null)?null:bd.asList(); l++; } dirtyCache=false; return true; } /** get xpression given a key @param v key @return xpression which corresponds to the given key or null if list is not standartized or key not found */ public REXP at(String v) { if (!updateVec() || keys==null || values==null) return null; int i=0; while (inull if list is not standartized or if index out of bounds */ public REXP at(int i) { return (!updateVec() || values==null || i<0 || i>=values.length)?null:values[i]; } /** returns all keys of the list @return array containing all keys or null if list is not standartized */ public String[] keys() { return (!updateVec())?null:this.keys; } } rJava/jri/configure0000755000175100001440000047633615133274037014056 0ustar hornikusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.71 for JRI 0.3. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, # Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="as_nop=: if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else \$as_nop case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ) then : else \$as_nop exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 blah=\$(echo \$(echo blah)) test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" if (eval "$as_required") 2>/dev/null then : as_have_required=yes else $as_nop as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null then : else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$as_shell as_have_required=yes if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null then : break 2 fi fi done;; esac as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop if { test -f "$SHELL" || test -f "$SHELL.exe"; } && as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$SHELL as_have_required=yes fi fi if test "x$CONFIG_SHELL" != x then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno then : printf "%s\n" "$0: This script requires a shell more modern than all" printf "%s\n" "$0: the shells that I found on your system." if test ${ZSH_VERSION+y} ; then printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and $0: simon.urbanek@r-project.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='JRI' PACKAGE_TARNAME='jri' PACKAGE_VERSION='0.3' PACKAGE_STRING='JRI 0.3' PACKAGE_BUGREPORT='simon.urbanek@r-project.org' PACKAGE_URL='' ac_unique_file="src/jri.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_STDIO_H # include #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_header_c_list= ac_subst_vars='LTLIBOBJS LIBOBJS DEFFLAGS RLD RINC CPICF JNIPREFIX JNISO JNILD JFLAGS JAVA_CFLAGS JAVA_INC JAVA_LIBS JAVA_LD_PATH JAVA_HOME JAR JAVAH JAVAC JAVA_PROG OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC R_INCLUDE_DIR R_DOC_DIR R_SHARE_DIR R_HOME host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures JRI 0.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/jri] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of JRI 0.3:";; esac cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for configure.gnu first; this name is used for a wrapper for # Metaconfig's "Configure" on case-insensitive file systems. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF JRI configure 0.3 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_try_run LINENO # ---------------------- # Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that # executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: program exited with status $ac_status" >&5 printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run ac_configure_args_raw= for ac_arg do case $ac_arg in *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_configure_args_raw " '$ac_arg'" done case $ac_configure_args_raw in *$as_nl*) ac_safe_unquote= ;; *) ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. ac_unsafe_a="$ac_unsafe_z#~" ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; esac cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by JRI $as_me 0.3, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac printf "%s\n" "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Sanitize IFS. IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo printf "%s\n" "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo printf "%s\n" "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then printf "%s\n" "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then printf "%s\n" "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && printf "%s\n" "$as_me: caught signal $ac_signal" printf "%s\n" "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h printf "%s\n" "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then ac_site_files="$CONFIG_SITE" elif test "x$prefix" != xNONE; then ac_site_files="$prefix/share/config.site $prefix/etc/config.site" else ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi for ac_site_file in $ac_site_files do case $ac_site_file in #( */*) : ;; #( *) : ac_site_file=./$ac_site_file ;; esac if test -f "$ac_site_file" && test -r "$ac_site_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 printf "%s\n" "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 printf "%s\n" "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Test code for whether the C compiler supports C89 (global declarations) ac_c_conftest_c89_globals=' /* Does the compiler advertise C89 conformance? Do not test the value of __STDC__, because some compilers set it to 0 while being otherwise adequately conformant. */ #if !defined __STDC__ # error "Compiler does not advertise C89 conformance" #endif #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ struct buf { int x; }; struct buf * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not \xHH hex character constants. These do not provoke an error unfortunately, instead are silently treated as an "x". The following induces an error, until -std is added to get proper ANSI mode. Curiously \x00 != x always comes out true, for an array size at least. It is necessary to write \x00 == 0 to get something that is true only with -std. */ int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) '\''x'\'' int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), int, int);' # Test code for whether the C compiler supports C89 (body of main). ac_c_conftest_c89_main=' ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); ' # Test code for whether the C compiler supports C99 (global declarations) ac_c_conftest_c99_globals=' // Does the compiler advertise C99 conformance? #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L # error "Compiler does not advertise C99 conformance" #endif #include extern int puts (const char *); extern int printf (const char *, ...); extern int dprintf (int, const char *, ...); extern void *malloc (size_t); // Check varargs macros. These examples are taken from C99 6.10.3.5. // dprintf is used instead of fprintf to avoid needing to declare // FILE and stderr. #define debug(...) dprintf (2, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK #error "your preprocessor is broken" #endif #if BIG_OK #else #error "your preprocessor is broken" #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) continue; return 0; } // Check varargs and va_copy. static bool test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str = ""; int number = 0; float fnumber = 0; while (*format) { switch (*format++) { case '\''s'\'': // string str = va_arg (args_copy, const char *); break; case '\''d'\'': // int number = va_arg (args_copy, int); break; case '\''f'\'': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); return *str && number && fnumber; } ' # Test code for whether the C compiler supports C99 (body of main). ac_c_conftest_c99_main=' // Check bool. _Bool success = false; success |= (argc != 0); // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[0] = argv[0][0]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' || dynamic_array[ni.number - 1] != 543); ' # Test code for whether the C compiler supports C11 (global declarations) ac_c_conftest_c11_globals=' // Does the compiler advertise C11 conformance? #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L # error "Compiler does not advertise C11 conformance" #endif // Check _Alignas. char _Alignas (double) aligned_as_double; char _Alignas (0) no_special_alignment; extern char aligned_as_int; char _Alignas (0) _Alignas (int) aligned_as_int; // Check _Alignof. enum { int_alignment = _Alignof (int), int_array_alignment = _Alignof (int[100]), char_alignment = _Alignof (char) }; _Static_assert (0 < -_Alignof (int), "_Alignof is signed"); // Check _Noreturn. int _Noreturn does_not_return (void) { for (;;) continue; } // Check _Static_assert. struct test_static_assert { int x; _Static_assert (sizeof (int) <= sizeof (long int), "_Static_assert does not work in struct"); long int y; }; // Check UTF-8 literals. #define u8 syntax error! char const utf8_literal[] = u8"happens to be ASCII" "another string"; // Check duplicate typedefs. typedef long *long_ptr; typedef long int *long_ptr; typedef long_ptr long_ptr; // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. struct anonymous { union { struct { int i; int j; }; struct { int k; long int l; } w; }; int m; } v1; ' # Test code for whether the C compiler supports C11 (body of main). ac_c_conftest_c11_main=' _Static_assert ((offsetof (struct anonymous, i) == offsetof (struct anonymous, w.k)), "Anonymous union alignment botch"); v1.i = 2; v1.w.k = 5; ok |= v1.i != 5; ' # Test code for whether the C compiler supports C11 (complete). ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} ${ac_c_conftest_c99_globals} ${ac_c_conftest_c11_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} ${ac_c_conftest_c99_main} ${ac_c_conftest_c11_main} return ok; } " # Test code for whether the C compiler supports C99 (complete). ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} ${ac_c_conftest_c99_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} ${ac_c_conftest_c99_main} return ok; } " # Test code for whether the C compiler supports C89 (complete). ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} return ok; } " as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" # Auxiliary files required by this configure script. ac_aux_files="config.guess config.sub" # Locations in which to look for auxiliary files. ac_aux_dir_candidates="${srcdir}/tools" # Search for a directory containing all of the required auxiliary files, # $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. # If we don't find one directory that contains all the files we need, # we report the set of missing files from the *first* directory in # $ac_aux_dir_candidates and give up. ac_missing_aux_files="" ac_first_candidate=: printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in $ac_aux_dir_candidates do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 ac_aux_dir_found=yes ac_install_sh= for ac_aux in $ac_aux_files do # As a special case, if "install-sh" is required, that requirement # can be satisfied by any of "install-sh", "install.sh", or "shtool", # and $ac_install_sh is set appropriately for whichever one is found. if test x"$ac_aux" = x"install-sh" then if test -f "${as_dir}install-sh"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 ac_install_sh="${as_dir}install-sh -c" elif test -f "${as_dir}install.sh"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 ac_install_sh="${as_dir}install.sh -c" elif test -f "${as_dir}shtool"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 ac_install_sh="${as_dir}shtool install -c" else ac_aux_dir_found=no if $ac_first_candidate; then ac_missing_aux_files="${ac_missing_aux_files} install-sh" else break fi fi else if test -f "${as_dir}${ac_aux}"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 else ac_aux_dir_found=no if $ac_first_candidate; then ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" else break fi fi fi done if test "$ac_aux_dir_found" = yes; then ac_aux_dir="$as_dir" break fi ac_first_candidate=false as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. if test -f "${ac_aux_dir}config.guess"; then ac_config_guess="$SHELL ${ac_aux_dir}config.guess" fi if test -f "${ac_aux_dir}config.sub"; then ac_config_sub="$SHELL ${ac_aux_dir}config.sub" fi if test -f "$ac_aux_dir/configure"; then ac_configure="$SHELL ${ac_aux_dir}configure" fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers src/config.h" # Make sure we can run config.sub. $SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 printf %s "checking build system type... " >&6; } if test ${ac_cv_build+y} then : printf %s "(cached) " >&6 else $as_nop ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 printf "%s\n" "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 printf %s "checking host system type... " >&6; } if test ${ac_cv_host+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 printf "%s\n" "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # find R home : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi # we attempt to use the same compiler as R did RBIN="${R_HOME}/bin/R" R_CC=`"${RBIN}" CMD config CC` ## CPP is now deprecated R_CPP="${R_CC} -E" R_CFLAGS=`"${RBIN}" CMD config CFLAGS` # find R_SHARE_DIR : ${R_SHARE_DIR=`"${RBIN}" CMD sh -c 'echo $R_SHARE_DIR'`} if test -z "${R_SHARE_DIR}"; then echo "could not determine R_SHARE_DIR" exit 1 fi # find R_DOC_DIR : ${R_DOC_DIR=`"${RBIN}" CMD sh -c 'echo $R_DOC_DIR'`} if test -z "${R_DOC_DIR}"; then echo "could not determine R_DOC_DIR" exit 1 fi # find R_INCLUDE_DIR : ${R_INCLUDE_DIR=`"${RBIN}" CMD sh -c 'echo $R_INCLUDE_DIR'`} if test -z "${R_INCLUDE_DIR}"; then echo "could not determine R_INCLUDE_DIR" exit 1 fi # if user did not specify CC then we use R's settings. # if CC was set then user is responsible for CFLAGS as well! if test -z "${CC}"; then CC="${R_CC}" CPP="${R_CPP}" CFLAGS="${R_CFLAGS}" fi RINC=`"${RBIN}" CMD config --cppflags` RLD=`"${RBIN}" CMD config --ldflags` if test -z "$RLD"; then as_fn_error $? "R was not compiled with --enable-R-shlib *** You must have libR.so or equivalent in order to use JRI *** " "$LINENO" 5 fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. set dummy ${ac_tool_prefix}clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "clang", so it can be a program name with args. set dummy clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi fi test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion -version; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 printf %s "checking whether the C compiler works... " >&6; } ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else $as_nop ac_file='' fi if test -z "$ac_file" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 printf %s "checking for C compiler default output file name... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 printf "%s\n" "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 printf %s "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else $as_nop { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 printf "%s\n" "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 printf %s "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 printf "%s\n" "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 printf %s "checking for suffix of object files... " >&6; } if test ${ac_cv_objext+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 printf "%s\n" "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 printf %s "checking whether the compiler supports GNU C... " >&6; } if test ${ac_cv_c_compiler_gnu+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_compiler_gnu=yes else $as_nop ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } ac_compiler_gnu=$ac_cv_c_compiler_gnu if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+y} ac_save_CFLAGS=$CFLAGS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 printf %s "checking whether $CC accepts -g... " >&6; } if test ${ac_cv_prog_cc_g+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes else $as_nop CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 printf "%s\n" "$ac_cv_prog_cc_g" >&6; } if test $ac_test_CFLAGS; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi ac_prog_cc_stdc=no if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 printf %s "checking for $CC option to enable C11 features... " >&6; } if test ${ac_cv_prog_cc_c11+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c11=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c11_program _ACEOF for ac_arg in '' -std=gnu11 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c11=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c11" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c11" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c11" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } CC="$CC $ac_cv_prog_cc_c11" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 ac_prog_cc_stdc=c11 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 printf %s "checking for $CC option to enable C99 features... " >&6; } if test ${ac_cv_prog_cc_c99+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c99_program _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c99" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c99" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } CC="$CC $ac_cv_prog_cc_c99" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 ac_prog_cc_stdc=c99 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 printf %s "checking for $CC option to enable C89 features... " >&6; } if test ${ac_cv_prog_cc_c89+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c89_program _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c89" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c89" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } CC="$CC $ac_cv_prog_cc_c89" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 ac_prog_cc_stdc=c89 fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ## we need HAVE_..._H for R-ext/eventloop.h which requires ## defines from R's config.h which are not shipped with R ac_header= ac_cache= for ac_item in $ac_header_c_list do if test $ac_cache; then ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then printf "%s\n" "#define $ac_item 1" >> confdefs.h fi ac_header= ac_cache= elif test $ac_header; then ac_cache=$ac_item else ac_header=$ac_item fi done if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes then : printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" if test "x$ac_cv_header_sys_time_h" = xyes then : printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default" if test "x$ac_cv_header_sys_types_h" = xyes then : printf "%s\n" "#define HAVE_SYS_TYPES_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/select.h" "ac_cv_header_sys_select_h" "$ac_includes_default" if test "x$ac_cv_header_sys_select_h" = xyes then : printf "%s\n" "#define HAVE_SYS_SELECT_H 1" >>confdefs.h fi ## RUN_JAVA(variable for the result, parameters) ## ---------- ## runs the java interpreter ${JAVA_PROG} with specified parameters and ## saves the output to the supplied variable. The exit value is ignored. if test -n "${CONFIGURED}"; then ## re-map variables that don't match JAVA_PROG="${JAVA}" JAVA_INC="${JAVA_CPPFLAGS}" JAVA_LD_PATH="${JAVA_LD_LIBRARY_PATH}" else ## find java compiler binaries if test -z "${JAVA_HOME}" ; then JAVA_PATH=${PATH} else JAVA_PATH=${JAVA_HOME}:${JAVA_HOME}/jre/bin:${JAVA_HOME}/bin:${JAVA_HOME}/../bin:${PATH} fi ## if 'java' is not on the PATH or JAVA_HOME, add some guesses as of ## where java could live JAVA_PATH=${JAVA_PATH}:/usr/java/bin:/usr/jdk/bin:/usr/lib/java/bin:/usr/lib/jdk/bin:/usr/local/java/bin:/usr/local/jdk/bin:/usr/local/lib/java/bin:/usr/local/lib/jdk/bin for ac_prog in java do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_JAVA_PROG+y} then : printf %s "(cached) " >&6 else $as_nop case $JAVA_PROG in [\\/]* | ?:[\\/]*) ac_cv_path_JAVA_PROG="$JAVA_PROG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in ${JAVA_PATH} do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_JAVA_PROG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi JAVA_PROG=$ac_cv_path_JAVA_PROG if test -n "$JAVA_PROG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $JAVA_PROG" >&5 printf "%s\n" "$JAVA_PROG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$JAVA_PROG" && break done ## FIXME: we may want to check for jikes, kaffe and others... for ac_prog in javac do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_JAVAC+y} then : printf %s "(cached) " >&6 else $as_nop case $JAVAC in [\\/]* | ?:[\\/]*) ac_cv_path_JAVAC="$JAVAC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in ${JAVA_PATH} do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_JAVAC="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi JAVAC=$ac_cv_path_JAVAC if test -n "$JAVAC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $JAVAC" >&5 printf "%s\n" "$JAVAC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$JAVAC" && break done for ac_prog in javah do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_JAVAH+y} then : printf %s "(cached) " >&6 else $as_nop case $JAVAH in [\\/]* | ?:[\\/]*) ac_cv_path_JAVAH="$JAVAH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in ${JAVA_PATH} do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_JAVAH="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi JAVAH=$ac_cv_path_JAVAH if test -n "$JAVAH"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $JAVAH" >&5 printf "%s\n" "$JAVAH" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$JAVAH" && break done for ac_prog in jar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_JAR+y} then : printf %s "(cached) " >&6 else $as_nop case $JAR in [\\/]* | ?:[\\/]*) ac_cv_path_JAR="$JAR" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in ${JAVA_PATH} do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_JAR="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi JAR=$ac_cv_path_JAR if test -n "$JAR"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $JAR" >&5 printf "%s\n" "$JAR" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$JAR" && break done fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking Java version" >&5 printf %s "checking Java version... " >&6; } JVER=`"$JAVA" -version 2>&1 | sed -n 's:^.* version "::p' | sed 's:".*::'` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $JVER" >&5 printf "%s\n" "$JVER" >&6; } if test -z "$JVER"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: **** Cannot detect Java version - the java -version output is unknown! ****" >&5 printf "%s\n" "$as_me: WARNING: **** Cannot detect Java version - the java -version output is unknown! ****" >&2;} else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking Java compatibility version (integer)" >&5 printf %s "checking Java compatibility version (integer)... " >&6; } ## .. Oracle decided to completely screw up Java version so have to try extract something meaningful .. if echo $JVER | grep '^1\.' >/dev/null; then ## old style 1.X JMVER=`echo $JVER | sed 's:^..::' | sed 's:\..*::'` else ## new stype omitting the major version JMVER=`echo $JVER | sed 's:\..*::'` fi ## strip -.* for versions like 13-ea JMVER=`echo $JMVER | sed 's:-.*::'` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $JMVER" >&5 printf "%s\n" "$JMVER" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $JAVAH actually works" >&5 printf %s "checking whether $JAVAH actually works... " >&6; } if "$JAVAH" -version >/dev/null 2>&1; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } JAVAH= fi have_all_java=yes ## Java 1.10 has no javah anymore -- it uses javac -h . instaead if test -z "$JAVAH"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether javah was replaced by javac -h" >&5 printf %s "checking whether javah was replaced by javac -h... " >&6; } if test "$JMVER" -gt 9; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } ## create headres in the compile step instead JFLAGS=' -h .' else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } have_all_java=no; fi fi if test -z "$JAVA_PROG"; then have_all_java=no; fi if test -z "$JAVAC"; then have_all_java=no; fi if test -z "$JAR"; then have_all_java=no; fi if test ${have_all_java} = no; then as_fn_error $? "one or more Java tools are missing. *** JDK is incomplete! Please make sure you have a complete JDK. JRE is *not* sufficient." "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for target flags" >&5 printf %s "checking for target flags... " >&6; } ## set JFLAGS target -- depends on the JDK version if echo $JFLAGS | grep '[-]target' >/dev/null; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: user-supplied: $JFLAGS" >&5 printf "%s\n" "user-supplied: $JFLAGS" >&6; } else if test "$JMVER" -lt 9; then JFLAGS="$JFLAGS -target 1.4 -source 1.4" else if test "$JMVER" -lt 12; then JFLAGS="$JFLAGS -target 1.6 -source 1.6" else JFLAGS="$JFLAGS -target 1.8 -source 1.8" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $JFLAGS" >&5 printf "%s\n" "$JFLAGS" >&6; } fi ## this is where our test-class lives getsp_cp=tools { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Java interpreter works" >&5 printf %s "checking whether Java interpreter works... " >&6; } acx_java_works=no if test -n "${JAVA_PROG}" ; then acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java -classpath ${getsp_cp} getsp -test" >&5 else echo "$as_me:$LINENO: running ${JAVA_PROG} -classpath ${getsp_cp} getsp -test" >&5 acx_java_result=`${JAVA_PROG} -classpath ${getsp_cp} getsp -test 2>&5` echo "$as_me:$LINENO: output: '$acx_java_result'" >&5 fi acx_jc_result=$acx_java_result if test "${acx_jc_result}" = "Test1234OK"; then acx_java_works=yes fi acx_jc_result= fi if test "x`uname -s 2>/dev/null`" = xDarwin; then ## we need to pull that out of R in case re-export fails (which is does on 10.11) DYLD_FALLBACK_LIBRARY_PATH=`"${RBIN}" --slave --vanilla -e 'cat(Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH"))'` export DYLD_FALLBACK_LIBRARY_PATH fi if test -z "${CONFIGURED}"; then if test ${acx_java_works} = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Java environment" >&5 printf %s "checking for Java environment... " >&6; } ## retrieve JAVA_HOME from Java itself if not set if test -z "${JAVA_HOME}" ; then acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java -classpath ${getsp_cp} getsp java.home" >&5 else echo "$as_me:$LINENO: running ${JAVA_PROG} -classpath ${getsp_cp} getsp java.home" >&5 acx_java_result=`${JAVA_PROG} -classpath ${getsp_cp} getsp java.home 2>&5` echo "$as_me:$LINENO: output: '$acx_java_result'" >&5 fi JAVA_HOME=$acx_java_result fi ## the availability of JAVA_HOME will tell us whether it's supported if test -z "${JAVA_HOME}" ; then if test x$acx_java_env_msg != xyes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not found" >&5 printf "%s\n" "not found" >&6; } fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: in ${JAVA_HOME}" >&5 printf "%s\n" "in ${JAVA_HOME}" >&6; } case "${host_os}" in darwin*) if -z "${JAVA_LIBS}" ; then JAVA_LIBS="-framework JavaVM" JAVA_LD_PATH= fi ;; *) acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java -classpath ${getsp_cp} getsp -libs" >&5 else echo "$as_me:$LINENO: running ${JAVA_PROG} -classpath ${getsp_cp} getsp -libs" >&5 acx_java_result=`${JAVA_PROG} -classpath ${getsp_cp} getsp -libs 2>&5` echo "$as_me:$LINENO: output: '$acx_java_result'" >&5 fi JAVA_LIBS=$acx_java_result JAVA_LIBS="${JAVA_LIBS} -ljvm" acx_java_result= if test -z "${JAVA_PROG}"; then echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java -classpath ${getsp_cp} getsp java.library.path" >&5 else echo "$as_me:$LINENO: running ${JAVA_PROG} -classpath ${getsp_cp} getsp java.library.path" >&5 acx_java_result=`${JAVA_PROG} -classpath ${getsp_cp} getsp java.library.path 2>&5` echo "$as_me:$LINENO: output: '$acx_java_result'" >&5 fi JAVA_LD_PATH=$acx_java_result ;; esac ## note that we actually don't test JAVA_LIBS - we hope that the detection ## was correct. We should also test the functionality for javac. have_java=yes fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "Java not found. Please install JDK 1.4 or later, make sure that the binaries are on the PATH and re-try. If that doesn't work, set JAVA_HOME correspondingly." "$LINENO" 5 fi as_ac_File=`printf "%s\n" "ac_cv_file_${JAVA_HOME}/include/jni.h" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${JAVA_HOME}/include/jni.h" >&5 printf %s "checking for ${JAVA_HOME}/include/jni.h... " >&6; } if eval test \${$as_ac_File+y} then : printf %s "(cached) " >&6 else $as_nop test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r "${JAVA_HOME}/include/jni.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes" then : JNI_H="${JAVA_HOME}/include" else $as_nop as_ac_File=`printf "%s\n" "ac_cv_file_${JAVA_HOME}/jni.h" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${JAVA_HOME}/jni.h" >&5 printf %s "checking for ${JAVA_HOME}/jni.h... " >&6; } if eval test \${$as_ac_File+y} then : printf %s "(cached) " >&6 else $as_nop test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r "${JAVA_HOME}/jni.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes" then : JNI_H="${JAVA_HOME}" else $as_nop as_ac_File=`printf "%s\n" "ac_cv_file_${JAVA_HOME}/../include/jni.h" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${JAVA_HOME}/../include/jni.h" >&5 printf %s "checking for ${JAVA_HOME}/../include/jni.h... " >&6; } if eval test \${$as_ac_File+y} then : printf %s "(cached) " >&6 else $as_nop test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r "${JAVA_HOME}/../include/jni.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes" then : JNI_H="${JAVA_HOME}/../include" else $as_nop as_fn_error $? "Cannot compile JNI programs, check jri/config.log for details. Please make sure you have a proper JDK installed. Use --disable-jri when you install rJava and don't need JRI. " "$LINENO" 5 fi fi fi JAVA_INC="-I${JNI_H}" : ${JAVA_CFLAGS=-D_REENTRANT} # Sun's JDK needs jni_md.h in in addition to jni.h and unfortunately it's stored somewhere else ... # this should be become more general at some point - so far we're checking linux and solaris only # (well, those are presumably the only platforms supported by Sun's JDK and others don't need this # at least as of now - 01/2004) jac_found_md=no for mddir in . linux solaris ppc irix alpha aix hp-ux genunix cygwin win32 freebsd; do as_ac_File=`printf "%s\n" "ac_cv_file_${JNI_H}/$mddir/jni_md.h" | $as_tr_sh` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${JNI_H}/$mddir/jni_md.h" >&5 printf %s "checking for ${JNI_H}/$mddir/jni_md.h... " >&6; } if eval test \${$as_ac_File+y} then : printf %s "(cached) " >&6 else $as_nop test "$cross_compiling" = yes && as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 if test -r "${JNI_H}/$mddir/jni_md.h"; then eval "$as_ac_File=yes" else eval "$as_ac_File=no" fi fi eval ac_res=\$$as_ac_File { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes" then : JAVA_INC="${JAVA_INC} -I${JNI_H}/$mddir" jac_found_md=yes fi if test ${jac_found_md} = yes; then break; fi done fi ## the configure variables may contain $(JAVA_HOME) which for testing needs to be replaced by the real path if test `echo foo | sed -e 's:foo:bar:'` = bar; then JAVA_INC0=`echo ${JAVA_INC} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LD_PATH0=`echo ${JAVA_LD_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: sed is not working properly - the configuration may fail" >&5 printf "%s\n" "$as_me: WARNING: sed is not working properly - the configuration may fail" >&2;} JAVA_INC0="${JAVA_INC}" JAVA_LIBS0="${JAVA_LIBS}" JAVA_LD_PATH0="${JAVA_LD_PATH}" fi LIBS="${LIBS} ${JAVA_LIBS0}" CFLAGS="${CFLAGS} ${JAVA_CFLAGS} ${JAVA_INC0}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether JNI programs can be compiled" >&5 printf %s "checking whether JNI programs can be compiled... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { jobject o; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop as_fn_error $? "Cannot compile a simple JNI program. See config.log for details." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${JAVA_LD_PATH0} export LD_LIBRARY_PATH { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether JNI programs can be run" >&5 printf %s "checking whether JNI programs can be run... " >&6; } if test "$cross_compiling" = yes then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { jobject o; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "Cannot run a simple JNI program - probably your jvm library is in non-standard location or JVM is unsupported. See config.log for details." "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking JNI data types" >&5 printf %s "checking JNI data types... " >&6; } if test "$cross_compiling" = yes then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1; } _ACEOF if ac_fn_c_try_run "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 printf "%s\n" "ok" >&6; } else $as_nop as_fn_error $? "One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this." "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi JNIPREFIX=lib CPICF=`"${RBIN}" CMD config CPICFLAGS` JNISO=.so JNILD=`"${RBIN}" CMD config SHLIB_LDFLAGS`" ${JAVA_LIBS}" # we need to adjust a few things according to OS .. case "${host_os}" in darwin*) JNISO=.jnilib JNILD="-dynamiclib $JNILD" CPICF=-fno-common if test -e "${R_HOME}/lib/i386" -a -e "${R_HOME}/lib/ppc" -a -e "${R_HOME}/lib/libR.dylib"; then # we have an universal framework, so we will use stubs and fat lib RLD="-framework R" RINC="-I${R_HOME}/include" # we can even cross-compile, maybe if test -z "${FORCE_NATIVE}"; then # find out the archs of JavaVM and build all of them jarchs=`file -L /System/Library/Frameworks/JavaVM.framework/JavaVM 2>/dev/null | sed -n 's/.*for architecture //p' | sed 's:).*::' | sed 's:ppc7.*:ppc:' | tr '\n' ' '` jrarchs='' ## ok, we have Java archs, but R may not be available for all of those for a in ${jarchs}; do if test -e "${R_HOME}/lib/$a"; then jrarchs="${jrarchs} $a"; fi done ## if have have more than one arch, display info and add -arch flags if test -n "${jrarchs}"; then echo "*** building fat JNI with gcc for architectures: ${jrarchs} ***" echo "*** use FORCE_NATIVE=yes to avoid this and use R settings ***" CFLAGS="" LDFLAGS="" CC="gcc" for a in ${jrarchs}; do CC="${CC} -arch $a"; done fi fi fi ;; *) ;; esac origCFLAGS=$CFLAGS CFLAGS="${CFLAGS} ${R_CFLAGS} ${RINC}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Rinterface.h exports R_CStackXXX variables" >&5 printf %s "checking whether Rinterface.h exports R_CStackXXX variables... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define CSTACK_DEFNS #include #include int main(void) { return R_CStackLimit?0:1; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } DEFFLAGS="${DEFFLAGS} -DRIF_HAS_CSTACK" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Rinterface.h exports R_SignalHandlers" >&5 printf %s "checking whether Rinterface.h exports R_SignalHandlers... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { return R_SignalHandlers; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } DEFFLAGS="${DEFFLAGS} -DRIF_HAS_RSIGHAND" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext CFLAGS=${origCFLAGS} ac_config_files="$ac_config_files src/Makefile" ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files run" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 printf "%s\n" "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by JRI $as_me 0.3, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ JRI config.status 0.3 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" Copyright (C) 2021 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) printf "%s\n" "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) printf "%s\n" "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX printf "%s\n" "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "run") CONFIG_FILES="$CONFIG_FILES run" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 printf "%s\n" "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`printf "%s\n" "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac case $ac_file$ac_mode in "run":F) chmod +x run ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi rJava/configure.win0000644000175100001440000000265015133274032014036 0ustar hornikusers#!/bin/sh echo "Generate Windows-specific files (src/jvm-w32) ..." make -C src/jvm-w32 if [ $? != 0 ]; then exit 1 fi echo "Find Java..." # findjava honors JAVA_HOME environment variable, so we can safely overwite it if [ -e src/jvm-w32/findjava.exe ]; then JAVA_HOME=`src/jvm-w32/findjava -s -f` fi if [ x$JAVA_HOME = x ]; then echo "ERROR: cannot find Java Development Kit." >&2 echo " Please set JAVA_HOME to specify its location manually" >&2 exit 1 fi echo " JAVA_HOME=$JAVA_HOME" echo "JAVA_HOME:=$JAVA_HOME" > src/Makevars.java if [ -e jri/configure.win ]; then echo "=== Building JRI ===" CONFIGURED=1 export CONFIGURED if [ -z "${RHOME}" ]; then RHOME="${R_HOME}" fi R_HOME=${RHOME} export R_HOME export RHOME export JAVA_HOME cd jri sh configure.win make BR=$? cd .. if [ $BR = 0 ]; then echo "=== JRI built ===" mkdir -p inst/jri # also copy into R_ARCH is present to avoid overwriting different archs if [ -n "${R_ARCH}" ]; then mkdir -p inst/jri${R_ARCH} cp jri/src/jri.dll inst/jri${R_ARCH}/ fi # yet still install into JRI in case users get confused cp -r jri/run.bat jri/src/jri.dll jri/src/JRI.jar jri/examples inst/jri/ else echo "**** WARNING: JRI could NOT be built" >&2 if [ -z "$IGNORE" ]; then echo "Set IGNORE=1 if you want to build rJava anyway." exit 1 fi fi fi echo "Configuration done." rJava/R/0000755000175100001440000000000015133274032011534 5ustar hornikusersrJava/R/completion.R0000644000175100001440000000341615133274032014034 0ustar hornikusers# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: # S4 dispatch does not work for .DollarNames, so we'll use S3 # {{{ bring .DollarNames from the future if necessary if( !exists( ".DollarNames", envir = asNamespace("utils") ) ){ .DollarNames <- function(x, pattern) UseMethod(".DollarNames") } # }}} # {{{ support function to retrieve completion names from RJavaTools ### get completion names from RJavaTools classNamesMethod <- function (cl, static.only = TRUE ) { # TODO: return both from java instead of two java calls fieldnames <- .jcall( "RJavaTools", "[Ljava/lang/String;", "getFieldNames", cl, static.only ) methodnames <- .jcall( "RJavaTools", "[Ljava/lang/String;", "getMethodNames", cl, static.only ) c(fieldnames, methodnames) } # }}} # {{{ jclassName ._names_jclassName <- function(x){ c( "class", classNamesMethod(x@jobj, static.only = TRUE ) ) } .DollarNames.jclassName <- function(x, pattern = "" ){ grep( pattern, ._names_jclassName(x), value = TRUE ) } setMethod("names", c(x="jclassName"), ._names_jclassName ) # }}} # {{{ jobjRef ._names_jobjRef <- function(x){ classNamesMethod(.jcall(x, "Ljava/lang/Class;", "getClass"), static.only = FALSE ) } .DollarNames.jobjRef <- function(x, pattern = "" ){ grep( pattern, ._names_jobjRef(x), value = TRUE ) } setMethod("names", c(x="jobjRef"), ._names_jobjRef ) # }}} # {{{ jarrayRef and jrectRef ._names_jarrayRef <- function(x ){ c("length", classNamesMethod(.jcall(x, "Ljava/lang/Class;", "getClass"), static.only = FALSE ) ) } .DollarNames.jarrayRef <- .DollarNames.jrectRef <- function(x, pattern = ""){ grep( pattern, ._names_jarrayRef(x), value = TRUE ) } setMethod("names", c(x="jarrayRef"), ._names_jarrayRef ) setMethod("names", c(x="jrectRef"), ._names_jarrayRef ) # }}} rJava/R/gc.R0000644000175100001440000000022315133274032012245 0ustar hornikusers.jgc <- function(R.gc=TRUE, ...) { if (R.gc) gc(...) .jcall(.jcall("java.lang.Runtime","Ljava/lang/Runtime;","getRuntime"), "V", "gc") } rJava/R/exceptions.R0000644000175100001440000000176415133274032014050 0ustar hornikusers## functions for some basic exception handling # FIXME: should all these actually be deprecated or defunct ## poll for an exception .jgetEx <- function(clear=FALSE) { exo <- .Call(RpollException) if (is.null(exo)) return(NULL) x <- new("jobjRef", jobj=exo, jclass="java/lang/Throwable") if (clear) .jclear() x } ## explicitly clear any pending exceptions .jclear <- function() { .C(RclearException) invisible(NULL) } ## throw an exception .jthrow <- function(exception, message=NULL) { if (is.character(exception)) exception <- .jnew(exception, as.character(message)) if (is(exception, "jobjRef")) .Call(RthrowException, exception) else stop("Invalid exception.") } "$.Throwable" <- function( x, name ){ if( name %in% names(c(x)) ){ c(x)[[ name ]] } else{ ._jobjRef_dollar( x[["jobj"]], name ) } } "$<-.Throwable" <- function( x, name, value ){ if( name %in% names(x) ){ x[[ name ]] <- value } else{ ._jobjRef_dollargets( x[["jobj"]], name, value ) } x } rJava/R/0classes.R0000644000175100001440000000353415133274032013401 0ustar hornikusers## S4 classes (jobjRef is re-defined in .First.lib to contain valid jobj) #' java object reference setClass("jobjRef", representation(jobj="externalptr", jclass="character"), prototype=list(jobj=NULL, jclass="java/lang/Object")) #' rugged arrays setClass("jarrayRef", representation("jobjRef", jsig="character")) #' rectangular java arrays double[][] d = new double[m][n] setClass("jrectRef", representation("jarrayRef", dimension="integer" ) ) # we extend array here so that we can keep dimensions # in the helper functions below, the storage mode is # set when the objects are built # TODO: maybe an initialize method is needed here # TODO: maybe a validate method is needed here as well setClass("jfloat", representation("array" ) ) setClass("jlong", representation("array" ) ) setClass("jbyte", representation("array" ) ) setClass("jshort", representation("array" ) ) setClass("jchar", representation("array" ) ) # there is no way to distinguish between double and float in R, so we need to mark floats specifically .jfloat <- function(x) { storage.mode( x ) <- "double" new("jfloat", x ) } # the same applies to long .jlong <- function(x) { storage.mode( x ) <- "double" new("jlong", x) } # and byte .jbyte <- function(x) { storage.mode( x ) <- "integer" new("jbyte", x) } # and short .jshort <- function(x){ storage.mode( x ) <- "integer" new("jshort", x) } # and char (experimental) .jchar <- function(x){ if (is.character(x)) { if (length(x) != 1L || is.na(x)) stop(".jchar() supports only (non-NA) character vectors of length one (aka strings)") ## use Java to actually do the conversion x <- .jcall(.jnew("java.lang.String", x), "[C", "toCharArray") } storage.mode( x ) <- "integer" new("jchar", x) } rJava/R/arrays.R0000644000175100001440000006017515133274032013171 0ustar hornikusers# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: # {{{ utilities to deal with arrays #' Indicates if a object refers to a java array #' #' @param o object #' @return TRUE if the object is a java array, FALSE if not #' (including when the object is not even a java reference) isJavaArray <- function( o ){ if( ( is( o, "jobjRef" ) || is( o, "jarrayRef") || is( o, "jrectRef") ) && !is.jnull(o) ){ .jcall( "RJavaArrayTools", "Z", "isArray", .jcast(o) ) } else FALSE } ._must_be_java_array <- function( o, message = "object is not a java array" ){ if( !isJavaArray(o ) ){ stop( message ) } } isJavaArraySignature <- function( sig ){ identical( substr( sig, 1, 1 ), '[' ) } #' get the component type of a java array getComponentType <- function( o, check = TRUE ){ if( check ) ._must_be_java_array( o ) .jcall( .jcall( o, "Ljava/lang/Class;", "getClass" ), "Ljava/lang/Class;", "getComponentType" ) } ._jarray_simplify <- function( x ){ ._must_be_java_array( x ) clname <- .jclass(x, true = TRUE ) Array <- "java/lang/reflect/Array" obj <- switch( clname, # deal with array of primitive first "[I" = .Call(RgetIntArrayCont , x@jobj), "[J" = .Call(RgetLongArrayCont , x@jobj), "[Z" = .Call(RgetBoolArrayCont , x@jobj) , "[B" = .Call(RgetByteArrayCont , x@jobj) , "[D" = .Call(RgetDoubleArrayCont, x@jobj) , "[S" = .Call(RgetShortArrayCont , x@jobj) , "[C" = .Call(RgetCharArrayCont , x@jobj) , "[F" = .Call(RgetFloatArrayCont , x@jobj) , "[Ljava.lang.String;" = .Call(RgetStringArrayCont, x@jobj), # otherwise, just get the object x ) obj } # }}} # {{{ length #' get the length of the array ._length_java_array <- function(x){ if( isJavaArray( x ) ){ .jcall( "java/lang/reflect/Array", "I", "getLength", .jcast( x, check = FALSE, convert.array = FALSE) ) } else{ stop( "the supplied object is not a java array" ) } } setMethod( "length", "jarrayRef", ._length_java_array ) setMethod( "length", "jrectRef", ._length_java_array ) setGeneric( "str" ) setMethod("str", "jarrayRef", function(object, ...){ txt <- sprintf( "Formal class 'jarrayRef' [package \"rJava\"] with 2 slots ..@ jobj : ..@ jclass: chr \"%s\" ..@ jsig : chr \"%s\" ", object@jclass, object@jsig ) cat( txt ) } ) setMethod("str", "jrectRef", function(object, ...){ dim <- object@dimension dim.txt <- if( length( dim ) == 1L ){ sprintf( "int %d", dim ) } else { sprintf( "int[1:%d] %s", length(dim), paste( if( length(dim) > 6 ) c( dim[1:6], "...") else dim, collapse = " ") ) } txt <- sprintf( "Formal class 'jrectRef' [package \"rJava\"] with 2 slots ..@ jobj : ..@ jclass : chr \"%s\" ..@ jsig : chr \"%s\" ..@ dimension: %s ", object@jclass, object@jsig, dim.txt ) cat( txt ) } ) # }}} # {{{ single bracket indexing : [ # indexing of .jarrayRef # is is not quite clear what the proper result should be, because technically # [ should always return a jarrayRef, but it's not the most useful thing to do. # the code below (ab)uses drop to try to deal with that, but it's not optimal ... # ._jctype <- function(x) if (is.jnull(x)) NA else if(is(x, "jarrayRef")) x@jsig else paste("L", x@jclass, ";", sep='') # #' index a java array # #' # #' @param x a reference to a java array # #' @param i indexer (only 1D indexing supported so far) # #' @param drop if the result if of length 1, just return the java object instead of an array of length one # #' @param simplify further simplify the result # ._java_array_single_indexer <- function( x, i, j, drop, simplify = FALSE, silent = FALSE, ... ){ # # arrays only # # if( !silent ){ # if( ! missing( j ) ){ # warning( "only one dimensional indexing is currently supported in i, ignoring j argument" ) # } # dots <- list( ... ) # if( length(dots) ){ # unnamed.dots <- dots[ names(dots) == "" ] # if( length( unnamed.dots ) ){ # warning( "only one dimensional indexing is currently supported in [, ignoring ... arguments" ) # } # } # } # # # the component type of the array - maybe used to make # # arrays with the same component type, but of length 0 # component.type <- getComponentType( x, check = FALSE ) # # # 'eval' the array # ja <- .jevalArray( x ) # # # native type - use R subsetting and maybe remap to java # if (!is.list(ja)) { # # perform the subset # o <- ja[i] # # # return native type if simplify # if( simplify ){ # return(o) # } # # if( length(o) == 0L) { # # return an array of the same component type as the original array # # but of length 0 # return( .jcall( "java/lang/reflect/Array", "Ljava/lang/Object;", "newInstance", component.type, 0L ) ) # } else { # # drop makes no sense here # return( .jarray( o ) ) # } # } # # # the result an array of java objects # sl <- ja[i] # # if( length( sl ) == 0L ){ # # TODO: make simplify influencial here # # for example if x is int[] then we want to get integer(0) # return( .jcall( "java/lang/reflect/Array", "Ljava/lang/Object;", "newInstance", component.type, 0L ) ) # } else{ # # just return the array # return( .jarray( sl ) ) # } # } # ## this is all weird - we need to distinguish between x[i] and x[i,] yet S4 fails to do so ... setMethod( "[", signature( x = "jarrayRef" ), function(x, i, j, ..., drop = FALSE){ # the code above is not good enough .NotYetImplemented() } ) # }}} # {{{ double bracket indexing : [[ ._collectIndex <- function( i, j, ...){ dots <- list( ... ) unnamed.dots <- if( length( dots ) ){ dots[ names(dots) == "" ] } firstInteger <- function(.) as.integer(.)[1] firstIntegerOfEach <- function(.) sapply( ., firstInteger ) index <- c( if( !missing(i) ) firstInteger(i), if( !missing(j) ) firstInteger(j), if( !is.null(unnamed.dots) && length(unnamed.dots) ) firstIntegerOfEach( unnamed.dots ) ) } # R version of RJavaArrayTools#getDimensionLength # it only works on the signature so should be used with caution getDimensionLength <- function( x, true.class = TRUE ){ nchar( sub( "[^[]+", "", .jclass(x, true = true.class) ) ) } # R version of RJavaArrayTools#getObjectTypeName getObjectTypeName <- function( x, true.class=TRUE){ sub( "^[[]*(.*);?$", "\\1", .jclass(x, true = true.class) ) } ._java_array_double_indexer <- function( x, i, j, ..., evalArray = FALSE, evalString = FALSE ){ # initial checks ._must_be_java_array( x ) index <- ._collectIndex( i, j, ... ) if( !length(index) || is.null(index) ){ # return the full object x } else{ # shift one left (java style indexing starts from 0 ) index <- index - 1L depth <- getDimensionLength( x ) typename <- getObjectTypeName( x ) if( length( index) == depth ){ # we need to dispatch primitive if( isPrimitiveTypeName( typename ) ){ res <- switch( typename, # deal with array of primitive first "I" = .jcall( "RJavaArrayTools", "I", "getInt" , .jcast(x), index ) , "J" = .jcall( "RJavaArrayTools", "J", "getLong" , .jcast(x), index ) , "Z" = .jcall( "RJavaArrayTools", "Z", "getBoolean", .jcast(x), index ) , "B" = .jcall( "RJavaArrayTools", "B", "getByte" , .jcast(x), index ) , "D" = .jcall( "RJavaArrayTools", "D", "getDouble" , .jcast(x), index ) , "S" = .jcall( "RJavaArrayTools", "S", "getShort" , .jcast(x), index ) , "C" = .jcall( "RJavaArrayTools", "C", "getChar" , .jcast(x), index ) , "F" = .jcall( "RJavaArrayTools", "F", "getFloat" , .jcast(x), index ), stop( "wrong primitive" ) # should never happen ) return( res ) } } # otherwise use the Object version .jcall( "RJavaArrayTools", "Ljava/lang/Object;", "get", .jcast(x), index, evalArray = evalArray, evalString = evalString ) } } # this is the only case that makes sense: i is an integer or a numeric of length one # we cannot use logical indexing or indexing by name because there is no such thing in java setMethod( "[[", signature( x = "jarrayRef" ), function(x, i, j, ...){ ._java_array_double_indexer( x, i, j, ... ) } ) ._java_array_double_replacer <- function( x, i, j, ..., value ){ # initial checks ._must_be_java_array( x ) index <- ._collectIndex( i, j, ... ) if( !length(index) || is.null(index) ){ # allow for x[[]] <- value newArray( value , simplify = FALSE ) } else{ jvalue <- ._java_valid_object( value ) if( ._isPrimitiveReference( value ) ){ # then use a primitive version .jcall( "RJavaArrayTools", "V", "set", .jcast(x), index - 1L, value ) } else{ # use the Object version .jcall( "RJavaArrayTools", "V", "set", .jcast(x), index - 1L, .jcast( jvalue ) ) if( isJavaArray( jvalue ) ){ # rectangularity might have changed # we have no choice but to reset the array x <- newArray( jobj = x@jobj, signature = x@jsig ) } } x } } setReplaceMethod( "[[", signature( x = "jarrayRef" ), function(x, i, j, ..., value ){ ._java_array_double_replacer( x, i, j, ..., value = value) } ) # }}} # {{{ head and tail setGeneric( "head" ) setMethod("head", signature( x = "jarrayRef" ), function(x, n = 6L, ... ){ if( !isJavaArray( x ) ){ stop( "not a java array" ) } # FIXME : this only makes sense for 1d arays n_objs <- length(x) if( abs( n ) >= n_objs ){ return( x ) } len <- if( n > 0L ) n else n_objs + n x[seq_len(n), ... ] } ) setGeneric( "tail" ) setMethod("tail", signature( x = "jarrayRef" ), function(x, n = 6L, ... ){ if( !isJavaArray( x ) ){ stop( "not a java array" ) } # FIXME : this only makes sense for 1d arays n_objs <- length(x) if( abs( n ) >= n_objs ) return(x) if( n < 0L){ n <- n_objs + n } return( x[ seq.int( n_objs-n+1, n_objs ) , ... ] ) } ) # }}} # {{{ newArray - dispatch to jarrayRef or jrectRef #' creates a new jarrayRef or jrectRef depending on the rectangularity #' of the array #' #' @param o a jobjRef object #' @param simplify if TRUE and the result is a rectangular array #' of primitives, simplify it to an R object newArray <- function( o, simplify = TRUE, jobj, signature ){ if( !missing(jobj) ){ o <- new("jobjRef", jobj = jobj, jclass = signature) } if( !isJavaArray( o ) ){ stop( "o does not refer to a java array" ) } if( inherits( o, "jrectRef" ) ){ # no need to go further return(o) } clazz <- tojni( .jclass( o, true = TRUE ) ) wrapper <- .jnew("ArrayWrapper", .jcast(o) ) isRect <- .jcall( wrapper, "Z", "isRectangular" ) if( isRect ){ dims <- .jcall( wrapper, "[I", "getDimensions" ) if( !simplify ){ # no need to go further down, return a reference return( new( "jrectRef", jobj = o@jobj, jsig = clazz, jclass = clazz, dimension = dims ) ) } isprim <- .jcall( wrapper, "Z", "isPrimitive" ) typename <- .jcall( wrapper, "Ljava/lang/String;", "getObjectTypeName" ) isstrings <- identical( typename, "java.lang.String" ) if( !isprim && !isstrings ){ # cannot simplify, return a reference return( new( "jrectRef", jobj = o@jobj, jsig = clazz, jclass = clazz, dimension = dims ) ) } if( isprim || isstrings ){ # array of java primitives, we can translate this to R array out <- structure( switch( typename , "I" = .jcall( wrapper, "[I" , "flat_int" ), "Z" = .jcall( wrapper, "[Z" , "flat_boolean" ), "B" = .jcall( wrapper, "[B" , "flat_byte" ), "J" = .jlong( .jcall( wrapper, "[J" , "flat_long" ) ), "S" = .jshort( .jcall( wrapper, "[T" , "flat_short" ) ), # [T is remapped to [S in .jcall "D" = .jcall( wrapper, "[D" , "flat_double" ), "C" = .jchar( .jcall( wrapper, "[C" , "flat_char" ) ), "F" = .jfloat( .jcall( wrapper, "[F" , "flat_float" ) ), "java.lang.String" = .jcall( wrapper, "[Ljava/lang/String;", "flat_String" ), stop( sprintf("cannot simplify type : ", typename) ) # this should not happen ), dim = dims ) return( out ) } } else { # not a rectangular array -> jarrayRef new( "jarrayRef", jobj = o@jobj, jsig = clazz, jclass = clazz ) } } # }}} # {{{ [ indexing of rectangular arrays setMethod( "[", signature( x = "jrectRef" ), function(x, i, j, ..., simplify = FALSE, drop = TRUE ){ # first we extract th data as a flat (one dimensional) R array # called 'flat' dim <- x@dimension wrapper <- .jnew( "ArrayWrapper", .jcast(x) ) typename <- .jcall( wrapper, "Ljava/lang/String;", "getObjectTypeName" ) isprim <- .jcall( wrapper, "Z", "isPrimitive" ) flat <- switch( typename, "I" = .jcall( wrapper, "[I" , "flat_int" , evalArray = TRUE ), "Z" = .jcall( wrapper, "[Z" , "flat_boolean" , evalArray = TRUE ), "B" = .jcall( wrapper, "[B" , "flat_byte" , evalArray = TRUE ), "J" = .jcall( wrapper, "[J" , "flat_long" , evalArray = TRUE ), "S" = .jcall( wrapper, "[T" , "flat_short" , evalArray = TRUE ), # [T is remapped to [S in .jcall "D" = .jcall( wrapper, "[D" , "flat_double" , evalArray = TRUE ), "C" = .jcall( wrapper, "[C" , "flat_char" , evalArray = TRUE ) , "F" = .jcall( wrapper, "[F" , "flat_float" , evalArray = TRUE ), "java.lang.String" = .jcall( wrapper, "[Ljava/lang/String;" , "flat_String" , evalArray = TRUE ), .jcall( wrapper, "[Ljava/lang/Object;" , "flat_Object" , evalArray = TRUE ) ) # then we give to flat the correct dimensions if( length(dim) != 1L ){ dim( flat ) <- dim } # now we construct the call to '[' on flat. # this call uses all the regular R indexing call <- match.call( call = sys.call(sys.parent()) ) n.args <- nargs( ) e <- as.list( call )[ -(1:2) ] names.e <- names(e) if( any( have.name <- (names.e != "") ) ){ # we need to extract drop and simplify nam <- names.e[ have.name ] if( !all( nam %in% c("simplify", "drop", "i", "j" ) ) ){ stop( "only 'drop' and 'simplify' are allowed as named arguments, they need to be written exactly" ) } } if( missing(i) && missing(j) && all( names.e != "" ) ){ # special case with no indexing at all actual.call <- sprintf( "flat[ , drop = %s ]", as.character(drop) ) } else if( !missing(i) && missing(j) && all( names.e != "" ) ){ # special case where there is only one index actual.call <- sprintf( "flat[ %s , drop = %s ]", deparse(i), as.character(drop) ) } else{ # we need to be careful about the missing's # we cannot just do things like list(...) because with missings # it just does not work actual.call <- "flat[" itoken <- if( missing(i ) ) " " else deparse(i) jtoken <- if( missing(j ) ) " " else deparse(j) actual.call <- sprintf( "flat[ %s , %s", itoken, jtoken ) iii <- 1L for( a in e ){ if( missing(a) ){ actual.call <- sprintf( "%s , ", actual.call ) } else if( have.name[iii] ) { # we put both at the end } else { # not missing, not named actual.call <- sprintf( "%s, %s", actual.call, deparse(a) ) } iii <- iii + 1L } actual.call <- sprintf( "%s, drop = %s ]", actual.call, as.character(drop) ) } # now we eval the call subs <- eval( parse( text = actual.call ) ) # now if we need and can simplify it, we return the subsetted array as is # otherwise, we rewrap it to java if( simplify && (typename == "java.lang.String" || isprim ) ) subs else .jarray( subs, dispatch = TRUE ) } ) # }}} # {{{ dim.jrectRef setMethod( "dim", signature( x = "jrectRef" ), function(x) x@dimension ) setReplaceMethod( "dim", signature( x = "jrectRef" ), function(x, value){ expected_prod <- prod( x@dimension ) if( is.null( value ) ){ value <- expected_prod } else{ received_prod <- prod(value) if( received_prod != expected_prod ){ stop( sprintf("dims [product %d] do not match the length of object [%d]", received_prod, expected_prod ) ) } } dim <- x@dimension wrapper <- .jnew( "ArrayWrapper", .jcast(x) ) typename <- .jcall( wrapper, "Ljava/lang/String;", "getObjectTypeName" ) flat <- structure( switch( typename, "I" = .jcall( wrapper, "[I" , "flat_int" , evalArray = TRUE ), "Z" = .jcall( wrapper, "[Z" , "flat_boolean" , evalArray = TRUE ), "B" = .jcall( wrapper, "[B" , "flat_byte" , evalArray = TRUE ), "J" = .jcall( wrapper, "[J" , "flat_long" , evalArray = TRUE ), "S" = .jcall( wrapper, "[T" , "flat_short" , evalArray = TRUE ), # [T is remapped to [S in .jcall "D" = .jcall( wrapper, "[D" , "flat_double" , evalArray = TRUE ), "C" = .jcall( wrapper, "[C" , "flat_char" , evalArray = TRUE ) , "F" = .jcall( wrapper, "[F" , "flat_float" , evalArray = TRUE ), "java.lang.String" = .jcall( wrapper, "[Ljava/lang/String;" , "flat_String" , evalArray = TRUE ), .jcall( wrapper, "[Ljava/lang/Object;" , "flat_Object" , evalArray = TRUE ) ) , dim = value ) .jarray(flat, dispatch = TRUE) } ) # }}} PRIMITIVE_TYPES <- c( "I", "Z", "B", "J", "S", "D", "C", "F" ) isPrimitiveTypeName <- function( type, include.strings = TRUE ){ type %in% PRIMITIVE_TYPES || ( include.strings && identical( type, "java.lang.String" ) ) } PRIMITIVE_TYPES_RX <- sprintf( "^[[]+[%s]$" , paste( PRIMITIVE_TYPES, collapse = "" ) ) isPrimitiveArraySignature <- function( x, ... ){ regexpr( PRIMITIVE_TYPES_RX, x, ... ) > 0 } isArraySignature <- function( x ){ substr( x, 1, 1 ) == "[" } # {{{ unique.jarrayRef setGeneric( "unique" ) ._unique_jrectRef <- function( x, incomparables = FALSE, ...){ dim <- x@dimension if( length( dim ) > 1L ){ stop( "'unique' only implemented for 1d array so far" ) } typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ .jarray( unique( .jevalArray( x ) ), dispatch = TRUE ) } else{ .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "unique", .jcast( x, "[Ljava/lang/Object;" ), evalArray = TRUE, simplify = TRUE ) } } setMethod( "unique", "jarrayRef", function(x, incomparables = FALSE, ...){ .NotYetImplemented() } ) setMethod( "unique", "jrectRef", ._unique_jrectRef ) # }}} # {{{ duplicated setGeneric( "duplicated" ) ._duplicated_jrectRef <- function( x, incomparables = FALSE, ...){ dim <- x@dimension if( length( dim ) > 1L ){ stop( "'duplicated' only implemented for 1d array so far" ) } typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ duplicated( .jevalArray( x ) ) } else{ .jcall( "RJavaArrayTools", "[Z", "duplicated", .jcast( x, "[Ljava/lang/Object;" ), evalArray = TRUE ) } } setMethod( "duplicated", "jrectRef", ._duplicated_jrectRef ) setMethod( "duplicated", "jarrayRef", function( x, incomparables = FALSE, ...){ .NotYetImplemented() }) # }}} # {{{ anyDuplicated .base.has.anyDuplicated <- exists("anyDuplicated", asNamespace("base")) if (!.base.has.anyDuplicated) { anyDuplicated <- function(x, incomparables = FALSE, ...) UseMethod("anyDuplicated") } setGeneric( "anyDuplicated" ) ._anyduplicated_jrectRef <- function( x, incomparables = FALSE, ...){ dim <- x@dimension if( length( dim ) > 1L ){ stop( "'anyDuplicated' only implemented for 1d array so far" ) } typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ anyDuplicated( .jevalArray( x ) ) } else{ .jcall( "RJavaArrayTools", "I", "anyDuplicated", .jcast( x, "[Ljava/lang/Object;" ), evalArray = TRUE ) + 1L } } setMethod( "anyDuplicated", "jrectRef", ._anyduplicated_jrectRef ) setMethod( "anyDuplicated", "jarrayRef", function( x, incomparables = FALSE, ...){ .NotYetImplemented() }) # }}} # {{{ flat #' utility to flatten an array flat <- function(x, simplify = FALSE){ stop( "undefined" ) } setGeneric( "flat") ._flat_jrectRef <- function( x, simplify = FALSE ){ dim <- dim(x) if( length(dim) == 1L ) { if( !simplify) x else x[ simplify = TRUE ] } else { x[ seq_len(prod(dim)), drop = TRUE, simplify = simplify ] } } setMethod( "flat", "jrectRef", ._flat_jrectRef ) setMethod( "flat", "jarrayRef", function(x, simplify=FALSE){ .NotYetImplemented() } ) # }}} # {{{ sort setGeneric( "sort" ) ._sort_jrectRef <- function( x, decreasing = FALSE, ...){ x <- flat( x ) dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ .jarray( sort( .jevalArray( x ), decreasing = decreasing ), dispatch = TRUE ) } else{ .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "sort", .jcast( x, "[Ljava/lang/Object;" ), decreasing, evalArray = TRUE, simplify = TRUE ) } } setMethod( "sort", "jrectRef", ._sort_jrectRef ) setMethod( "sort", "jarrayRef", function(x, decreasing=FALSE, ...){ .NotYetImplemented() }) # }}} # {{{ rev setGeneric( "rev" ) setMethod( "rev", "jrectRef", function(x){ x <- flat( x ) dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ .jarray( rev( .jevalArray( x ) ), dispatch = TRUE ) } else{ .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "rev", .jcast( x, "[Ljava/lang/Object;" ), evalArray = TRUE, simplify = TRUE ) } } ) setMethod( "rev", "jarrayRef", function(x){ .NotYetImplemented() }) # }}} # {{{ as.list # S4 dispatch does not work as.list.jarrayRef <- function(x, ... ){ .jevalArray( x ) } as.list.jrectRef <- function( x, ...){ .jevalArray( x ) } as.list.jobjRef <- function( x, ... ){ if( ! .jinstanceof( x, "java.lang.Iterable" ) ){ stop( "only objects that implements java.lang.Iterable can be converted to lists" ) } .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "getIterableContent", .jcast(x, "java/lang/Iterable") , evalArray = TRUE, ... ) } # }}} # {{{ min, max, range setMethod("min", "jrectRef", function(x, ...,na.rm=TRUE){ dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ min( x[simplify=TRUE], na.rm = na.rm ) } else{ summarizer <- .jnew( "RectangularArraySummary", .jcast(x), dim ) .jcall( summarizer, "Ljava/lang/Object;", "min", na.rm ) } } ) setMethod("min", "jarrayRef", function(x, ...,na.rm=TRUE){ .NotYetImplemented() }) setMethod("max", "jrectRef", function(x, ..., na.rm=TRUE){ dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ max( x[simplify=TRUE], na.rm = na.rm ) } else{ summarizer <- .jnew( "RectangularArraySummary", .jcast(x), dim ) .jcall( summarizer, "Ljava/lang/Object;", "max", na.rm ) } } ) setMethod("max", "jarrayRef", function(x, ..., na.rm=TRUE){ .NotYetImplemented() } ) setMethod("range", "jrectRef", function(x, ..., na.rm=TRUE){ dim <- x@dimension typename <- .jcall( "RJavaArrayTools", "Ljava/lang/String;", "getObjectTypeName", .jcast(x) ) if( isPrimitiveTypeName( typename, include.strings = TRUE ) ){ range( x[simplify=TRUE], na.rm = na.rm ) } else{ summarizer <- .jnew( "RectangularArraySummary", .jcast(x), dim ) .jcall( summarizer, "[Ljava/lang/Object;", "range", na.rm, evalArray = TRUE, simplify = TRUE ) } } ) setMethod("range", "jarrayRef", function(x, ..., na.rm=TRUE){ .NotYetImplemented() }) # }}} rJava/R/serialize.R0000644000175100001440000000157215133274032013653 0ustar hornikusers## Java serialization/unserialization .jserialize <- function(o) { if (!is(o, "jobjRef")) stop("can serialize Java objects only") .jcall("RJavaClassLoader","[B","toByte",.jcast(o, "java.lang.Object")) } .junserialize <- function(data) { if (!is.raw(data)) stop("can de-serialize raw vectors only") o <- .jcall("RJavaClassLoader","Ljava/lang/Object;","toObjectPL",.jarray(data, dispatch = FALSE)) if (!is.jnull(o)) { cl<-try(.jclass(o), silent=TRUE) if (all(class(cl) == "character")) o@jclass <- gsub("\\.","/",cl) } o } .jcache <- function(o, update=TRUE) { if (!is(o, "jobjRef")) stop("o must be a Java object") if (!is.null(update) && (!is.logical(update) || length(update) != 1)) stop("update must be TRUE, FALSE of NULL") what <- update if (isTRUE(what)) what <- .jserialize(o) invisible(.Call(javaObjectCache, o@jobj, what)) } rJava/R/options.R0000644000175100001440000000044415133274032013354 0ustar hornikusers.joptions <- function(...) { l <- list(...) if (length(l)==0) return(list()) if ("jni.cache" %in% names(l)) { v <- l[["jni.cache"]] if (!is.logical(v) || length(v)!=1) stop("jni.cache must be a logical vector of length 1") .C(RuseJNICache,v) invisible(NULL) } } rJava/R/memprof.R0000644000175100001440000000020015133274032013314 0ustar hornikusers.jmemprof <- function(file = "-") { if (is.null(file)) file <- "" invisible(.Call(RJava_set_memprof, as.character(file))) } rJava/R/jinit.R0000644000175100001440000002600715133274032013001 0ustar hornikusers## This file is part of the rJava package - low-level R/Java interface ## (C)2006 Simon Urbanek ## For license terms see DESCRIPTION and/or LICENSE ## ## $Id$ .check.JVM <- function() .Call(RJava_checkJVM) .need.init <- function() .Call(RJava_needs_init) ## initialization .jinit <- function(classpath=NULL, parameters=getOption("java.parameters", NA), ..., silent=FALSE, force.init=FALSE) { running.classpath <- character() if (!.need.init()) { running.classpath <- .jclassPath() if (!force.init) { if (length(classpath)) { cpc <- unique(unlist(strsplit(classpath, .Platform$path.sep))) if (length(cpc)) .jaddClassPath(cpc) } return(0) } } # default JVM initialization parameters # Up until 1.0-12 jfirst (=onLoad) set java.parameters to -Xmx512m to increase the heap # size, so parameters was always -Xmx512m unless the user set java.parameters or parameters. # We now leave the java.parameters alone and only set the default heap size if # java.parameters is not set -- with mostly the same effect. # (NB: JVMs have changed the default from 256Mb to 25% of available memory in some cases, # thus the default is becoming less important nowadays.) # We also increase the default heap size since machines using R are unlikely # to be starved for RAM. Note that the meaning of NULL has changed to "none" # since 1.0-13. if (any(is.na(parameters))) parameters <- "-Xmx1g" if (is.null(parameters)) parameters <- character() ## determine path separator path.sep <- .Platform$path.sep if (!is.null(classpath)) { classpath <- as.character(classpath) if (length(classpath)) classpath <- paste(classpath,collapse=path.sep) } # merge CLASSPATH environment variable if present cp<-Sys.getenv("CLASSPATH") if (!is.null(cp)) { if (is.null(classpath)) classpath<-cp else classpath<-paste(classpath,cp,sep=path.sep) } # set rJava/java/boot for boostrap (so we can get RJavaClassLoader) boot.classpath <- file.path(.rJava.base.path,"java","boot") # if running in a sub-arch, append -Dr.arch in case someone gets the idea to start JRI if (is.character(.Platform$r_arch) && nzchar(.Platform$r_arch) && length(grep("-Dr.arch", parameters, fixed=TRUE)) == 0L) parameters <- c(paste("-Dr.arch=/", .Platform$r_arch, sep=''), as.character(parameters)) ## unfortunately Sys/setlocale()/Sys.getlocale() have incompatible interfaces so there ## is no good way to get/set locales -- so we have to hack around it ... locale.list <- c("LC_COLLATE", "LC_CTYPE", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LC_MESSAGES", "LC_PAPER", "LC_MEASUREMENT") ## RStudio on Windows crashes due to missing error handlers if locales ## are queried that Windows does not support so we remove those to work around it if (identical(.Platform$OS.type, "windows")) locale.list <- locale.list[-(6:8)] locales <- sapply(locale.list, Sys.getlocale) loc.sig <- Sys.getlocale() #cat(">> init CLASSPATH =",classpath,"\n") #cat(">> boot class path: ", boot.classpath,"\n") # call the corresponding C routine to initialize JVM xr <- .External(RinitJVM, boot.classpath, parameters) ## we have to re-set the locales right away suppressWarnings(try(if (!identical(Sys.getlocale(), loc.sig)) for (i in names(locales)) try(Sys.setlocale(i, locales[i]), silent=TRUE), silent=TRUE)) if (xr==-1) stop("Unable to initialize JVM.") if (xr==-2) stop("Another VM is already running and rJava was unable to attach to that VM.") # we'll handle xr==1 later because we need fully initialized rJava for that # this should remove any lingering .jclass objects from the global env # left there by previous versions of rJava pj <- grep("^\\.jclass",ls(1,all.names=TRUE),value=TRUE) if (length(pj)>0) { rm(list=pj,pos=1) if (exists(".jniInitialized",1)) rm(list=".jniInitialized",pos=1) if (!silent) warning("rJava found hidden Java objects in your workspace. Internal objects from previous versions of rJava were deleted. Please note that Java objects cannot be saved in the workspace.") } ##--- HACK-WARNING: we're operating directly on the namespace environment ## this could be dangerous. for (x in .delayed.variables) unlockBinding(x, .env) assign(".jniInitialized", TRUE, .env) # get cached class objects for reflection assign(".jclassObject", .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Object"), .env) assign(".jclassClass", .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.Class"), .env) assign(".jclassString", .jcall("java/lang/Class","Ljava/lang/Class;","forName","java.lang.String"), .env) assign(".jclass.int", .jfield("java/lang/Integer", "Ljava/lang/Class;", "TYPE"), .env) assign(".jclass.double", .jfield("java/lang/Double", "Ljava/lang/Class;", "TYPE"), .env) assign(".jclass.float", .jfield("java/lang/Float", "Ljava/lang/Class;", "TYPE"), .env) assign(".jclass.boolean", .jfield("java/lang/Boolean", "Ljava/lang/Class;", "TYPE"), .env) assign(".jclass.void", .jfield("java/lang/Void", "Ljava/lang/Class;", "TYPE"), .env) ## if NOAWT is set, set AWT to headless if (nzchar(Sys.getenv("NOAWT"))) .jcall("java/lang/System","S","setProperty","java.awt.headless","true") lib <- "libs" if (nchar(.Platform$r_arch)) lib <- file.path("libs", .Platform$r_arch) rjcl <- NULL if (xr==1) { # && nchar(classpath)>0) { # ok, so we're attached to some other JVM - now we need to make sure that # we can load our class loader. If we can't then we have to use our bad hack # to be able to squeeze our loader in # first, see if this is actually JRIBootstrap so we have a loader already rjcl <- .Call(RJava_primary_class_loader) if (is.null(rjcl) || .jidenticalRef(rjcl,.jzeroRef)) rjcl <- NULL else rjcl <- new("jobjRef", jobj=rjcl, jclass="RJavaClassLoader") if (is.jnull(rjcl)) rjcl <- .jnew("RJavaClassLoader", .rJava.base.path, file.path(.rJava.base.path, lib), check=FALSE) .jcheck(silent=TRUE) if (is.jnull(rjcl)) { ## it's a hack, so we run it in try(..) in case BadThings(TM) happen ... cpr <- try(.jmergeClassPath(boot.classpath), silent=TRUE) if (inherits(cpr, "try-error")) { .jcheck(silent=TRUE) if (!silent) warning("Another VM is running already and the VM did not allow me to append paths to the class path.") assign(".jinit.merge.error", cpr, .env) } if (length(parameters)>0 && any(parameters!=getOption("java.parameters")) && !silent) warning("Cannot set VM parameters, because VM is running already.") } } if (is.jnull(rjcl)) rjcl <- .jnew("RJavaClassLoader", .rJava.base.path, file.path(.rJava.base.path, lib), check=FALSE ) if (!is.jnull(rjcl)) { ## init class loader assign(".rJava.class.loader", rjcl, .env) ##-- set the class for native code .Call(RJava_set_class_loader, .env$.rJava.class.loader@jobj) ## now it's time to add any additional class paths cpc <- unique(strsplit(classpath, .Platform$path.sep)[[1]]) if (length(cpc)) .jaddClassPath(cpc) } else stop("Unable to create a Java class loader.") ##.Call(RJava_new_class_loader, .rJava.base.path, file.path(.rJava.base.path, lib)) ## lock namespace bindings for (x in .delayed.variables) lockBinding(x, .env) ## now we need to update the attached namespace (package env) as well m <- match(paste("package", getNamespaceName(.env), sep = ":"), search())[1] if (!is.na(m)) { ## only is it is attached pe <- as.environment(m) for (x in .delayed.export.variables) { unlockBinding(x, pe) pe[[x]] <- .env[[x]] lockBinding(x, pe) } } # FIXME: is this the best place or should this be done # internally right after the RJavaClassLoader is instantiated # init the cached RJavaTools class in the jni side .Call(initRJavaTools) # not yet # import( c( "java.lang", "java.util") ) invisible(xr) } # FIXME: this is not always true: osgi, eclipse etc use a different # class loader strategy, we should add some sort of hook to let people # define how they want this to be done .jmergeClassPath <- function(cp) { ccp <- .jcall("java/lang/System","S","getProperty","java.class.path") ccpc <- strsplit(ccp, .Platform$path.sep)[[1]] cpc <- strsplit(cp, .Platform$path.sep)[[1]] rcp <- unique(cpc[!(cpc %in% ccpc)]) if (length(rcp) > 0) { # the loader requires directories to include trailing slash # Windows: need / or \ ? (untested) dirs <- which(file.info(rcp)$isdir) for (i in dirs) if (substr(rcp[i],nchar(rcp[i]),nchar(rcp[i]))!=.Platform$file.sep) rcp[i]<-paste(rcp[i], .Platform$file.sep, sep='') ## this is a hack, really, that exploits the fact that the system class loader ## is in fact a subclass of URLClassLoader and it also subverts protection ## of the addURL class using reflection - yes, bad hack, but we use it ## only if the boot class path doesn't contain our own class loader so ## we cannot replace the system loader with our own (this will happen when we ## need to attach to an existing VM) ## The original discussion and code for this hack was at: ## http://forum.java.sun.com/thread.jspa?threadID=300557&start=15&tstart=0 ## it should probably be run in try(..) because chances are that it will ## break if Sun changes something... cl <- .jcall("java/lang/ClassLoader", "Ljava/lang/ClassLoader;", "getSystemClassLoader") urlc <- .jcall("java/lang/Class", "Ljava/lang/Class;", "forName", "java.net.URL") clc <- .jcall("java/lang/Class", "Ljava/lang/Class;", "forName", "java.net.URLClassLoader") ar <- .jcall("java/lang/reflect/Array", "Ljava/lang/Object;", "newInstance", .jclassClass, 1:1) .jcall("java/lang/reflect/Array", "V", "set", .jcast(ar, "java/lang/Object"), 0:0, .jcast(urlc, "java/lang/Object")) m<-.jcall(clc, "Ljava/lang/reflect/Method;", "getDeclaredMethod", "addURL", .jcast(ar,"[Ljava/lang/Class;")) .jcall(m, "V", "setAccessible", TRUE) ar <- .jcall("java/lang/reflect/Array", "Ljava/lang/Object;", "newInstance", .jclassObject, 1:1) for (fn in rcp) { f <- .jnew("java/io/File", fn) url <- .jcall(f, "Ljava/net/URL;", "toURL") .jcall("java/lang/reflect/Array", "V", "set", .jcast(ar, "java/lang/Object"), 0:0, .jcast(url, "java/lang/Object")) .jcall(m, "Ljava/lang/Object;", "invoke", .jcast(cl, "java/lang/Object"), .jcast(ar, "[Ljava/lang/Object;")) } # also adjust the java.class.path property to not confuse others if (length(ccp)>1 || (length(ccp)==1 && nchar(ccp[1])>0)) rcp <- c(ccp, rcp) acp <- paste(rcp, collapse=.Platform$path.sep) .jcall("java/lang/System","S","setProperty","java.class.path",as.character(acp)) } # if #rcp>0 invisible(.jcall("java/lang/System","S","getProperty","java.class.path")) } .jvmState <- function() .Call(RgetJVMstate) rJava/R/call.R0000644000175100001440000003510415133274032012575 0ustar hornikusers## This file is part of the rJava package - low-level R/Java interface ## (C)2006 Simon Urbanek ## For license terms see DESCRIPTION and/or LICENSE ## ## $Id$ # create a new object .jnew <- function(class, ..., check=TRUE, silent=!check, class.loader=NULL) { class <- gsub("\\.", "/", as.character(class)) # allow non-JNI specifiation # TODO: should this do "S" > "java/lang/String", ... like .jcall if (check) .jcheck(silent=TRUE) o<-.External(RcreateObject, class, ..., silent=silent, class.loader=class.loader) if (check) .jcheck(silent=silent) if (is.null(o)) { if (!silent) { stop("Failed to create object of class `",class,"'") } else { o <- .jzeroRef } } new("jobjRef", jobj=o, jclass=class) } # create a new object reference manually (avoid! for backward compat only!) # the problem with this is that you need a valid `jobj' which # is implementation-dependent so it is undefined outside rJava internals # it is now used by JRI.createRJavaRef, though .jmkref <- function(jobj, jclass="java/lang/Object") { new("jobjRef", jobj=jobj, jclass=gsub('\\.','/',as.character(jclass))) } # evaluates an array reference. If rawJNIRefSignature is set, then obj is not assumed to be # jarrayRef, but rather direct JNI reference with the corresponding signature .jevalArray <- function(obj, rawJNIRefSignature=NULL, silent=FALSE, simplify=FALSE) { jobj<-obj sig<-rawJNIRefSignature if (is.null(rawJNIRefSignature)) { if(!inherits(obj,"jarrayRef")) { if (!inherits(obj,"jobjRef")) stop("object is not a Java object reference (jobjRef/jarrayRef).") cl <- gsub("\\.","/",.jclass(obj)) if (is.null(cl) || !isJavaArraySignature(cl) ) stop("object is not a Java array.") sig <- cl } else sig <- obj@jsig jobj<-obj@jobj } else if (is(obj, "jobjRef")) jobj<-obj@jobj if (sig=="[I") return(.Call(RgetIntArrayCont, jobj)) else if (sig=="[J") return(.Call(RgetLongArrayCont, jobj)) else if (sig=="[Z") return(.Call(RgetBoolArrayCont, jobj)) else if (sig=="[B") return(.Call(RgetByteArrayCont, jobj)) else if (sig=="[D") return(.Call(RgetDoubleArrayCont, jobj)) else if (sig=="[S") return(.Call(RgetShortArrayCont, jobj)) else if (sig=="[C") return(.Call(RgetCharArrayCont, jobj)) else if (sig=="[F") return(.Call(RgetFloatArrayCont, jobj)) else if (sig=="[Ljava/lang/String;") return(.Call(RgetStringArrayCont, jobj)) else if (sig=="[Ljava/lang/Double;" && simplify) { obj@jclass <- sig; return(.jcall("RJavaArrayTools", "[D", "unboxDoubles", obj)) } else if (sig=="[Ljava/lang/Integer;" && simplify) { obj@jclass <- sig; return(.jcall("RJavaArrayTools", "[I", "unboxIntegers", obj)) } else if (sig=="[Ljava/lang/Boolean;" && simplify) { obj@jclass <- sig; return(as.logical(.jcall("RJavaArrayTools", "[I", "unboxBooleans", obj))) } else if (substr(sig,1,2)=="[L") return(lapply(.Call(RgetObjectArrayCont, jobj), function(x) new("jobjRef", jobj=x, jclass=substr(sig, 3, nchar(sig)-1)) )) else if (substr(sig,1,2)=="[[") { if (simplify) { # try to figure out if this is a rectangular array in which case we can do better o <- newArray(simplify=TRUE, jobj=jobj, signature=sig) # if o is not a reference then we were able to simplify it if (!is(o, "jobjRef")) return(o) } # otherwise simplify has no effect return(lapply(.Call(RgetObjectArrayCont, jobj), function(x) newArray(jobj=x, signature=substr(sig, 2, 999), simplify=simplify))) } # if we don't know how to evaluate this, issue a warning and return the jarrayRef if (!silent) warning(paste("I don't know how to evaluate an array with signature",sig,". Returning a reference.")) newArray(jobj = jobj, signature = sig, simplify = FALSE) } .jcall <- function(obj, returnSig="V", method, ..., evalArray=TRUE, evalString=TRUE, check=TRUE, interface="RcallMethod", simplify=FALSE, use.true.class = FALSE) { if (check) .jcheck() iaddr <- .env[[interface]] interface <- if (is.null(iaddr)) getNativeSymbolInfo(interface, "rJava", TRUE, FALSE)$address else iaddr r<-NULL # S is a shortcut for Ljava/lang/String; if (returnSig=="S") returnSig<-"Ljava/lang/String;" if (returnSig=="[S") returnSig<-"[Ljava/lang/String;" # original S (short) is now mapped to T so we need to re-map it (we don't really support short, though) if (returnSig=="T") returnSig <- "S" if (returnSig=="[T") returnSig <- "[S" if (inherits(obj,"jobjRef") || inherits(obj,"jarrayRef") || inherits(obj,"jrectRef") ) r<-.External(interface, obj@jobj, returnSig, method, ...) else r<-.External(interface, as.character(obj), returnSig, method, ...) if (returnSig=="V") return(invisible(NULL)) if( use.true.class && !is.null( r ) ){ if( ! ( isPrimitiveTypeName(returnSig) || isArraySignature(returnSig) ) ){ # avoid calling .jcall since we work on external pointers directly here clazz <- .External(interface, r , "Ljava/lang/Class;", "getClass") clazzname <- .External(interface, clazz, "Ljava/lang/String;", "getName") clazzname <- .External(RgetStringValue, clazzname) returnSig <- tojniSignature( clazzname ) } } if (isJavaArraySignature(returnSig)) { # eval or return a reference r <- if (evalArray) .jevalArray(r, rawJNIRefSignature=returnSig, simplify=simplify) else newArray(jobj = r, signature = returnSig, simplify = FALSE) } else if ( substr(returnSig,1,1)=="L") { if (is.null(r)){ if( check ) .jcheck( silent = FALSE ) return(r) } if (returnSig=="Ljava/lang/String;" && evalString){ if( check ) .jcheck( silent = FALSE ) return(.External(RgetStringValue, r)) } r <- new("jobjRef", jobj=r, jclass=substr(returnSig,2,nchar(returnSig)-1)) } if (check) .jcheck() if (.conv.in$.) .convert.in(r) else r } .jstrVal <- function(obj) { # .jstrVal(.jstrVal(...)) = .jstrVal(...) if (is.character(obj)) return(obj) r<-NULL if (!is(obj,"jobjRef")) stop("can get value of Java objects only") if (!is.null(obj@jclass) && obj@jclass=="lang/java/String") r<-.External(RgetStringValue, obj@jobj) else r<-.External(RtoString, obj@jobj) r } #' casts java object into new.class #' #' @param obj a java object reference #' @param new.class the new class (in JNI or Java) #' @param check logical. If TRUE the cast if checked #' @param convert.array logical. If TRUE and the new class represents an array, then a jarrayRef object is made .jcast <- function(obj, new.class="java/lang/Object", check = FALSE, convert.array = FALSE) { if (!is(obj,"jobjRef")) stop("cannot cast anything but Java objects") if( check && !.jinstanceof( obj, new.class) ){ stop( sprintf( "cannot cast object to '%s'", new.class ) ) } new.class <- gsub("\\.","/", as.character(new.class)) # allow non-JNI specifiation if( convert.array && !is( obj, "jarrayRef" ) && isJavaArray( obj ) ){ r <- .jcastToArray( obj, signature = new.class) } else { r <- obj r@jclass <- new.class } r } # makes sure that a given object is jarrayRef .jcastToArray <- function(obj, signature=NULL, class="", quiet=FALSE) { if (!is(obj, "jobjRef")) return(.jarray(obj)) if (is.null(signature)) { # TODO: factor out these two calls into a separate function cl <- .jcall(obj, "Ljava/lang/Class;", "getClass") cn <- .jcall(cl, "Ljava/lang/String;", "getName") if ( !isJavaArraySignature(cn) ) { if (quiet) return(obj) else stop("cannot cast to array, object signature is unknown and class name is not an array") } signature <- cn } else{ if( !isJavaArraySignature(signature) ){ if( quiet ) { return( obj ) } else{ stop( "cannot cast to array, signature is not an array signature" ) } } } signature <- gsub('\\.', '/', signature) if (inherits(obj, "jarrayRef")) { obj@jsig <- signature return(obj) } newArray(obj, simplify=FALSE) } # creates a new "null" object of the specified class # although it sounds weird, the class is important when passed as # a parameter (you can even cast the result) .jnull <- function(class="java/lang/Object") { new("jobjRef", jobj=.jzeroRef, jclass=as.character(class)) } .jcheck <- function(silent=FALSE) invisible(.Call(RJavaCheckExceptions, silent)) .jproperty <- function(key) { if (length(key)>1) sapply(key, .jproperty) else .jcall("java/lang/System", "S", "getProperty", as.character(key)[1]) } #' gets the dim of an array, or its length if it is just a vector getDim <- function(x){ dim <- dim(x) if( is.null( dim ) ) dim <- length(x) dim } .jarray <- function(x, contents.class = NULL, dispatch = FALSE) { # this already is an array, so don't bother if( isJavaArray( x ) ) return( newArray( x, simplify = FALSE) ) # this is a two stage process, first we need to convert into # a flat array using the jni code # TODO: but this needs to move to the internal jni world to avoid # too many copies # common mistake is to not specify a list but just a single Java object # but, well, people just keep doing it so we may as well support it dim <- if (inherits(x,"jobjRef")) { x <- list(x) 1L } else getDim(x) # the jni call array <- .Call(RcreateArray, x, contents.class) if (!dispatch) return( array ) if( is.list( x ) ){ # if the input of RcreateArray was a list, we need some more care # because we cannot be sure the array is rectangular so we have to # check it newArray( array, simplify = FALSE ) } else { # then we transform this to a rectangular array of the proper dimensions if( length( dim ) == 1L ) { # single dimension array new( "jrectRef", jobj = array@jobj, jsig = array@jsig, jclass = array@jclass, dimension = dim ) } else { builder <- .jnew( "RectangularArrayBuilder", .jcast(array), dim ) clazz <- .jcall( builder, "Ljava/lang/String;", "getArrayClassName" ) # we cannot use .jcall here since it will try to simplify the array # or go back to java to calculate its dimensions, ... r <- .External( RcallMethod, builder@jobj, "Ljava/lang/Object;", "getArray" ) new( "jrectRef", jobj = r, dimension = dim, jclass = clazz, jsig = tojni( clazz ) ) } } } # works on EXTPTR or jobjRef or NULL. NULL is always silently converted to .jzeroRef .jidenticalRef <- function(a,b) { if (is(a,"jobjRef")) a<-a@jobj if (is(b,"jobjRef")) b<-b@jobj if (is.null(a)) a <- .jzeroRef if (is.null(b)) b <- .jzeroRef if (!inherits(a,"externalptr") || !inherits(b,"externalptr")) stop("Invalid argument to .jidenticalRef, must be a pointer or jobjRef") .Call(RidenticalRef,a,b) } # returns TRUE only for NULL or jobjRef with jobj=0x0 is.jnull <- function(x) { (is.null(x) || (is(x,"jobjRef") && .jidenticalRef(x@jobj,.jzeroRef))) } # should we move this to C? .jclassRef <- function(x, silent=FALSE) { if (is.jnull(x)) { if (silent) return(NULL) else stop("null reference has no class") } if (!is(x, "jobjRef")) { if (silent) return(NULL) else stop("invalid object") } cl <- NULL try(cl <- .jcall(x, "Ljava/lang/Class;", "getClass", check=FALSE)) .jcheck(silent=TRUE) if (is.jnull(cl) && !silent) stop("cannot get class object") cl } # return class object for a given class name; silent determines whether # an error should be thrown on failure (FALSE) or just null reference (TRUE) .jfindClass <- function(cl, silent=FALSE, class.loader=.rJava.class.loader) { if (inherits(cl, "jclassName")) return(cl@jobj) if (!is.character(cl) || length(cl)!=1) stop("invalid class name") cl<-gsub("/",".",cl) a <- NULL if (!is.jnull(class.loader)) try(a <- .jcall("java/lang/Class","Ljava/lang/Class;","forName",cl,TRUE,.jcast(class.loader, "java.lang.ClassLoader"), check=FALSE)) else try(a <- .jcall("java/lang/Class","Ljava/lang/Class;","forName",cl,check=FALSE)) # this is really .jcheck but we don't want it to appear on the call stack .Call(RJavaCheckExceptions, silent) if (!silent && is.jnull(a)) stop("class not found") a } # Java-side inheritance check; NULL inherits from any class, because # it can be cast to any class type; cl can be a class name or a jobjRef to a class object .jinherits <- function(o, cl, class.loader=.rJava.class.loader) { if (is.jnull(o)) return(TRUE) if (!is(o, "jobjRef")) stop("invalid object") if (is.character(cl)) cl <- .jfindClass(cl, class.loader=class.loader) else if (inherits(cl, "jclassName")) cl <- cl@jobj if (!is(cl, "jobjRef")) stop("invalid class object") ocl <- .jclassRef(o) .Call(RisAssignableFrom, ocl@jobj, cl@jobj) } # compares two things which may be Java objects. invokes Object.equals if applicable and thus even different pointers can be equal. if one parameter is not Java object, but scalar string/int/number/boolean then a corresponding Java object is created for comparison # strict comparison returns FALSE if Java-reference is compared with non-reference. otherwise conversion into Java scalar object is attempted .jequals <- function(a, b, strict=FALSE) { if (is.null(a)) a <- new("jobjRef") if (is.null(b)) b <- new("jobjRef") if (is(a,"jobjRef")) o <- a else if (is(b,"jobjRef")) { o <- b; b <- a } else return(all.equal(a,b)) if (!is(b,"jobjRef")) { if (strict) return(FALSE) if (length(b)!=1) { warning("comparison of non-scalar values is always FALSE"); return(FALSE) } if (is.character(b)) b <- .jnew("java/lang/String",b) else if (is.integer(b)) b <- .jnew("java/lang/Integer",b) else if (is.numeric(b)) b <- .jnew("java/lang/Double",b) else if (is.logical(b)) b <- .jnew("java/lang/Boolean", b) else { warning("comparison of non-trivial values to Java objects is always FALSE"); return(FALSE) } } if (is.jnull(a)) is.jnull(b) else .jcall(o, "Z", "equals", .jcast(b, "java/lang/Object")) } .jfield <- function(o, sig=NULL, name, true.class=is.null(sig), convert=TRUE) { if (length(sig)) { if (sig=='S') sig<-"Ljava/lang/String;" if (sig=='T') sig<-"S" if (sig=='[S') sig<-"[Ljava/lang/String;" if (sig=='[T') sig<-"[S" } r <- .Call(RgetField, o, sig, as.character(name), as.integer(true.class)) if (inherits(r, "jobjRef")) { if (isJavaArraySignature(r@jclass)) { r <- if (convert) .jevalArray(r, rawJNIRefSignature=r@jclass, simplify=TRUE) else newArray(r, simplify=FALSE) } if (convert && inherits(r, "jobjRef")) { if (r@jclass == "java/lang/String") return(.External(RgetStringValue, r@jobj)) if (.conv.in$.) return(.convert.in(r)) } } r } ".jfield<-" <- function(o, name, value) .Call(RsetField, o, name, value) rJava/R/J.R0000644000175100001440000000347315133274032012057 0ustar hornikuserssetClass("jclassName", representation(name="character", jobj="jobjRef")) jclassName <- function(class, class.loader=.rJava.class.loader) { if (.need.init()) .jinit() if( is( class, "jobjRef" ) && .jinherits(class, "java/lang/Class" ) ){ jobj <- class name <- .jcall( class, "Ljava/lang/String;", "getName", evalString = TRUE ) } else{ name <- gsub("/",".",as.character(class)) jobj <- .jfindClass(as.character(class), class.loader=class.loader) } new("jclassName", name=name, jobj=jobj) } setGeneric("new") setMethod("new", signature(Class="jclassName"), function(Class, ...) .J(Class, ...)) ## FIXME: this is not quite right - it looks at static method/fields only, ## but that prevents things like x = J("foo"); x$equals(x) from working ## while x$class$equals(x) works. setMethod("$", c(x="jclassName"), function(x, name) { if( name == "class" ){ x@jobj } else if (classHasField(x@jobj, name, TRUE)){ .jfield(x, , name) } else if (classHasMethod(x@jobj, name, TRUE)){ function(...) .jrcall(x, name, ...) } else if( classHasClass(x@jobj, name, FALSE) ){ inner.cl <- .jcall( "RJavaTools", "Ljava/lang/Class;", "getClass", x@jobj, name, FALSE ) new("jclassName", name=.jcall(inner.cl, "S", "getName"), jobj=inner.cl) } else { stop("no static field, method or inner class called `", name, "' in `", x@name, "'") } }) setMethod("$<-", c(x="jclassName"), function(x, name, value) .jfield(x, name) <- value) setMethod("show", c(object="jclassName"), function(object) invisible(show(paste("Java-Class-Name:",object@name)))) setMethod("as.character", c(x="jclassName"), function(x, ...) x@name) ## the magic `J' J<-function(class, method, ..., class.loader=.rJava.class.loader) if (nargs() <= 2L && missing(method)) jclassName(class, class.loader=class.loader) else .jrcall(class, method, ..., class.loader=class.loader) rJava/R/jri.R0000644000175100001440000000671415133274032012453 0ustar hornikusers## bindings into JRI ## warning: JRI REXP class has currently no finalizers! (RReleaseREXP must be used manually for now) ## warning: this produces JRI-API pbjects - that should go away! use toJava below .r2j <- function(x, engine = NULL, convert = TRUE) { if (is.null(engine)) engine <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine") if (!is(engine, "jobjRef")) stop("invalid or non-existent engine") new("jobjRef",jobj=.Call(PushToREXP,"org/rosuda/JRI/REXP",engine@jobj,engine@jclass,x,convert),jclass="org/rosuda/JRI/REXP") } toJava <- function(x, engine = NULL) { ## this is really the wrong place for all this REngine checking stuff, but so far .jengine uses JRI API only and legacy code may rely on that ## so this is the only place that assumes REngine API and thus will load it ... ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE) if (is.jnull(ec)) { .jcheck(TRUE) stop("JRI is not loaded. Please start JRI first - see ?.jengine") } ec <- .jfindClass("org.rosuda.REngine.REngine", silent=TRUE) if (is.jnull(ec)) { .jcheck(TRUE) fn <- system.file("jri","REngine.jar",package="rJava") if (nzchar(fn)) .jaddClassPath(fn) fn <- system.file("jri","JRIEngine.jar",package="rJava") if (nzchar(fn)) .jaddClassPath(fn) ec <- .jfindClass("org.rosuda.REngine.REngine", silent=TRUE) if (is.jnull(ec)) { .jcheck(TRUE) stop("Cannot find REngine API classes. Please make sure you have installed and loaded the REngine API") } } if (is.null(engine)) engine <- .jcall("org/rosuda/REngine/REngine","Lorg/rosuda/REngine/REngine;","getLastEngine") if (is.jnull(engine)) { # no last engine, but there may be JRI engine already running ... me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE) .jcheck(TRUE) if (is.jnull(me)) stop("JRI is not running. Please start JRI first - see ?.jengine") engine <- .jnew("org/rosuda/REngine/JRI/JRIEngine", me) .jcheck(TRUE) } .jcheck(TRUE) if (!is(engine, "jobjRef")) stop("invalid or non-existent engine") new("jobjRef",jobj=.Call(PushToREXP,"org/rosuda/REngine/REXPReference",engine@jobj,"org/rosuda/REngine/REngine",x,NULL),jclass="org/rosuda/REngine/REXPReference") } .setupJRI <- function(new=TRUE) { ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE) if (is.jnull(ec)) { .jcheck(TRUE) .jaddClassPath(system.file("jri","JRI.jar",package="rJava")) ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE) .jcheck(TRUE) if (is.jnull(ec)) stop("Cannot find JRI classes") } me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE) .jcheck(TRUE) if (!is.jnull(me)) { if (!new) return(TRUE) warning("JRI engine is already running.") return(FALSE) } e <- .jnew("org/rosuda/JRI/Rengine") !is.jnull(e) } .jengine <- function(start=FALSE, silent=FALSE) { me <- NULL ec <- .jfindClass("org.rosuda.JRI.Rengine", silent=TRUE) .jcheck(TRUE) if (!is.jnull(ec)) { me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE) .jcheck(TRUE) } if (is.jnull(me)) { if (!start) { if (silent) return(NULL) stop("JRI engine is not running.") } .setupJRI(FALSE) me <- .jcall("org/rosuda/JRI/Rengine","Lorg/rosuda/JRI/Rengine;","getMainEngine", check=FALSE) .jcheck(TRUE) } if (is.jnull(me) && !silent) stop("JRI engine is not running.") me } rJava/R/import.R0000644000175100001440000000731515133274032013177 0ustar hornikusers IMPORTER <- ".__rjava__import" java_class_importers <- new.env() assign( ".namespaces", NULL, envir = java_class_importers ) getImporterFromNamespace <- function( nm, create = TRUE ){ .namespaces <- get(".namespaces", envir = java_class_importers ) if( !is.null( .namespaces ) ){ for( item in .namespaces ){ if( identical( item$nm, nm ) ){ return( item$importer ) } } } if( create ){ addImporterNamespace(nm) } } addImporterNamespace <- function( nm ){ importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) ) assign( ".namespaces", append( list( list( nm = nm, importer = importer ) ), get(".namespaces", envir = java_class_importers ) ), envir = java_class_importers ) importer } getImporterFromEnvironment <- function(env, create = TRUE){ if( isNamespace( env ) ){ getImporterFromNamespace( env ) } else if( exists(IMPORTER, envir = env ) ){ get( IMPORTER, envir = env ) } else if( create ){ addImporterNamespace(env) } } getImporterFromGlobalEnv <- function( ){ if( exists( "global", envir = java_class_importers ) ){ get( "global", envir = java_class_importers ) } else{ initGlobalEnvImporter() } } initGlobalEnvImporter <- function(){ importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) ) assign( "global", importer , envir = java_class_importers ) importer } import <- function( package = "java.util", env = sys.frame(sys.parent()) ){ if( missing(env) ){ caller <- sys.function(-1) env <- environment( caller ) if( isNamespace( env ) ){ importer <- getImporterFromNamespace( env ) } } else{ force(env) if( !is.environment( env ) ){ stop( "env is not an environment" ) } if( ! exists( IMPORTER, env ) || is.jnull( get( IMPORTER, envir = env ) ) ){ importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) ) if( isNamespace(env) ){ unlockBinding( IMPORTER, env = env ) assignInNamespace( IMPORTER, importer, envir = env ) } assign( IMPORTER, importer, envir = env ) } else{ importer <- get( IMPORTER, envir = env ) } } mustbe.importer( importer ) .jcall( importer, "V", "importPackage", package ) } is.importer <- function(x){ is( x, "jobjRef" ) && .jinherits( x, "RJavaImport" ) } mustbe.importer <- function(x){ if( !is.importer(x) ){ stop( "object not a suitable java package importer" ) } } #' collect importers getAvailableImporters <- function( frames = TRUE, namespace = TRUE, global = TRUE, caller = sys.function(-1L) ){ importers <- .jnew( "java/util/HashSet" ) addImporter <- function( importer ){ if( is.importer( importer ) ){ .jcall( importers, "Z", "add", .jcast(importer) ) } } if( isTRUE( global ) ){ addImporter( getImporterFromGlobalEnv() ) } if( isTRUE( frames ) ){ frames <- sys.frames() if( length(frames) > 1L ){ sapply( head( frames, -1L ), function(env) { if( !identical( env, .GlobalEnv ) ){ addImporter( getImporterFromEnvironment( env ) ) } } ) } } if( isTRUE( namespace ) ){ force(caller) env <- environment( caller ) if( isNamespace( env ) ){ addImporter( getImporterFromNamespace( env ) ) } } importers } #' lookup for a class name in the available importers lookup <- function( name = "Object", ..., caller = sys.function(-1L) ){ force(caller) importers <- getAvailableImporters(..., caller = caller) .jcall( "RJavaImport", "Ljava/lang/Class;", "lookup", name, .jcast( importers, "java/util/Set" ) ) } javaImport <- function( packages = "java.lang" ){ importer <- .jnew( "RJavaImport", .jcast( .rJava.class.loader, "java/lang/ClassLoader" ) ) .jcall( importer, "V", "importPackage", packages ) .Call( newRJavaLookupTable , importer ) } rJava/R/loader.R0000644000175100001440000000600715133274032013130 0ustar hornikusers.jaddClassPath <- function(path, class.loader=.rJava.class.loader) { if (!length(path)) return(invisible(NULL)) if (!is.jnull(class.loader)) invisible(.jcall(class.loader, "V", "addClassPath", as.character(path))) else { cpr <- try(.jmergeClassPath(paste(path, collapse=.Platform$path.sep)), silent=TRUE) invisible(!inherits(cpr, "try-error")) } } .jclassPath <- function(class.loader=.rJava.class.loader) { if (is.jnull(class.loader)) { cp <- .jcall("java/lang/System", "S", "getProperty", "java.class.path") unlist(strsplit(cp, .Platform$path.sep)) } else { .jcall(class.loader,"[Ljava/lang/String;","getClassPath") } } .jaddLibrary <- function(name, path, class.loader=.rJava.class.loader) { if (!is.jnull(class.loader)) invisible(.jcall(class.loader, "V", "addRLibrary", as.character(name)[1], as.character(path)[1])) } .jrmLibrary <- function(name) { ## FIXME: unimplemented } .jclassLoader <- function(package=NULL) { if (!is.null(package)) { loader <- asNamespace(package)$.rJava.class.loader if (!is.jnull(loader)) return(loader) } .rJava.class.loader } .jpackage <- function(name, jars='*', morePaths='', nativeLibrary=FALSE, lib.loc=NULL, parameters=getOption("java.parameters"), own.loader=FALSE) { if (!.jniInitialized) .jinit(parameters=parameters) loader <- .rJava.class.loader if (isTRUE(own.loader)) { lib <- "libs" if (nchar(.Platform$r_arch)) lib <- file.path("libs", .Platform$r_arch) ns <- asNamespace(name) loader <- ns$.rJava.class.loader <- .jnew("RJavaClassLoader", .rJava.base.path, file.path(.rJava.base.path, lib), .rJava.class.loader, check = FALSE) } classes <- system.file("java", package=name, lib.loc=lib.loc) if (nchar(classes)) { .jaddClassPath(classes, class.loader=loader) if (length(jars)) { if (length(jars) == 1 && jars == '*') { jars <- grep(".*\\.jar", list.files(classes, full.names=TRUE), TRUE, value=TRUE) if (length(jars)) .jaddClassPath(jars, class.loader=loader) } else .jaddClassPath(paste(classes, jars, sep=.Platform$file.sep), class.loader=loader) } } if (any(nchar(morePaths))) { cl <- as.character(morePaths) cl <- cl[nchar(cl)>0] .jaddClassPath(cl, class.loader=loader) } if (is.logical(nativeLibrary)) { if (nativeLibrary) { libs <- "libs" if (nchar(.Platform$r_arch)) lib <- file.path("libs", .Platform$r_arch) lib <- system.file(libs, paste(name, .Platform$dynlib.ext, sep=''), package=name, lib.loc=lib.loc) if (nchar(lib)) .jaddLibrary(name, lib, class.loader=loader) else warning("Native library for `",name,"' could not be found.") } } else { .jaddLibrary(name, nativeLibrary, class.loader=loader) } invisible(TRUE) } rJava/R/instanceof.R0000644000175100001440000000117015133274032014007 0ustar hornikusers`%instanceof%` <- .jinstanceof <- function( o, cl ){ if( !inherits( o, "jobjRef" ) ){ stop( "o is not a java object" ) } # first get the class object that represents cl if( inherits( cl, "jobjRef" ) ){ if( .jclass( cl ) == "java.lang.Class" ){ clazz <- cl } else { clazz <- .jcall( cl, "Ljava/lang/Class;", "getClass" ) } } else if( inherits( cl, "jclassName" ) ) { clazz <- cl@jobj } else if( inherits( cl, "character" ) ){ clazz <- .jfindClass(cl) } else { return(FALSE) } # then find out if o is an instance of the class .jcall( clazz , "Z", "isInstance", .jcast(o, "java/lang/Object" ) ) } rJava/R/tools.R0000644000175100001440000000121115133274032013012 0ustar hornikusers#' converts a java class name to jni notation tojni <- function( cl = "java.lang.Object" ){ gsub( "[.]", "/", cl ) } tojniSignature <- function( cl ){ sig <- tojni( cl ) if( isPrimitiveTypeName(sig) || isPrimitiveArraySignature(sig) ){ return( sig ) } n <- nchar( sig ) last <- substr( sig, n, n ) add.semi <- last != ";" first <- substr( sig, 1, 1 ) add.L <- ! first %in% c("L", "[" ) sig <- if( !add.L && !add.semi) sig else sprintf( "%s%s%s", if( add.L ) "L" else "", sig, if( add.semi ) ";" else "" ) sig } #' converts jni notation to java notation tojava <- function( cl = "java/lang/Object" ){ gsub( "/", ".", cl ) } rJava/R/methods.R0000644000175100001440000000204615133274032013324 0ustar hornikusers## methods for jobjRef class ## ## additional methods ($ and $<-) are defined in reflection.R # show method # FIXME: this should show the class of the object instead of Java-Object setMethod("show", c(object="jobjRef"), function(object) { if (is.jnull(object)) show("Java-Object") else show(paste("Java-Object{", .jstrVal(object), "}", sep='')) invisible(NULL) }) setMethod("show", c(object="jarrayRef"), function(object) { show(paste("Java-Array-Object",object@jsig,":", .jstrVal(object), sep='')) invisible(NULL) }) # map R comparison operators to .jequals setMethod("==", c(e1="jobjRef",e2="jobjRef"), function(e1,e2) .jequals(e1,e2)) setMethod("==", c(e1="jobjRef"), function(e1,e2) .jequals(e1,e2)) setMethod("==", c(e2="jobjRef"), function(e1,e2) .jequals(e1,e2)) setMethod("!=", c(e1="jobjRef",e2="jobjRef"), function(e1,e2) !.jequals(e1,e2)) setMethod("!=", c(e1="jobjRef"), function(e1,e2) !.jequals(e1,e2)) setMethod("!=", c(e2="jobjRef"), function(e1,e2) !.jequals(e1,e2)) # other operators such as <,> are defined in comparison.R rJava/R/converter.R0000644000175100001440000000175315133274032013674 0ustar hornikusers# in: Java -> R .conv.in <- new.env(parent=emptyenv()) .conv.in$. <- FALSE # out: R -> Java .conv.out <- new.env(parent=emptyenv()) .conv.out$. <- FALSE # --- internal fns .convert.in <- function(jobj, verify.class=TRUE) { jcl <- if (verify.class) .jclass(jobj) else gsub("/",".",jobj@jclass) cv <- .conv.in[[jcl]] if (!is.null(cv)) jobj else cv$fn(jobj) } .convert.out <- function(robj) { for (cl in class(robj)) { cv <- .conv.out[[cl]] if (!is.null(cv)) return(cv$fn(robj)) } robj } # external fns .jsetJConvertor <- function(java.class, fn) { if (is.null(fn)) { rm(list=java.class, envir=.conv.in) if (!length(ls(.conv.in))) .conv.in$. <- FALSE } else { .conv.in$. <- TRUE .conv.in[[java.class]] <- list(fn=fn) } } .jsetRConvertor <- function(r.class, fn) { if (is.null(fn)) { rm(list=r.class, envir=.conv.out) if (!length(ls(.conv.out))) .conv.out$. <- FALSE } else { .conv.out$. <- TRUE .conv.out[[r.class]] <- list(fn=fn) } } rJava/R/rep.R0000644000175100001440000000160315133274032012445 0ustar hornikusers# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: # {{{ rep setGeneric("rep") setMethod( "rep", "jobjRef", function( x, times = 1L, ... ){ .jcall( "RJavaArrayTools", "[Ljava/lang/Object;", "rep", .jcast(x), as.integer(times), evalArray = FALSE ) } ) setMethod( "rep", "jarrayRef", function(x, times = 1L, ...){ .NotYetImplemented() } ) setMethod( "rep", "jrectRef", function(x, times = 1L, ...){ .NotYetImplemented() } ) # }}} # {{{ clone clone <- function( x, ... ){ UseMethod( "clone" ) } clone.default <- function( x, ... ){ .NotYetImplemented() } setGeneric( "clone" ) setMethod( "clone", "jobjRef", function(x, ...){ .jcall( "RJavaArrayTools", "Ljava/lang/Object;", "cloneObject", .jcast( x ) ) } ) setMethod( "clone", "jarrayRef", function(x, ...){ .NotYetImplemented( ) } ) setMethod( "clone", "jrectRef", function(x, ...){ .NotYetImplemented( ) } ) # }}} rJava/R/windows/0000755000175100001440000000000015133274032013226 5ustar hornikusersrJava/R/windows/FirstLib.R0000755000175100001440000000657615133274032015110 0ustar hornikusers.msg <- message .onLoad <- function(libname, pkgname) { OPATH <- Sys.getenv("PATH") javahome <- if (!is.null(getOption("java.home"))) getOption("java.home") else Sys.getenv("JAVA_HOME") if (nzchar(javahome) && !dir.exists(javahome)) { .msg("java.home option: ", getOption("java.home")) .msg("JAVA_HOME environment variable: ", Sys.getenv("JAVA_HOME")) warning("Java home setting is INVALID, it will be ignored.\nPlease do NOT set it unless you want to override system settings.") javahome <- "" } if(!nzchar(javahome)) { ## JAVA_HOME was not set explicitly find.java <- function() { for (root in c("HLM", "HCU")) for(key in c( "Software\\JavaSoft\\JRE", "Software\\JavaSoft\\JDK", "Software\\JavaSoft\\Java Runtime Environment", "Software\\JavaSoft\\Java Development Kit" )) { hive <- try(utils::readRegistry(key, root, 2), silent=TRUE) if (!inherits(hive, "try-error")) return(hive) } hive } hive <- find.java() if (inherits(hive, "try-error")) stop("JAVA_HOME cannot be determined from the Registry") if (!length(hive$CurrentVersion)) stop("No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.") this <- hive[[hive$CurrentVersion]] javahome <- this$JavaHome paths <- if (is.character(this$RuntimeLib)) dirname(this$RuntimeLib) else character() # wrong on 64-bit } else paths <- character() if(is.null(javahome) || !length(javahome) || !nchar(javahome)) stop("JAVA_HOME is not set and could not be determined from the registry") #else cat("using JAVA_HOME =", javahome, "\n") ## we need to add Java-related library paths to PATH curPath <- OPATH paths <- c(paths, file.path(javahome, "bin", "client"), # 32-bit file.path(javahome, "bin", "server"), # 64-bit file.path(javahome, "bin"), # base (now needed for MSVCRT in recent Sun Java) file.path(javahome, "jre", "bin", "server"), # old 64-bit (or manual JAVA_HOME setting to JDK) file.path(javahome, "jre", "bin", "client")) # old 32-bit (or manual JAVA_HOME setting to JDK) cpc <- strsplit(curPath, ";", fixed=TRUE)[[1]] ## split it up so we can check presence/absence of a path ## add paths only if they are not in already and they exist for (path in unique(paths)) if (!path %in% cpc && file.exists(path)) curPath <- paste(path, curPath, sep=";") ## set PATH only if it's not correct already (cannot use identical/isTRUE because of PATH name attribute) if (curPath != OPATH) { Sys.setenv(PATH = curPath) # check the resulting PATH - if they don't match then Windows has truncated it if (curPath != Sys.getenv("PATH")) warning("*** WARNING: your Windows system seems to suffer from truncated PATH bug which will likely prevent rJava from loading.\n Either reduce your PATH or read http://support.microsoft.com/kb/906469 on how to fix your system.") } library.dynam("rJava", pkgname, libname) Sys.setenv(PATH = OPATH) .jfirst(libname, pkgname) } rJava/R/with.R0000644000175100001440000001226615133274032012641 0ustar hornikusers## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## ## Author: Romain Francois ._populate_with_fields_and_methods <- function( env, fields, methods, classes, data, only.static = FALSE ){ object <- if( only.static ) .jnull() else .jcast( data ) # fields if( !is.jnull(fields) ) { lapply( fields, function(x ){ n <- .jcall( x, "S", "getName" ) type <- .jcall( .jcall( x, "Ljava/lang/Class;", "getType"), "Ljava/lang/String;" , "getName" ) suffix <- switch( type, "boolean" = "Boolean", "byte" = "Byte", "char" = "Char", "double" = "Double", "float" = "Float", "int" = "Int", "long" = "Long", "short" = "Short", "" ) target <- switch( type, "boolean" = "Z", "byte" = "B", "char" = "C", "double" = "D", "float" = "F", "int" = "I", "long" = "L", "short" = "S", "Ljava/lang/Object;" ) set_method <- sprintf( "set%s", suffix) get_method <- sprintf( "get%s", suffix ) makeActiveBinding( n, function(v){ if( missing(v) ){ ## get .jcall( x, target, get_method, object ) } else { ## set .jcall( x, "V", set_method , object, v ) } }, env ) } ) } # methods if( !is.jnull(methods) ){ done.this <- NULL lapply( methods, function(m){ n <- .jcall( m, "S", "getName" ) if( n %in% done.this ) return() fallback <- tryCatch( match.fun( n ), error = function(e) NULL ) assign( n, function(...) { tryCatch( .jrcall( if(only.static) data@name else data , n, ...), error = function(e){ if( !is.null(fallback) && inherits(fallback, "function") ){ fallback( ... ) } } ) }, env ) done.this <<- c( done.this, n ) } ) } # classes if( !is.jnull( classes ) ){ lapply( classes, function( cl ){ name <- .jcall( cl, "S", "getSimpleName" ) assign( name, new("jclassName", name=.jcall(cl, "S", "getName"), jobj=cl), env ) } ) } } grabDots <- function( env, ...){ dots <- list(...) if( length( dots ) ){ dots.names <- names(dots) sapply( dots.names, function( name ){ if( name != "" ){ assign( name, dots[[ name ]], env ) } } ) } } with.jobjRef <- function( data, expr, ...){ env <- new.env( parent = parent.frame() ) clazz <- .jcall( data, "Ljava/lang/Class;", "getClass") fields <- .jcall( clazz, "[Ljava/lang/reflect/Field;", "getFields" ) methods <- .jcall( clazz, "[Ljava/lang/reflect/Method;", "getMethods" ) classes <- .jcall( clazz, "[Ljava/lang/Class;" , "getClasses" ) ._populate_with_fields_and_methods( env, fields, methods, classes, data, only.static = FALSE ) assign( "this", data, env ) grabDots( env, ... ) eval( substitute( expr ), env ) } within.jobjRef <- function(data, expr, ... ){ call <- match.call() call[[1]] <- as.name("with.jobjRef") eval( call, parent.frame() ) data } with.jarrayRef <- function( data, expr, ...){ env <- new.env( parent = environment() ) clazz <- .jcall( data, "Ljava/lang/Class;", "getClass") fields <- .jcall( clazz, "[Ljava/lang/reflect/Field;", "getFields" ) methods <- .jcall( clazz, "[Ljava/lang/reflect/Method;", "getMethods" ) classes <- .jcall( clazz, "[Ljava/lang/Class;" , "getClasses" ) ._populate_with_fields_and_methods( env, fields, methods, classes, data, only.static = FALSE ) assign( "this", data, env ) # add "length" pseudo field makeActiveBinding( "length", function(v){ if( missing( v ) ){ ._length_java_array( data ) } else{ stop( "cannot modify length of java array" ) } }, env ) grabDots( env, ... ) eval( substitute( expr ), env ) } within.jarrayRef <- function(data, expr, ... ){ call <- match.call() call[[1]] <- as.name("with.jarrayRef") eval( call, parent.frame() ) data } with.jclassName <- function( data, expr, ... ){ env <- new.env( parent = environment() ) clazz <- data@jobj static_fields <- .jcall( "RJavaTools", "[Ljava/lang/reflect/Field;", "getStaticFields", clazz ) static_methods <- .jcall( "RJavaTools", "[Ljava/lang/reflect/Method;", "getStaticMethods", clazz ) static_classes <- .jcall( clazz, "[Ljava/lang/Class;", "getClasses" ) ._populate_with_fields_and_methods( env, static_fields, static_methods, static_classes, data, only.static = TRUE ) grabDots( env, ... ) eval( substitute( expr ), env ) } within.jclassName <- function(data, expr, ... ){ call <- match.call() call[[1]] <- as.name("with.jclassName") eval( call, parent.frame() ) data } rJava/R/reflection.R0000644000175100001440000002770415133274032014023 0ustar hornikusers### reflection functions - convenience function relying on the low-level ### functions .jcall/.jnew and friends ### reflection tools (inofficial so far, because it returns strings ### instead of the reflection objects - it's useful for quick checks, ### though) .jmethods <- function(o, name=NULL, as.obj=FALSE, class.loader=.rJava.class.loader) { cl <- if (is(o, "jobjRef")) .jcall(o, "Ljava/lang/Class;", "getClass") else if (is(o, "jclassName")) o@jobj else .jfindClass(as.character(o), class.loader=class.loader) ms<-.jcall(cl,"[Ljava/lang/reflect/Method;","getMethods") if (length(name)) { n <- sapply(ms, function(o) .jcall(o, "S", "getName")) ms <- ms[grep(name, n)] } if (isTRUE(as.obj)) ms else unlist(lapply(ms,function(x) .jcall(x,"S","toString"))) } .jconstructors <- function(o, as.obj=FALSE, class.loader=.rJava.class.loader) { cl <- if (is(o, "jobjRef")) .jcall(o, "Ljava/lang/Class;", "getClass") else if (is(o, "jclassName")) o@jobj else .jfindClass(as.character(o), class.loader=class.loader) cs<-.jcall(cl,"[Ljava/lang/reflect/Constructor;","getConstructors") if (isTRUE(as.obj)) return(cs) unlist(lapply(cs,function(x) .jcall(x,"S","toString"))) } ### this list maps R class names to Java class names for which the constructor does the necessary conversion (for use in .jrcall) ### The order matters in case an object inherits from multiple (S3) classes - then the first one ### in the list is picked. .class.to.jclass <- c( jlong = "java/lang/Long", jchar = "java/lang/Character", jshort = "java/lang/Short", jfloat = "java/lang/Float", jbyte = "java/lang/Byte", integer = "java/lang/Integer", numeric = "java/lang/Double", logical = "java/lang/Boolean", character= "java/lang/String" ) ### Java classes that have a corresponding primitive type and thus a corresponding TYPE field to use with scalars .primitive.classes = c("java/lang/Byte", "java/lang/Integer", "java/lang/Double", "java/lang/Boolean", "java/lang/Long", "java/lang/Character", "java/lang/Short", "java/lang/Float") ### creates a valid java object ### if a is already a java object reference, all is good ### otherwise some primitive conversion occurs # this is used for internal purposes only, in particular # it does not dispatch arrays to jrectRef ._java_valid_object <- function(a) { if (is(a, "jobjRef")) a else if (is(a, "jclassName")) a@jobj else if (is.null(a)) .jnull() else if (is.raw(a)) .jarray(a, dispatch=FALSE) ## raw is always [B else { ## check all classes (in S3 case, see #317) cm <- match(class(a), names(.class.to.jclass)) if (!all(is.na(cm))) { ## at least one subclass matches cm <- min(cm, na.rm=TRUE) ## pick the lowest (i.e. in precedence of the order above) ## scalar? then create directly if (length(a) == 1) { y <- .jnew(.class.to.jclass[cm], a) if (.class.to.jclass[cm] %in% .primitive.classes) attr(y, "primitive") <- TRUE y } else .jarray(a, dispatch = FALSE) } else { stop("Sorry, parameter type `", class(a)[1] ,"' is ambiguous or not supported.") } } } ### creates a list of valid java parameters, used in both .J and .jrcall ._java_valid_objects_list <- function( ... ) lapply(list(...), ._java_valid_object ) ### returns a list of Class objects ### this is used in both .J and .jrcall ._isPrimitiveReference <- function(x) isTRUE(attr(x, "primitive")) ._java_class <- function( x ){ ## FIXME: not sure how to pass though the class loader here - only affects NULL objects if (is.jnull(x)) { if (is(x,"jobjRef")) .jfindClass(x@jclass) else .jclassObject } else { if (._isPrimitiveReference(x)) .jfield(x, "Ljava/lang/Class;", "TYPE") else .jcall(x, "Ljava/lang/Class;", "getClass") } } ._java_class_list <- function( objects_list ) lapply(objects_list, ._java_class ) ### reflected call - this high-level call uses reflection to call a method ### it is much less efficient than .jcall but doesn't require return type ### specification or exact matching of parameter types .jrcall <- function(o, method, ..., simplify=TRUE, class.loader=.rJava.class.loader) { if (!is.character(method) | length(method) != 1) stop("Invalid method name - must be exactly one character string.") if (.need.init()) .jinit() if (is(o, "jclassName")) cl <- o@jobj else if (is(o, "jobjRef")) cl <- .jcall(o, "Ljava/lang/Class;", "getClass") else cl <- .jfindClass(o, class.loader=class.loader) if (is.jnull(cl)) stop("Cannot find class of the object.") # p is a list of parameters that are formed solely by valid Java objects p <- ._java_valid_objects_list(...) # list of classes pc <- ._java_class_list( p ) # invoke the method directly from the RJavaTools class # ( this throws the actual exception instead of an InvocationTargetException ) j_p <- .jarray(p, "java/lang/Object" , dispatch = FALSE ) j_pc <- .jarray(pc, "java/lang/Class" , dispatch = FALSE ) r <- .jcall( "RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, .jcast(if(inherits(o,"jobjRef") || inherits(o, "jarrayRef")) o else cl, "java/lang/Object"), .jnew( "java/lang/String", method), j_p, j_pc, use.true.class = TRUE, evalString = simplify, evalArray = FALSE ) # null is returned when the return type of the method is void # TODO[romain]: not sure how to distinguish when the result is null but the # return type is not null if( is.jnull( r ) || is.null(r) ){ return( invisible( NULL ) ) } # simplify if needed and return the object if( is(r, "jarrayRef" ) && simplify ){ ._jarray_simplify( r ) } else if (simplify){ .jsimplify(r) } else { r } } ### reflected construction of java objects ### This uses reflection to call a suitable constructor based ### on the classes of the ... it does not require exact match between ### the objects and the constructor parameters ### This is to .jnew what .jrcall is to .jcall .J <- function(class, ..., class.loader=.rJava.class.loader) { ## if it is a name, load the class, otherwise assume we have the object if (is.character(class)) { ## allow non-JNI specifiation class <- gsub("\\.","/",class) class <- .jfindClass(class, class.loader=class.loader) } else if (is(class, "jclassName")) { class <- class@jobj } # p is a list of parameters that are formed solely by valid Java objects p <- ._java_valid_objects_list(...) # list of classes pc <- ._java_class_list( p ) # use RJavaTools to find create the object o <- .jcall("RJavaTools", "Ljava/lang/Object;", "newInstance", class, .jarray(p,"java/lang/Object", dispatch = FALSE ), .jarray(pc,"java/lang/Class", dispatch = FALSE ), evalString = FALSE, evalArray = FALSE, use.true.class = TRUE ) o } ## make sure Java's -2147483648 .iNA <- function(o, convert=TRUE) if(convert && is.na(o)) -2147483648.0 else o ### simplify non-scalar reference to a scalar object if possible .jsimplify <- function(o, promote=FALSE) { if (!inherits(o, "jobjRef") && !inherits(o, "jarrayRef")) return(o) cn <- .jclass(o, true=TRUE) if (cn == "java.lang.Boolean") .jcall(o, "Z", "booleanValue") else if (cn == "java.lang.Integer" || cn == "java.lang.Short" || cn == "java.lang.Character" || cn == "java.lang.Byte") .iNA(.jcall(o, "I", "intValue"), promote) else if (cn == "java.lang.Number" || cn == "java.lang.Double" || cn == "java.lang.Long" || cn == "java.lang.Float") .jcall(o, "D", "doubleValue") else if (cn == "java.lang.String") .jstrVal(.jcast(o, "java/lang/String")) else o } #! ### get the value of a field (static class fields are not supported yet) #! .jrfield <- function(o, name, simplify=TRUE, true.class=TRUE) { #! if (!inherits(o, "jobjRef") && !inherits(o, "jarrayRef") && !is.character(o)) #! stop("Object must be a Java reference or class name.") #! if (is.character(o)) { #! cl <- .jfindClass(o) #! .jcheck(silent=TRUE) #! if (is.null(cl)) #! stop("class not found") #! o <- .jnull() #! } else { #! cl <- .jcall(o, "Ljava/lang/Class;", "getClass") #! o <- .jcast(o, "java/lang/Object") #! } #! f <- .jcall(cl, "Ljava/lang/reflect/Field;", "getField", name) #! r <- .jcall(f,"Ljava/lang/Object;","get",o) #! if (simplify) r <- .jsimplify(r) #! if (true.class && (inherits(r, "jobjRef") || inherits(r, "jarrayRef"))) { #! cl <- .jcall(r, "Ljava/lang/Class;", "getClass") #! cn <- .jcall(cl, "Ljava/lang/String;", "getName") #! if (substr(cn,1,1) != '[') #! r@jclass <- gsub("\\.","/",cn) #! } #! r #! } ### list the fields of a class or object .jfields <- function(o, name=NULL, as.obj=FALSE, class.loader=.rJava.class.loader) { cl <- if (is(o, "jobjRef")) .jcall(o, "Ljava/lang/Class;", "getClass") else if (is(o, "jclassName")) o@jobj else .jfindClass(as.character(o), class.loader=class.loader) f <- .jcall(cl, "[Ljava/lang/reflect/Field;", "getFields") if (length(name)) { n <- sapply(f, function(o) .jcall(o, "S", "getName")) f <- f[grep(name, n)] } if (isTRUE(as.obj)) f else unlist(lapply(f, function(x) .jcall(x, "S", "toString"))) } ._must_be_character_of_length_one <- function(name){ if( !is.character(name) || length(name) != 1L ){ stop( "'name' must be a character vector of length one" ) } } ### checks if the java object x has a field called name hasField <- function( x, name ){ ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "hasField", .jcast( x, "java/lang/Object" ), name) } hasJavaMethod <- function( x, name ){ ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "hasMethod", .jcast( x, "java/lang/Object" ), name) } hasClass <- function( x, name){ ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "hasClass", .jcast( x, "java/lang/Object" ), name) } ### the following ones are needed for the static version of $ classHasField <- function(x, name, static=FALSE, class.loader=.rJava.class.loader) { if (is(x, "jclassName")) x <- x@jobj else if (!is(x, "jobjRef")) x <- .jfindClass(as.character(x), class.loader=class.loader) ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "classHasField", x, name, static) } classHasMethod <- function(x, name, static=FALSE, class.loader=.rJava.class.loader) { if (is(x, "jclassName")) x <- x@jobj else if (!is(x, "jobjRef")) x <- .jfindClass(as.character(x), class.loader=class.loader) ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "classHasMethod", x, name, static) } classHasClass <- function(x, name, static=FALSE, class.loader=.rJava.class.loader) { if (is(x, "jclassName")) x <- x@jobj else if (!is(x, "jobjRef")) x <- .jfindClass(as.character(x), class.loader=class.loader) ._must_be_character_of_length_one(name) .jcall("RJavaTools", "Z", "classHasClass", x, name, static) } ### syntactic sugar to allow object$field and object$methods(...) ### first attempts to find a field of that name and then a method ._jobjRef_dollar <- function(x, name) { if (hasField(x, name) ){ .jfield(x, , name) } else if( hasJavaMethod( x, name ) ) { function(...) .jrcall(x, name, ...) } else if( hasClass(x, name) ) { cl <- .jcall( x, "Ljava/lang/Class;", "getClass" ) inner.cl <- .jcall( "RJavaTools", "Ljava/lang/Class;", "getClass", cl, name, FALSE ) new("jclassName", name=.jcall(inner.cl, "S", "getName"), jobj=inner.cl) } else if( is.character(name) && length(name) == 1L && name == "length" && isJavaArray(x) ){ length( x ) } else { stop( sprintf( "no field, method or inner class called '%s' ", name ) ) } } setMethod("$", c(x="jobjRef"), ._jobjRef_dollar ) ### support for object$field<-... ._jobjRef_dollargets <- function(x, name, value) { if( hasField( x, name ) ){ .jfield(x, name) <- value } x } setMethod("$<-", c(x="jobjRef"), ._jobjRef_dollargets ) # get a class name for an object .jclass <- function(o, true=TRUE) { if (true) .jcall(.jcall(o, "Ljava/lang/Class;", "getClass"), "S", "getName") else if( inherits( o, "jarrayRef" ) ) o@jsig else o@jclass } rJava/R/comparison.R0000644000175100001440000000320515133274032014031 0ustar hornikusers #' if a and b are compatable, #' in the sense of the java.util.Comparable interface #' then the result of the compareTo method is returned #' otherwise an error message is generated .jcompare <- function(a, b) { if (is.null(a)) a <- new("jobjRef") if (is.null(b)) b <- new("jobjRef") if( isJavaArray(a) || isJavaArray(b) ){ stop( "comparison (<,>,<=,>=) is not implemented for java arrays yet" ) } if( !is(a, "jobjRef" ) ) a <- ._java_valid_object( a ) if( !is(b, "jobjRef" ) ) b <- ._java_valid_object( b ) .jcall( "RJavaComparator", "I", "compare", .jcast(a), .jcast(b) ) } ._lower <- function(e1, e2){ .jcompare( e1, e2 ) <= 0L } ._greater <- function(e1, e2 ){ .jcompare( e1, e2 ) >= 0L } ._strictly_lower <- function(e1, e2 ){ .jcompare( e1, e2 ) < 0L } ._strictly_greater <- function(e1, e2 ){ .jcompare( e1, e2 ) > 0L } setMethod("<" , c(e1="jobjRef",e2="jobjRef"), ._strictly_lower ) setMethod("<" , c(e1="jobjRef") , ._strictly_lower ) setMethod("<" , c(e2="jobjRef") , ._strictly_lower ) setMethod(">" , c(e1="jobjRef",e2="jobjRef"), ._strictly_greater ) setMethod(">" , c(e1="jobjRef") , ._strictly_greater ) setMethod(">" , c(e2="jobjRef") , ._strictly_greater ) setMethod("<=", c(e1="jobjRef",e2="jobjRef"), ._lower ) setMethod("<=", c(e1="jobjRef") , ._lower ) setMethod("<=", c(e2="jobjRef") , ._lower ) setMethod(">=", c(e1="jobjRef",e2="jobjRef"), ._greater ) setMethod(">=", c(e1="jobjRef") , ._greater ) setMethod(">=", c(e2="jobjRef") , ._greater ) rJava/R/zzz.R.in0000644000175100001440000000524215133274032013124 0ustar hornikusers.onLoad <- function(libname, pkgname) { ## we can skip all the detection logic if forced - assuming the user has loaded JVM already if (!nzchar(Sys.getenv("RJAVA_FORCE_LOAD"))) { ## On OS X with Oracle Java we may need to work around Oracle bug: ## https://bugs.openjdk.java.net/browse/JDK-7131356 use.dynload <- FALSE @USE_DYNLOAD_TRUE@use.dynload <- TRUE if (length(grep("^darwin", R.version$os))) { jh <- Sys.getenv("JAVA_HOME") if (nzchar(jh) && !dir.exists(jh)) { warning("JAVA_HOME is set incorrectly! Ingoring.") jh <- "" } if (!nzchar(jh) && file.exists("/usr/libexec/java_home")) jh <- system("/usr/libexec/java_home", intern=TRUE)[1L] if (!nzchar(jh)) { if (use.dynload) stop("Cannot find Java. Install Java run-time and use R CMD javareconf.\nAs a last resort you can set JAVA_HOME appropriately.") warning("Cannot find Java. Install Java run-time and use R CMD javareconf.\nAs a last resort you can set JAVA_HOME if you know the correct value.") } if (file.exists(file.path(jh, "jre/lib"))) jh <- file.path(jh, "jre") dlp <- Sys.getenv("DYLD_LIBRARY_PATH") if (nzchar(dlp)) dlp <- paste0(":", dlp) ## pre-load JLI due to Oracle bug if (file.exists(jli <- file.path(jh, "lib/jli/libjli.dylib"))) dyn.load(jli, FALSE) ## this is mandatory - we need the JVM if (file.exists(jvm <- file.path(jh, "lib/server/libjvm.dylib"))) { dyn.load(jvm, FALSE) Sys.setenv(DYLD_LIBRARY_PATH=paste0(file.path(jh, "lib/server"), dlp)) } else { warning("Cannot find JVM library '", jvm, "'\nInstall Java and/or check JAVA_HOME (if in doubt, do NOT set it, it will be detected)") if (use.dynload) stop("JVM could not be found") } } else if (use.dynload) { jh <- Sys.getenv("JAVA_HOME") if (nzchar(jh) && !dir.exists(jh)) { warning("JAVA_HOME is set incorrectly! Ingoring.") jh <- "" } if (!nzchar(jh)) stop("JAVA_HOME is requied for dynamically loaded JVM, but is not set.\nRe-run R CMD javareconf or set JAVA_HOME correctly.") if (file.exists(file.path(jh, "jre/lib"))) jh <- file.path(jh, "jre") if (!file.exists(jvm <- file.path(jh, "lib/server/libjvm.so"))) stop("Cannot find ", jvm,", re-configure R or use valid JAVA_HOME") dyn.load(jvm, FALSE) } } ## RJAVA_FORCE_LOAD library.dynam("rJava", pkgname, libname) # pass on to the system-independent part .jfirst(libname, pkgname) } rJava/R/jfirst.R0000644000175100001440000000532715133274032013167 0ustar hornikusers# this part is common to all platforms and must be invoked # from .First.lib after library.dynam # actual namespace environment of this package .env <- environment() # variables in the rJava environment that will be initialized *after* the package is loaded # they need to be pre-created at load time and populated later by .jinit .delayed.export.variables <- c(".jniInitialized", ".jclassObject", ".jclassString", ".jclassClass", ".jclass.int", ".jclass.double", ".jclass.float", ".jclass.boolean", ".jclass.void", ".jinit.merge.error") # variables that are delayed but not exported are added here .delayed.variables <- c(.delayed.export.variables, ".rJava.class.loader") # C entry points to register .register.addr <- c( # .Call "PushToREXP", "RJava_checkJVM", "RJava_needs_init", "RJava_new_class_loader", "RJava_primary_class_loader", "RJava_set_class_loader", "RJava_set_memprof", "RJavaCheckExceptions", "RcreateArray", "RgetBoolArrayCont", "RgetByteArrayCont", "RgetCharArrayCont", "RgetDoubleArrayCont", "RgetField", "RgetFloatArrayCont", "RgetIntArrayCont", "RgetLongArrayCont", "RgetNullReference", "RgetObjectArrayCont", "RgetShortArrayCont", "RgetStringArrayCont", "RidenticalRef", "RgetSimpleClassNames", "RisAssignableFrom", "RpollException", "RsetField", "RthrowException", "javaObjectCache", "initRJavaTools", "newRJavaLookupTable", "useDynamicSymbols", "RgetJVMstate", # .External "RcreateObject", "RgetStringValue", "RinitJVM", "RtoString", "RcallMethod", # .C "RclearException", "RuseJNICache" ) .jfirst <- function(libname, pkgname) { # register all C entry points addr <- getNativeSymbolInfo(.register.addr, pkgname) for (name in .register.addr) .env[[name]] <- addr[[name]]$address # disable symbol lookup from now on - if there is an error # in native calls from now on, it means a symbol has not # been added to the list above .Call(useDynamicSymbols, FALSE) assign(".rJava.base.path", paste(libname, pkgname, sep=.Platform$file.sep), .env) assign(".jzeroRef", .Call(RgetNullReference), .env) for (x in .delayed.variables) assign(x, NULL, .env) assign(".jniInitialized", FALSE, .env) ## S4 classes update - all classes are created earlier in classes.R, but jobjRef's prototype is only valid after the dylib is loaded setClass("jobjRef", representation(jobj="externalptr", jclass="character"), prototype=list(jobj=.jzeroRef, jclass="java/lang/Object"), where=.env) } rJava/NEWS0000644000175100001440000007446115133274032012046 0ustar hornikusers NEWS/ChangeLog for rJava -------------------------- 1.0-14 2026-01-19 o Minor changes to replace EXTPTR macros with API calls globally. o Added Authors@R and ORCID. o Add some protection fixes. 1.0-13 2025-05-12 o The default Java parameters have changed from -Xmx512m to -Xmx1g and will be only set by .jinit() if the java.parameters option is not set (and no parameters are specified). (#341) Previously, the java.parameters option would be set on load (if not present), now it is not changed by rJava at all and left to the user. o .jinit() interprets parameters=NA as "use rJava default" (see above) and NULL is a shorthand for character(). 1.0-12 2024-01-26 o Win32: minor changes to adapt to (undocumented) API changes in R 4.2.0. o Win32: warn if R_HOME path is too long. o dispatch on superclasses when converting native types in the reflection API (J/.jrcall). Please note that it is safer to use the native API than to rely on reflection conversions so packages are encouraged to use the native API which is much faster and type-safe. (#317) o remove JavaDoc from the distribution tar ball due to security issues (#303). Note that JavaDoc can be generated from the source package by running `make javadoc` in the `src/java` directory. o bugfix: .jarray(..., dispatch=TRUE) was generating nested arrays with incorrect content if the input array had more than two dimensions. (#5) o the IGNORE env var was misspelled in configure.win. (#304) 1.0-10 2023-11-30 o minor documentation fixes o fix format specifier in an error message 1.0-9 2023-11-28 o clean up benign C warnings 1.0-8 2022-12-30 o attempt to prevent (close to) infinite loop in stack detection due to unwanted tail call optimization by gcc >= 11 if JDK older than Java 10 is used. (#300) 1.0-7 2022-04-29 o fix conversion from native encoding into UTF-16 (introduced in 1.0-2) to work correctly if the native encoding is neither UTF-8 nor Latin1. (#228) o debugging: if DEBUG_ENCODING C macro is defined string conversion routines will output debugging information when strings are converted between R and Java. o JRI: console callbacks (Read/WriteConsole) encode and decode strings between native encoding and Java. (#24) Previously, only UTF-8 native locales were supported. o Replaced deprected constructors like new Double(double) with valueOf() calls to make recent JDKs happy. o Work around a crash in RStudio on UCRT Windows. (#296) o add .jvmState() reporting the state of the JVM. (#259) 1.0-6 2021-12-10 o remove obsolete autoconf macros o JRI 0.5-7 changes: - add support for JRI_CPPFLAGS and JRI_LIBS variables which allow specific flag overrides in JRI only - use config.h in jri.h (except for Windows) - add header checks needed for R_ext/eventloop.h (#284) - update automake tools 1.0-5 2021-09-24 o allow access modifications to fail on JDK-17 == Important note to Java developers: JDK-17 no longer allows access overrides, so J() wrapper will fail for cases where the underlying class does not allow public access. This means that it is no longer possible to write high-level code that behaves as if it was a member of the class. Do not upgrade to JDK-17 if that is important in your application or write a Java wrapper that exposes the necessary fields/methods as public. 1.0-4 2021-09-03 o make jverify() check the object type before checking for serialization content. This fixes possible segfaults, including one in .jfield() when used on jclassName objects where jverify() was used on the wrapping S4 class. 1.0-3 2021-04-16 o update URLs referring to Java docs to current 1.8 website 1.0-2 2021-04-15 o convert UTF-16 surrogate pairs to UTF-8 when retrieving strings from Java to R (#51) o use UTF-16 encoding when converting R strings to Java o avoid warnings in the "blah" R Windows API by casting to different types on Windows and unix. 1.0-1 2021-04-12 o New feature: support for custom class loaders. It is strongly recommended that package authors that use rJava in their package use this new feature since it avoids conflicts of classes in packages. (#250) The main mechanism is the own.loader=TRUE option in .jpackage() which instantiates a new, clean class loader for a package such that it is not affected by subsequent class path changes by the user or other packages. In order to use it, the package has to use class.loader=.rJava.class.loader in calls to functions that need to load classes such as .jnew() or J(). This can also be done automatically via something like J <- function(...) rJava::J(..., class.loader=.rJava.class.loader) in the package without need to change every call to J() separately. See the documentation for .jpackage() for details. o J() will automatically call .jinit() if rJava has not been initialized yet. o .jchar(x) supports single non-NA string by calling the String$toCharArray() method. o raw vectors were not recognised in J() API (#260) 0.9-14 2021-02-04 o JRI: fixed detection of the major Java version (#239) o JRI: support Java major versions with suffixes like 13-ea (#236) o JRI: Windows: flags sources as 1.8 to support Java 14 and higher where changes in the language break old code (#241) o Fixed compilation of JRI on macOS to not require the JavaVM framework, but rely on flags from R CMD javareconf. This avoids breakage on macOS 11 which no longer provides JavaVM in the SDK. (#248) 0.9-13 2020-07-06 o increase default JVM stack size by adding -Xss2m to JVM parameters unless -Xss is already specified in .jinit(). This is an attempt to address stack overflow problems in Java 11 and higher on some platforms which appear to use very small stack sizes. (#224) o re-define EXTPTR_xx macros to avoid ABI breakage between R 4.0.0 and later R 4.0.x versions. o add missing C entry points to the symbol cache. (#221) o disable dynamic symbol lookup to catch any (inadvertent) use of unregistered symbols. 0.9-12 2020-03-23 o rJava has a new option --enable-dynload which enables rJava to load JVM dynamically at run-time. It is only supported on unix platforms at this point and is enabled by default on macOS. When enabled, rJava library does not link to JVM, but instead assumes that the JVM library will be loaded into R before JVM functions are used. The default initialization uses the following order to find JVM at run-time: - use JAVA_HOME (typically set by R CMD javareconf) - call /usr/libexec/java_home (if JAVA_HOME is not set) Find ${JAVA_HOME}[/jre]/lib/server/libjvm.{so|dylib} If not found, Java cannot be loaded. On Windows the order has not changed: getOption("java.home"), JAVA_HOME environment variable and registry. However, if the Java home setting is specified, it must be a valid directory, otherwise a warning is issued (#209) and it is assumed to be "" and thus the search continues in the registry. o convert class names from Java objects into JNI notation when constructing method signatures. (#81) o fix a bug in .jfield() which prevented accessing static fields if rJava class loader was not present yet (only affected initialization). o modify bootstrap to avoid reflection calls which are broken in Java 12 (see #175 and https://bugs.openjdk.java.net/browse/JDK-8221530). o added .jgc() to run JVM garbage collector (#180) o fix filtered .jfields() to return actual values (#213) o .jfields() and .jmethods() now correctly filter results even for as.obj=TRUE (#212). Filtering is done by retrieving the names and applying the regular expression specified in `name'. 0.9-11 2019-03-27 o fix segfault if en exception is thrown during rJava initialization (#177) o disable Java stack workaround if loaded from a JVM process (#130) o bump JVM target to 1.8 for JDK 12 and higher since such target is no longer supported (#174). o fix HAVE_XRS detection (#168) o Windows: fix build if javah.exe is missing (#157) o Windows: detect JAVA_HOME correctly from registry even if the key is using JDK instead Java Development Kit (#120) o Windows: don't fail if `RuntimeLib` registry entry is missing (#163) 0.9-10 2018-05-29 o support builds with JDKs that are missing javah (#141) o detect JDKs that don't call themselves Java (such as openjdk) (#146) o macOS: pre-load libjvm.dylib to avoid issues with incorrect ID in Oracle's released binaries 0.9-9 2017-10-11 o add support for --disable-Xrs configure option in case java -Xrs is so broken that it cannot even be tested - reportedly the case with Docker (see #63). o add optional class.loader= argument to .jnew() which allows to use a custom loader in special cases. o change target to 1.6 and higher since Java 1.9 breaks when asked to compile anything older than that. There is no technical reason, so you can still build 1.2/1.4 targets by reverting 992828b and using a JDK that won't break on 1.4 targets. o Process events on Windows while in rniIndle. (#23) o Work around a bug of Oracle's Java on Linux which caps the stack of R at 2M. (#102) The bug leads to segfaults in recursive computations (not an R error as R doesn't know the stack size has been reduced). The workaround can be disabled via environment variable RJAVA_JVM_STACK_WORKAROUND=0, which may produce better results with memory access checkers (ASAN, valgrind), because the workaround detects the new stack size by trying to access inaccessible memory. This JVM behavior was a workaround for an issue in old Linux systems (JDK-4466587) and is going to be fixed in Java 10. o Work around a change in registry location on Windows for Oracle Java 1.9. (#120) 0.9-8 2016-01-06 o Work around a bug on Oracle's Java on OS X by pre-loading jli o Work around DYLD_FALLBACK_LIBRARY_PATH being dropped in OS X 10.11 0.9-7 2015-07-27 o explicitly set -classpath in configure for getps since the user may have set CLASSPATH and thus override the default (see #3) o when constructing String references from character vectors, treat NA as null on the Java side (see #15) o add .jsimplify(..., promote=TRUE) option to promote int to double if integer NAs are to be interpreted literally as -2147483648 values. (see #39) o fix .jarray(.jshort(...)) to respect the `jshort` tag (see #40) 0.9-6 2012-12-23 o bugfix: the first JVM parameters was shadowed by headless mode parameter if enabled (default on OS X). 0.9-5 2012-12-03 o add more debugging information in RJavaClassLoader to trace cases where class path entries are invalid or discarded o detect support for -Xrs and enable it by default (this prevents Java from killing R process on interrupt) o restore locales after Java initialization (some JVMs clobber locales with incompatible settings). o add --enable-headless option which sets the java.awt.headless to true. In the auto mode this flag is only enabled on Mac OS X. Note that it is only set upon initialization, it does not affect already running JVMs. 0.9-4 2013-03-11 o added support for unboxing of Double[], Integer[] and Boolean[] to .jevalArray(.., simplify=TRUE) and thus also to .jcall() o Windows: add Java configuration paths before existing PATH entries o Windows: honor a new option "java.home" to override JAVA_HOME environment variable and system settings to allow co-existence of other tools that may require different Java paths. o Windows: fix a buglet in error reporting when no Java is installed o raise an error if the number of arguments to a Java call exceeds maxJavaPars. Previously, calls would be silently truncated. Note that maxJavaPars can be raised by compiling rJava, e.g. with: PKG_CFLAGS=-DmaxJavaPars=96 R CMD INSTAL rJava_... 0.9-3 2011-12-10 o bugfix: .jinit() was failing on Java 1.4 with "cannot obtain Class.getSimpleName method ID" since the method is only present in Java 1.5+ This was inadvertent, rJava aims to support Java 1.2+ 0.9-2 2011-10-26 o When NOAWT is set, rJava will enable headless mode in the JVM by setting the java.awt.headless property to true during initialization in .jinit() o All C-level entry points are now pre-cached when rJava is loaded such that calls can be made much faster since symbols don't need to be looked up. This should speed up calls to methods that take very little time as well as other parts such as checking for exceptions. 0.9-1 2011-06-28 o fixed Java detection from registry on Windows (bug introduced in 0.9-0) 0.9-0 2011-06-22 o fixes issues introduced by several new features in the late 0.8 series. Most importantly .jarray() and .jevalArray() behave as intended (and as implemented in previous versions). The same applies to .jcall() behavior with respect to arrays and its evalArray argument. The defaults for some new arguments have been changed to reflect the original behavior. o .jevalArray() has an additional argument `simplify' which allows multi-dimensional arrays to be converted to native R types. Use with care - it may convert more recursive types in the future so it should be used preferably where you have control over the types converted. o fixed a bug in .jevalArray that was not simplifying string vectors correctly when the array type was not specified (.jclass returns dot notation whereas signatures use JNI notation so a conversion was necessary) o use install.libs.R in R 2.13.1 to install multi-arch JRI 0.8-8 2010-12-20 o Add support for r.arch in RJavaClassLoader on Windows as well o javaImport was only able to import java packages from the system class loader (not from additional jars) 0.8-7 2010-10-18 o Windows updates to accommodate changes in R 2.12 and layout changes in recent Sun Java installations. 0.8-6 2010-09-17 o JRI 0.5-4: rniStop() provides several ways to notify R on unix. It improves handing of user interrupts via rniStop() by allowing to avoid signals (signals can cause problems in some recent JVM implementations). 0.8-5 2010-09-02 o fix a bug introduced in 0.8-2 where .jclassPath() would not show the real class path o if the rJava class loader is used as a primary loader it will also register as the context class loader. Some projects rely on the thread context class loader instead of Class.getClassLoader() [which is still more reliable] so those will now work as well. o JRI 0.5-3 (bugfixes) 0.8-4 2010-04-28 o JRI 0.5-2 IMPORTANT NOTE: handling of NAs in character vectors has been fixed, NAs were incorrectly passed as "NA" from R to Java instead of nulls (it was correct the other way round). Any code that relies on such incorrect behavior will need to be fixed! Other changes in JRI are mostly related to Windows support (bugfixes R 2.11.0 and Windows 64-bit support) o run.bat is now installed as part of JRI 0.8-3 2010-03-16 o REngine and JRIEngine classes are now included in rJava/JRI although they are not loaded by default. o .r2j now has convert parameter to allow the creation of pure references (convert=FALSE) o toJava() is a new function equivalent to .r2j but resulting in REngine API references (instances of REXPReference). By default the references are not resolved since the primary use is to pass R functions to Java for callbacks. o set text mode for stdin on Windows (thanks to Brian Ripley) o fix support of NULL arguments in new(J("SomeClass"), ...) o fixed issues in with() and within() when used on jobjRef; also the evaluation environment is now the parent frame as expected o disable AWT tests if NOAWT is set; enable a few more tests 0.8-2 2010-01-22 o faster class loader implementation o added support for 64-bit Windows (thanks to Brian Ripley) 0.8-1 2009-10-30 o fixed exception handling on Windows: the access to "call" was off for Windows builds causing incorrect "call" entries in exceptions which broke when encountered in try(). o fixed .jcall() which had inadvertently the default for use.true.class argument set to TRUE. That is considered a bug since it breaks the original behavior and is against the idea of .jcall being the low-level interface. 0.8-0 2009-10-27 o new exception handling was introduced: Java exceptions are mapped to Exception conditions which can be used to catch the exception at R level using e.g tryCatch. The class name automatically contains "Exception", "error" and "condition", as well as all the names (without package path) of the classes in the inheritance tree of the actual class of the Exception. This allows targeted handlers: tryCatch(.jnew("foo"), NoClassDefFoundError=function(e) ...) In addition JNI code now causes an error instead of a warning, however, some errors internal to JNI may not have an associated Java exception and thus will fire the usual simpleError condition. As a consequence of the new error handling exception objects are now supplied in e$jobj of the handler and .jgetEx() becomes obsolete. o added new high-level API using the "J" function. It replaces the previously used .J()/.jrnew() and .jrcall(). New Java objects are created using new(J("class"), ...) and static methods and fields are accessed using J("class")$... The corresponding implementation uses reflection in all cases. An additional class "jclassName" was created to support static calls to accessor methods such as $ and calls to new(). o [RF] arrays are now split in two classes : "jrectRef" for rectangular arrays, similar to R arrays, and jarrayRef for rugged arrays. Indexing of all arrays is supported using the double bracket indexer "[[" and "[[<-" The single indexer "[" is only currently implemented for rectangular arrays. This is experimental. Replacement ([<-) is not supported yet. o [RF] with.jclassName and within.jclassName is added to support "with" semantics on static fields and methods of java classes. Double <- J("java.lang.Double" ) with( Double, parseDouble( "10.2" ) ) o [RF] length.jarrayRef queries the number of objects in a java array. An exception is generated if the object is not an array. Also array$length can be used similarly to array.length in java o [RF] .jcast gains arguments "check" and "convert.array". Their default value is FALSE for backwards compatibility with previous releases of rJava o [RF] Binary operators <, >, <=, >= to compare two objects where at least one is a java object reference. d <- new( J("java.lang.Double"), 0.0 ) d < 1.0 d < 1L Comparison of arrays is not currently supported o [RF] lapply and sapply may now be used on Iterable java objects such as Vector and java arrays. see ?as.list.jobjRef o [RF] The generic "clone" function is added, and an implementation for java objects. an Object must implement the Cloneable interface, otherwise an exception will be raised. Furthermore, careful reading of the java documentation of Object#clone is recommended since this is not standard java behaviour. Currently "clone" is not supported on arrays o [RF] A mechanism for "attach"ing java packages has been introduced, following the mechanism of the RObjectTables package from the OmegaHat project. This allows to "attach" a set of java package paths to R's search path: > attach( javaImport( "java.util", "java.lang" ) ) and then use classes from this package like this : > new( Vector ) > new( HashMap ) > new( Double, 10.2 ) > new( Integer, 10L ) > Collections$EMPTY_MAP This feature is currently __very__ experimental and is as dangerous as any other use of attach 0.7-1 (never released) o [RF] added .J high-level java constructor (based on reflection as opposed to complete match as .jnew does) o [RF] added .jinstanceof and instanceof operator o when loaded into another JVM (e.g. via JRI), rJava would crash on any call if .jinit() was missing. Now it correctly reports the error. o fixed synchronization issues in both JRI and REngine 0.7-0 2009-08-22 o fixed bug in $ getter of fields using old .jfield API o fixed a bug in .jevalArray which failed when the signature was specified directly (and subsequently .jfield failed in most cases) o improve speed of reflection-based API (.jrcall and `$') by using native array support in rJava o reflection API now returns NULL invisibly for void results o try to find the best match in reflection-based API using internal Java code (code and idea by Romain Francois) o added with() method for jobjRef (by Romain Francois), see http://romainfrancois.blog.free.fr/index.php? post/2009/06/17/with-semantics-for-java-objects-in-rJava o added names() method for jobjRef to facilitate code completion (based on code by RF: http://tr.im/w33B) o update to JRI 0.5-0 0.6-3 2009-06-14 o update to JRI 0.4-3 (adds REngine API, enhanced support for environments and references) o allow signatures longer than 256 bytes o added lib.loc parameter to .jpackage() 0.6-2 2009-01-26 o fix --enable-debug to really enable debug code o improve Windows setup (add only paths if they are not already listed and check their presence first) and warn if the system suffers from PATH truncation bug (or PATH is truncated in general) 0.6-1 2008-12-23 o substitute $(JAVA_HOME) in configuration flags when necessary o flag generated strings as UTF-8 and convert incoming strings into UTF-8 (see note in ?.jcall for details) This should improve interoperability in non-UTF-8 locales (most prominent example is Windows) 0.6-0 2008-09-22 o add support for object cache - see .jcache() - based on Java serialization 0.5-2 (never released, turned into 0.6-0) o add direct support for raw vectors as method parameters (before .jarray(r) had to be used) o add .jserialize() and .junserialize() functions for Java-serialization (do not confuse with R serialization!) 0.5-1 2007-11-05 o fix crashes in Windows when Java calls the vfprintf hook o enhance Java environment checks, add more specific errors o add support for r.arch system property which allows multi-arch support on platforms that don't have fat binaries (e.g. Linux) 0.5-0 2007-08-22 o **API CHANGE** The order of arguments of .jfield has been changed to match the order used in .jcall and the return value is as expected and doesn't need .jsimplify anymore. o The implementation of .jfield no longer uses reflection it supports static fields and .jfield<-() was added. o Consolidate interface code for static/non-static calls. It is now possible to call a static method using a non-static object. o Add .jpackage function for initialization of Java packages. See documentation for details, packages should no longer use .jinit in their initialization code. o Add preliminary JRI support from R (see .jengine) o Prepare hooks for de-serialization o Add support for short Java type o Add support for converters o Fix R-devel compatibility issues o Fix a memory leak in string array handling o Use Java settings from R for compilation o Add a custom class loader o Fix a bug in .jcastToArray that produced invalid signatures o Added support for [Z in .jevalArray o Fix a bug in .jarray missing [ prefix for native type arrays 0.4-13 2007-01-14 o Fix Java-side memory leaks (temporary parameters to methods were not properly released, thanks to Erik van Barneveld for supplying a reproducible example). o Fix a bug that caused only the first VM parameter to be passed on during initialization (thanks to Bernard Rosman for reporting). o .jmkref now accepts plain class names (with .) o Fix bug in .jarray (and underlying RcreateArray) that was returning wrong class name if the contents class was an array. o Add --enable-callbacks option to configure (disabled by default). The callbacks support is currently incomplete and experimental. o Update URL to http://www.rforge.net/rJava/ o Update to JRI 0.3-7 (LCons, createRJavaRef, assign XT_NONE) 0.4-12 2006-11-29 o Added documentation for .jthrow, .jclear and .jgetEx and a bugfix in .jgetEx o rJava now uses a namespace. This is still somewhat experimental, because rJava needs to perform some dirty tricks to unseal the namespace during initialization. Please test and report! o Update to JRI 0.3-6 (GIJ fix and fix for R-devel interface changes) 0.4-11 2006-10-10 o Replace variadic macros with wrappers (for compilers that don't support ISO C99). o Modify JNI error reporting - use warnings instead of direct stderr. o Update to JRI 0.3-5 0.4-10 2006-09-14 o Removed obsolete JNI 1.1 support that is no longer provided in JDK 1.6 and thus prevented rJava from being used with JDK 1.6 o Update to JRI 0.3-4 (change compilation to force Java 1.4 compatibility even when more recent JDK is used) 0.4-9 2006-09-12 o Update to JRI 0.3-3 which fixes API version mistake which 0.4-8 2006-09-11 o Added --enable-jri=auto option which will build JRI only if R shared library is present. It is now the default. o Update to JRI 0.3-2 (added boolean support) 0.4-7 2006-09-05 o .jevalArray now works with Java objects that have not been cast to a Java array explicitly. The function is now also documented properly. o Added .jgetEx and .jclear functions for querying and clearing of Java exceptions/throwables. o Added .jthrow to allow throwing of exceptions from R code. o Fixed a typo in .jrcall when handling string return values. 0.4-6 2006-08-20 o Fixed bug in initialization on Windows, introduced in 0.4-4 0.4-5 2006-06-24 o Added support for scalar bytes as .jbyte (byte arrays are still natively represented as RAW vectors) o Added .r2j function which allows to push R objects into Java as references. This works only if R is run via JRI, because it requires a working Rengine instance. 0.4-4 2006-06-21 o Fixed bug that prevented loading into existing VM if the classpath contained duplicate items. .jmergeClassPath now filters out duplicate paths. o .jcall and .jnew discard all named parameters that are passed as `...'. Named parameters are now reserved for future call options o Converted all S3-methods into S4 methods. Also `show' is now used instead of `print' and the output format was changed. o Prototype for jobjRef is now a valid null-Object o Added .jequals and corresponding ==, != op methods. Currently == and != operators feature the same behavior as .jequals(...,strict=FALSE), i.e. scalar non-Java objects are converted into Java objects if possible and then compared, so s <- .jnew("java/lang/String","foo") s == "foo" # returns TRUE o Added .jinherits which allows to check Java-side inheritance using JNI (= isAssignableTo). o Added .jfindClass and .jclassRef that return Java class object o Added check parameter to .jcall and .jnew that allows the caller to prevent implicit call to .jcheck It is mainly useful in cases where silent operation is desired (e.g. in conjunction with try). Additionally, silent parameter was added to .jnew o Added is.jnull which is like is.null but also returns TRUE if the supplied Java object is a null-reference o Added jlong class and .jlong function. Those were documented in the tutorial but never really implemented. Still, they may not be supported in all parts of rJava. WARNING: conversion between Java's long and R's jlong is lossy! R stores jlong in doubles so the conversion implies loss of precision. 0.4-3 2006-05-16 o improved, documented and fixed handling of fields .jfield is dedicated accessor with more options 0.4-2 2006-05-08 o Update to JRI 0.2-5 (no change in rJava) 0.4-1 2006-05-05 o Fixed bug in Windows initialization 0.4-0 2006-05-03 o JRI is now included in rJava 0.3-9 2006-04-20 o fixed a minor bug in Rglue.c that may prevent older compilers from compiling it. 0.3-8 2006-04-17 o .jinit has an additional parameter 'parameters' that allows users to pass additional parameters to the VM (such as -X...) o .jinit now uses a hack (defined in .jmergeClassPath) that allows us to modify the class path of a running VM. This may or may not work for a specific VM, because it is an ugly hack exploiting some implementational features of the VM. See .jmergeClassPath source for reference and explanation. o .jarray now supports the use of .jarray(x) where x is a Java reference. The documentation requires you to use .jarray(list(x)), but since the use of .jarray(x) seems to be a very common mistake, we may as well silently support it. o .jarray has an optional parameter contents.class which allows the global specification of the class type for arrays of objects. (Untested, use with care! In most cases .jcast is probably what you really want.) o Added some more support for floats, longs and byte arrays. (Again, untested) 0.3-7 2006-01-31 (non-public release) o New, experimental feature has been added - JNI cache. This feature can be enabled by passing --enable-jni-cache argument to configure. Normally, each time we access JVM we retrieve new JNI environment to make sure there are no threading issues. In single-threaded environment this is superfluous, so we may as well cache it. The idea is to reduce the overhead. However, the gain is not as huge as expected, so it is not enabled by default. Also note that threads and jni-cache are mutually exclusive. o Another even more experimental feature has been added - support for threads. This feature is enabled by using --enable-threads configure argument. When threads support is enabled, JVM is started on a thread separate from the main thread. Some implementations of AWT classes require this. However, it is not always safe to use, because R event loop is unaware of the separate thread and can deadlock it. 0.3-6 2006-01-30 0.3-5 2006-01-02 0.3-4 2005-12-28 0.3-3 2005-12-20 0.3 2005-12-19 o finalizers, arrays 0.2 2005-09-03 o S4 classes 0.1 2003-08-26 o initial release rJava/src/0000755000175100001440000000000015133274032012122 5ustar hornikusersrJava/src/loader.c0000644000175100001440000000535115133274032013540 0ustar hornikusers/* functions dealing with the rJava class loader * * rJava R/Java interface (C)Copyright 2003-2007 Simon Urbanek * (see rJava project root for licensing details) */ #include "rJava.h" jclass clClassLoader = (jclass) 0; jobject oClassLoader = (jobject) 0; HIDE int initClassLoader(JNIEnv *env, jobject cl) { clClassLoader = (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, cl)); /* oClassLoader = (*env)->NewGlobalRef(env, cl); */ oClassLoader = cl; #ifdef DEBUG_CL printf("initClassLoader: cl=%x, clCl=%x, jcl=%x\n", oClassLoader, clClassLoader, javaClassClass); #endif return 0; } REPC SEXP RJava_set_class_loader(SEXP ldr) { JNIEnv *env=getJNIEnv(); if (TYPEOF(ldr) != EXTPTRSXP) error("invalid type"); if (!env) error("VM not initialized"); jverify(ldr); initClassLoader(env, (jobject)EXTPTR_PTR(ldr)); return R_NilValue; } REPC SEXP RJava_primary_class_loader(void) { JNIEnv *env=getJNIEnv(); jclass cl = (*env)->FindClass(env, "RJavaClassLoader"); _dbg(Rprintf("RJava_primary_class_loader, cl = %x\n", (int) cl)); if (cl) { jmethodID mid = (*env)->GetStaticMethodID(env, cl, "getPrimaryLoader", "()LRJavaClassLoader;"); _dbg(Rprintf(" - mid = %d\n", (int) mid)); if (mid) { jobject o = (*env)->CallStaticObjectMethod(env, cl, mid); _dbg(Rprintf(" - call result = %x\n", (int) o)); if (o) { return j2SEXP(env, o, 1); } } } checkExceptionsX(env, 1); #ifdef NEW123 jclass cl = (*env)->FindClass(env, "JRIBootstrap"); Rprintf("RJava_primary_class_loader, cl = %x\n", (int) cl); if (cl) { jmethodID mid = (*env)->GetStaticMethodID(env, cl, "getBootRJavaLoader", "()Ljava/lang/Object;"); Rprintf(" - mid = %d\n", (int) mid); if (mid) { jobject o = (*env)->CallStaticObjectMethod(env, cl, mid); Rprintf(" - call result = %x\n", (int) o); if (o) { return j2SEXP(env, o, 1); } } } checkExceptionsX(env, 1); #endif return R_NilValue; } REPC SEXP RJava_new_class_loader(SEXP p1, SEXP p2) { JNIEnv *env=getJNIEnv(); const char *c1 = CHAR(STRING_ELT(p1, 0)); const char *c2 = CHAR(STRING_ELT(p2, 0)); jstring s1 = newString(env, c1); jstring s2 = newString(env, c2); jclass cl = (*env)->FindClass(env, "RJavaClassLoader"); _dbg(Rprintf("find rJavaClassLoader: %x\n", (int) cl)); jmethodID mid = (*env)->GetMethodID(env, cl, "", "(Ljava/lang/String;Ljava/lang/String;)V"); _dbg(Rprintf("constructor mid: %x\n", mid)); jobject o = (*env)->NewObject(env, cl, mid, s1, s2); _dbg(Rprintf("new object: %x\n", o)); o = makeGlobal(env, o); _dbg(Rprintf("calling initClassLoader\n")); initClassLoader(env, o); releaseObject(env, s1); releaseObject(env, s2); releaseObject(env, cl); return R_NilValue; } rJava/src/callJNI.c0000644000175100001440000002531415133274032013547 0ustar hornikusers#include #include #include "rJava.h" #include #include #ifdef MEMPROF FILE *memprof_f = 0; #endif /* local to JRI */ static void releaseLocal(JNIEnv *env, jobject o); REPC SEXP RJavaCheckExceptions(SEXP silent) { int result = 0; JNIEnv *env = getJNIEnv(); if (env) result = checkExceptionsX(env, asInteger(silent)); return ScalarInteger(result); } HIDE void* errJNI(const char *err, ...) { char msg[512]; va_list ap; #ifndef RJ_DEBUG /* non-debug version goes straight to ckx - it should never return */ ckx(NULL); #endif va_start(ap, err); msg[511]=0; vsnprintf(msg, 511, err, ap); #ifdef RJ_DEBUG Rf_warning("%s", msg); #else Rf_error("%s", msg); /* this never returns and is just a fallback in case ckx doesn't return */ #endif va_end(ap); checkExceptionsX(getJNIEnv(), 0); return 0; } /* loader: if NULL does NOT use any custom loader but uses system FindClass, otherwise Class.forName(..., true, loader) if user first and system only as fall-back */ HIDE jclass findClass(JNIEnv *env, const char *cName, jobject loader) { if (loader) { char cn[128], *c=cn; jobject cns; jclass cl; strcpy(cn, cName); while (*c) { if (*c=='/') *c='.'; c++; }; cns = newString(env, cn); if (!cns) error("unable to create Java string from '%s'", cn); #ifdef DEBUG_CL printf("findClass(\"%s\") [with %s loader]\n", cn, (loader && loader == oClassLoader) ? "rJava" : "custom"); #endif cl = (jclass) (*env)->CallStaticObjectMethod(env, javaClassClass, mid_forName, cns, (jboolean) 1, loader); #if RJAVA_LEGACY clx(env); #endif _mp(MEM_PROF_OUT(" %08x LNEW class\n", (int) cl)) releaseObject(env, cns); #ifdef DEBUG_CL printf(" - got %x\n", (unsigned int) cl); #endif #if RJAVA_LEGACY if (cl) #endif return cl; } #ifdef DEBUG_CL printf("findClass(\"%s\") (no loader)\n", cName); #endif { jclass cl = (*env)->FindClass(env, cName); _mp(MEM_PROF_OUT(" %08x LNEW class\n", (int) cl)) #ifdef DEBUG_CL printf(" - got %x\n", (unsigned int) cl); #endif return cl; } } /* loader: if NULL, uses oClassLoader (rJava class loader) */ HIDE jobject createObject(JNIEnv *env, const char *class, const char *sig, jvalue *par, int silent, jobject loader) { /* va_list ap; */ jmethodID mid; jclass cls; jobject o; cls=findClass(env, class, loader ? loader : oClassLoader); if (!cls) return silent?0:errJNI("createObject.FindClass %s failed",class); mid=(*env)->GetMethodID(env, cls, "", sig); if (!mid) { releaseLocal(env, cls); return silent?0:errJNI("createObject.GetMethodID(\"%s\",\"%s\") failed",class,sig); } /* va_start(ap, sig); */ o=(*env)->NewObjectA(env, cls, mid, par); _mp(MEM_PROF_OUT(" %08x LNEW object\n", (int) o)) /* va_end(ap); */ releaseLocal(env, cls); return (o||silent)?o:errJNI("NewObject(\"%s\",\"%s\",...) failed",class,sig); } HIDE void printObject(JNIEnv *env, jobject o) { jmethodID mid; jclass cls; jobject s; const char *c; cls=(*env)->GetObjectClass(env,o); _mp(MEM_PROF_OUT(" %08x LNEW class from object %08x (JRI-local)\n", (int)cls, (int)o)) if (!cls) { releaseLocal(env, cls); errJNI("printObject.GetObjectClass failed"); return ; } mid=(*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); if (!mid) { releaseLocal(env, cls); errJNI("printObject.GetMethodID for toString() failed"); return; } s=(*env)->CallObjectMethod(env, o, mid); _mp(MEM_PROF_OUT(" %08x LNEW object method toString result (JRI-local)\n", (int)s)) if (!s) { releaseLocal(env, cls); errJNI("printObject o.toString() call failed"); return; } c=(*env)->GetStringUTFChars(env, (jstring)s, 0); (*env)->ReleaseStringUTFChars(env, (jstring)s, c); releaseLocal(env, cls); releaseLocal(env, s); } HIDE jdoubleArray newDoubleArray(JNIEnv *env, double *cont, int len) { jdoubleArray da=(*env)->NewDoubleArray(env,len); jdouble *dae; _mp(MEM_PROF_OUT(" %08x LNEW double[%d]\n", (int) da, len)) if (!da) return errJNI("newDoubleArray.new(%d) failed",len); dae=(*env)->GetDoubleArrayElements(env, da, 0); if (!dae) { releaseLocal(env, da); return errJNI("newDoubleArray.GetDoubleArrayElements failed"); } memcpy(dae,cont,sizeof(jdouble)*len); (*env)->ReleaseDoubleArrayElements(env, da, dae, 0); return da; } HIDE jintArray newIntArray(JNIEnv *env, int *cont, int len) { jintArray da=(*env)->NewIntArray(env,len); jint *dae; _mp(MEM_PROF_OUT(" %08x LNEW int[%d]\n", (int) da, len)) if (!da) return errJNI("newIntArray.new(%d) failed",len); dae=(*env)->GetIntArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newIntArray.GetIntArrayElements failed"); } memcpy(dae,cont,sizeof(jint)*len); (*env)->ReleaseIntArrayElements(env, da, dae, 0); return da; } HIDE jbyteArray newByteArray(JNIEnv *env, void *cont, int len) { jbyteArray da=(*env)->NewByteArray(env,len); jbyte *dae; _mp(MEM_PROF_OUT(" %08x LNEW byte[%d]\n", (int) da, len)) if (!da) return errJNI("newByteArray.new(%d) failed",len); dae=(*env)->GetByteArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newByteArray.GetByteArrayElements failed"); } memcpy(dae,cont,len); (*env)->ReleaseByteArrayElements(env, da, dae, 0); return da; } HIDE jbyteArray newByteArrayI(JNIEnv *env, int *cont, int len) { jbyteArray da=(*env)->NewByteArray(env,len); jbyte* dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW byte[%d]\n", (int) da, len)) if (!da) return errJNI("newByteArray.new(%d) failed",len); dae=(*env)->GetByteArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newByteArray.GetByteArrayElements failed"); } while (iReleaseByteArrayElements(env, da, dae, 0); return da; } HIDE jbooleanArray newBooleanArrayI(JNIEnv *env, int *cont, int len) { jbooleanArray da=(*env)->NewBooleanArray(env,len); jboolean *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW bool[%d]\n", (int) da, len)) if (!da) return errJNI("newBooleanArrayI.new(%d) failed",len); dae=(*env)->GetBooleanArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newBooleanArrayI.GetBooleanArrayElements failed"); } /* we cannot just memcpy since JNI uses unsigned char and R uses int */ while (iReleaseBooleanArrayElements(env, da, dae, 0); return da; } HIDE jcharArray newCharArrayI(JNIEnv *env, int *cont, int len) { jcharArray da=(*env)->NewCharArray(env,len); jchar *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW char[%d]\n", (int) da, len)) if (!da) return errJNI("newCharArrayI.new(%d) failed",len); dae=(*env)->GetCharArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newCharArrayI.GetCharArrayElements failed"); } while (iReleaseCharArrayElements(env, da, dae, 0); return da; } HIDE jshortArray newShortArrayI(JNIEnv *env, int *cont, int len) { jshortArray da=(*env)->NewShortArray(env,len); jshort *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW short[%d]\n", (int) da, len)) if (!da) return errJNI("newShortArrayI.new(%d) failed",len); dae=(*env)->GetShortArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newShortArrayI.GetShortArrayElements failed"); } while (iReleaseShortArrayElements(env, da, dae, 0); return da; } HIDE jfloatArray newFloatArrayD(JNIEnv *env, double *cont, int len) { jfloatArray da=(*env)->NewFloatArray(env,len); jfloat *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW float[%d]\n", (int) da, len)) if (!da) return errJNI("newFloatArrayD.new(%d) failed",len); dae=(*env)->GetFloatArrayElements(env, da, 0); if (!dae) { releaseLocal(env,da); return errJNI("newFloatArrayD.GetFloatArrayElements failed"); } /* we cannot just memcpy since JNI uses float and R uses double */ while (iReleaseFloatArrayElements(env, da, dae, 0); return da; } HIDE jlongArray newLongArrayD(JNIEnv *env, double *cont, int len) { jlongArray da=(*env)->NewLongArray(env,len); jlong *dae; int i=0; _mp(MEM_PROF_OUT(" %08x LNEW long[%d]\n", (int) da, len)) if (!da) return errJNI("newLongArrayD.new(%d) failed",len); dae=(*env)->GetLongArrayElements(env, da, 0); if (!dae) { releaseLocal(env, da); return errJNI("newLongArrayD.GetFloatArrayElements failed"); } /* we cannot just memcpy since JNI uses long and R uses double */ while (iReleaseLongArrayElements(env, da, dae, 0); return da; } HIDE jstring newString(JNIEnv *env, const char *cont) { jstring s=(*env)->NewStringUTF(env, cont); _mp(MEM_PROF_OUT(" %08x LNEW string \"%s\"\n", (int) s, cont)) return s?s:errJNI("newString(\"%s\") failed",cont); } HIDE jstring newString16(JNIEnv *env, const jchar *cont, jsize len) { jstring s=(*env)->NewString(env, cont, len); _mp(MEM_PROF_OUT(" %08x LNEW string [%p,%d]\n", (int) s, cont, (int) len)) return s?s:errJNI("newString16(%p,%d) failed", cont, (int)len); } HIDE void releaseObject(JNIEnv *env, jobject o) { /* Rprintf("releaseObject: %lx\n", (long)o); printObject(env, o); */ _mp(MEM_PROF_OUT(" %08x LREL\n", (int)o)) (*env)->DeleteLocalRef(env, o); } HIDE jclass objectClass(JNIEnv *env, jobject o) { jclass cls=(*env)->GetObjectClass(env,o); _mp(MEM_PROF_OUT(" %08x LNEW class from object %08x\n", (int) cls, (int) o)) return cls; } static void releaseLocal(JNIEnv *env, jobject o) { _mp(MEM_PROF_OUT(" %08x LREL (JRI-local)\n", (int)o)) (*env)->DeleteLocalRef(env, o); } HIDE jobject makeGlobal(JNIEnv *env, jobject o) { jobject g=(*env)->NewGlobalRef(env,o); _mp(MEM_PROF_OUT("G %08x GNEW %08x\n", (int) g, (int) o)) return g?g:errJNI("makeGlobal: failed to make global reference"); } HIDE void releaseGlobal(JNIEnv *env, jobject o) { /* Rprintf("releaseGlobal: %lx\n", (long)o); printObject(env, o); */ _mp(MEM_PROF_OUT("G %08x GREL\n", (int) o)) (*env)->DeleteGlobalRef(env,o); } static jobject nullEx = 0; HIDE int checkExceptionsX(JNIEnv *env, int silent) { jthrowable t=(*env)->ExceptionOccurred(env); if (t == nullEx) t = 0; else { if ((*env)->IsSameObject(env, t, 0)) { nullEx = t; t = 0; } else { _mp(MEM_PROF_OUT(" %08x LNEW exception\n", (int) t)) } } if (t) { if (!silent) ckx(env); (*env)->ExceptionClear(env); releaseLocal(env, t); return 1; } return 0; } rJava/src/config.h.in0000644000175100001440000000473715133274032014160 0ustar hornikusers/* src/config.h.in. Generated from configure.ac by autoheader. */ /* define if callbacks support is enabled. */ #undef ENABLE_JRICB /* Define to 1 if you have the declaration of `siglongjmp', and to 0 if you don't. */ #undef HAVE_DECL_SIGLONGJMP /* Define to 1 if you have the declaration of `sigsetjmp', and to 0 if you don't. */ #undef HAVE_DECL_SIGSETJMP /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define if you have POSIX.1 compatible sigsetjmp/siglongjmp. */ #undef HAVE_POSIX_SETJMP /* Define to 1 when static inline works */ #undef HAVE_STATIC_INLINE /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Set if the Java parameter -Xrs is supported */ #undef HAVE_XRS /* Set if caching JNI environment is enabled. */ #undef JNI_CACHE /* memory profiling is enabled when defined */ #undef MEMPROF /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Set if threading support should be enabled. */ #undef THREADS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Set if headless mode is to be used when starting the JVM */ #undef USE_HEADLESS_INIT /* Define to empty if `const' does not conform to ANSI C. */ #undef const rJava/src/fields.c0000644000175100001440000002716515133274032013547 0ustar hornikusers/* R-callable functions to get/set fields * * rJava R/Java interface (C)Copyright 2003-2007 Simon Urbanek * (see rJava project root for licensing details) */ #include "rJava.h" #include static char *classToJNI(const char *cl) { if (*cl=='[') { char *d = strdup(cl); char *c = d; while (*c) { if (*c=='.') *c='/'; c++; } return d; } if (!strcmp(cl, "boolean")) return strdup("Z"); if (!strcmp(cl, "byte")) return strdup("B"); if (!strcmp(cl, "int")) return strdup("I"); if (!strcmp(cl, "long")) return strdup("J"); if (!strcmp(cl, "double")) return strdup("D"); if (!strcmp(cl, "short")) return strdup("S"); if (!strcmp(cl, "float")) return strdup("F"); if (!strcmp(cl, "char")) return strdup("C"); /* anything else is a real class -> wrap into L..; */ char *jc = malloc(strlen(cl)+3); *jc='L'; strcpy(jc+1, cl); strcat(jc, ";"); { char *c=jc; while (*c) { if (*c=='.') *c='/'; c++; } } return jc; } static SEXP R_Sym_jobj = 0; /* get an R object and extract Java class and Java object from it. if it is a string of class reference then jobj will be NULL and only the class is provided. is_local is set to1 if the returned cls is a local reference that needs to be released, 0 otherwise (typically if it is NULL or comes from jclassName object) FIXME: This is fairly generic - should we move it to tools? */ static jclass inputToClass(JNIEnv *env, SEXP obj, jobject *jobj, int *is_local) { jclass cls = 0; jobject o = 0; if (is_local) *is_local = 0; if (!R_Sym_jobj) R_Sym_jobj = Rf_install("jobj"); /* jclassName is the result of J("class.name") and has the class object in jobj slot */ if (inherits(obj, "jclassName")) { obj = GET_SLOT(obj, R_Sym_jobj); jverify(obj); /* twice wrapped: className has @jobj slot which in turn contains jobjRef to the class */ obj = GET_SLOT(obj, R_Sym_jobj); jverify(obj); cls = (jclass)EXTPTR_PTR(obj); #ifdef RJ_DEBUG if (cls) { rjprintf("inputToClass, class: "); printObject(env, cls); } #endif } else { char *clnam = 0; if (IS_JOBJREF(obj)) /* any of the jobjRef derivates */ obj = GET_SLOT(obj, install("jobj")); if (TYPEOF(obj) == EXTPTRSXP) { jverify(obj); o = (jobject)EXTPTR_PTR(obj); } else if (TYPEOF(obj) == STRSXP && LENGTH(obj) == 1) clnam = strdup(CHAR(STRING_ELT(obj, 0))); else error("invalid object parameter"); if (!o && !clnam) error("cannot access a NULL object"); #ifdef RJ_DEBUG if (o) { rjprintf("inputToClass, object: "); printObject(env, o); } else { rjprintf("inputToClass, class: %s\n", clnam); } #endif if (o) cls = objectClass(env, o); else { /* this should be rare since is doesn't provide a way to specify the class loader */ cls = findClass(env, clnam, oClassLoader); free(clnam); if (!cls) { error("cannot find class %s", CHAR(STRING_ELT(obj, 0))); } } if (cls && is_local) *is_local = 1; } if (jobj) *jobj = o; return cls; } /* find field signature using reflection. Basically it is the same as: cls.getField(fnam).getType().getName() + class2JNI mangling */ /* TODO; use the mid_RJavaTools_getFieldTypeName method ID instead */ static char *findFieldSignature(JNIEnv *env, jclass cls, const char *fnam) { char *detsig = 0; jstring s = newString(env, fnam); if (s) { jobject f = (*env)->CallObjectMethod(env, cls, mid_getField, s); _mp(MEM_PROF_OUT(" %08x LNEW object getField result value\n", (int) f)) if (f) { jobject fcl = (*env)->CallObjectMethod(env, f, mid_getType); _mp(MEM_PROF_OUT(" %08x LNEW object getType result value\n", (int) f)) if (fcl) { jobject fcns = (*env)->CallObjectMethod(env, fcl, mid_getName); releaseObject(env, fcl); if (fcns) { const char *fcn = (*env)->GetStringUTFChars(env, fcns, 0); detsig = classToJNI(fcn); _dbg(Rprintf("class '%s' -> '%s' sig\n", fcn, detsig)); (*env)->ReleaseStringUTFChars(env, fcns, fcn); releaseObject(env, fcns); /* fid = (*env)->FromReflectedField(env, f); */ } } else releaseObject(env, fcl); releaseObject(env, f); } releaseObject(env, s); } return detsig; } /** get value of a field of an object or class object (int), return signature (string), field name (string) arrays and objects are returned as IDs (hence not evaluated) class name can be in either form / or . */ REPC SEXP RgetField(SEXP obj, SEXP sig, SEXP name, SEXP trueclass) { jobject o = 0; SEXP e; const char *retsig, *fnam; char *detsig = 0; jfieldID fid; jclass cls; int tc = asInteger(trueclass), cls_local = 0; JNIEnv *env=getJNIEnv(); if (obj == R_NilValue) return R_NilValue; cls = inputToClass(env, obj, &o, &cls_local); if (!cls) error("cannot determine object class"); #ifdef RJ_DEBUG rjprintf("RgetField.class: "); printObject(env, cls); #endif if (TYPEOF(name)!=STRSXP || LENGTH(name)!=1) { if (cls_local) releaseObject(env, cls); error("invalid field name"); } fnam = CHAR(STRING_ELT(name,0)); if (sig == R_NilValue) { retsig = detsig = findFieldSignature(env, cls, fnam); if (!retsig) { if (cls_local) releaseObject(env, cls); error("unable to detect signature for field '%s'", fnam); } } else { if (TYPEOF(sig)!=STRSXP || LENGTH(sig)!=1) { if (cls_local) releaseObject(env, cls); error("invalid signature parameter"); } retsig = CHAR(STRING_ELT(sig,0)); } _dbg(rjprintf("field %s signature is %s\n",fnam,retsig)); if (o) { /* first try non-static fields */ fid = (*env)->GetFieldID(env, cls, fnam, retsig); checkExceptionsX(env, 1); if (!fid) { /* if that fails, try static ones */ o = 0; fid = (*env)->GetStaticFieldID(env, cls, fnam, retsig); } } else /* no choice if the object was a string */ fid = (*env)->GetStaticFieldID(env, cls, fnam, retsig); if (!fid) { checkExceptionsX(env, 1); if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); error("RgetField: field %s not found", fnam); } switch (*retsig) { case 'I': { int r=o? (*env)->GetIntField(env, o, fid): (*env)->GetStaticIntField(env, cls, fid); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'S': { jshort r=o? (*env)->GetShortField(env, o, fid): (*env)->GetStaticShortField(env, cls, fid); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'C': { int r=(int) (o? (*env)->GetCharField(env, o, fid): (*env)->GetStaticCharField(env, cls, fid)); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'B': { int r=(int) (o? (*env)->GetByteField(env, o, fid): (*env)->GetStaticByteField(env, cls, fid)); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'J': { jlong r=o? (*env)->GetLongField(env, o, fid): (*env)->GetStaticLongField(env, cls, fid); e = allocVector(REALSXP, 1); REAL(e)[0] = (double)r; if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'Z': { jboolean r=o? (*env)->GetBooleanField(env, o, fid): (*env)->GetStaticBooleanField(env, cls, fid); e = allocVector(LGLSXP, 1); LOGICAL(e)[0] = r?1:0; if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'D': { double r=o? (*env)->GetDoubleField(env, o, fid): (*env)->GetStaticDoubleField(env, cls, fid); e = allocVector(REALSXP, 1); REAL(e)[0] = r; if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'F': { double r = (double) (o? (*env)->GetFloatField(env, o, fid): (*env)->GetStaticFloatField(env, cls, fid)); e = allocVector(REALSXP, 1); REAL(e)[0] = r; if (cls_local) releaseObject(env, cls); if (detsig) free(detsig); return e; } case 'L': case '[': { SEXP rv; jobject r = o? (*env)->GetObjectField(env, o, fid): (*env)->GetStaticObjectField(env, cls, fid); _mp(MEM_PROF_OUT(" %08x LNEW field value\n", (int) r)) if (cls_local) releaseObject(env, cls); if (tc) { if (detsig) free(detsig); return new_jobjRef(env, r, 0); } if (*retsig=='L') { /* need to fix the class name */ char *d = strdup(retsig), *c = d; while (*c) { if (*c==';') { *c=0; break; }; c++; } rv = new_jobjRef(env, r, d+1); free(d); } else rv = new_jobjRef(env, r, retsig); if (detsig) free(detsig); return rv; } } /* switch */ if (cls_local) releaseObject(env, cls); if (detsig) { free(detsig); error("unknown field signature"); } error("unknown field signature '%s'", retsig); return R_NilValue; } REPC SEXP RsetField(SEXP ref, SEXP name, SEXP value) { jobject o = 0, otr; SEXP obj = ref; const char *fnam; sig_buffer_t sig; jfieldID fid; jclass cls; jvalue jval; int cls_local = 0; JNIEnv *env=getJNIEnv(); if (TYPEOF(name)!=STRSXP && LENGTH(name)!=1) error("invalid field name"); fnam = CHAR(STRING_ELT(name, 0)); if (obj == R_NilValue) error("cannot set a field of a NULL object"); cls = inputToClass(env, obj, &o, &cls_local); if (!cls) error("cannot determine object class"); #ifdef RJ_DEBUG rjprintf("RsetField.class: "); printObject(env, cls); #endif init_sigbuf(&sig); jval = R1par2jvalue(env, value, &sig, &otr); if (o) { fid = (*env)->GetFieldID(env, cls, fnam, sig.sig); if (!fid) { checkExceptionsX(env, 1); o = 0; fid = (*env)->GetStaticFieldID(env, cls, fnam, sig.sig); } } else fid = (*env)->GetStaticFieldID(env, cls, fnam, sig.sig); if (!fid) { checkExceptionsX(env, 1); if (cls_local) releaseObject(env, cls); if (otr) releaseObject(env, otr); done_sigbuf(&sig); error("cannot find field %s with signature %s", fnam, sig.sigbuf); } switch(sig.sig[0]) { case 'Z': o?(*env)->SetBooleanField(env, o, fid, jval.z): (*env)->SetStaticBooleanField(env, cls, fid, jval.z); break; case 'C': o?(*env)->SetCharField(env, o, fid, jval.c): (*env)->SetStaticCharField(env, cls, fid, jval.c); break; case 'B': o?(*env)->SetByteField(env, o, fid, jval.b): (*env)->SetStaticByteField(env, cls, fid, jval.b); break; case 'I': o?(*env)->SetIntField(env, o, fid, jval.i): (*env)->SetStaticIntField(env, cls, fid, jval.i); break; case 'D': o?(*env)->SetDoubleField(env, o, fid, jval.d): (*env)->SetStaticDoubleField(env, cls, fid, jval.d); break; case 'F': o?(*env)->SetFloatField(env, o, fid, jval.f): (*env)->SetStaticFloatField(env, cls, fid, jval.f); break; case 'J': o?(*env)->SetLongField(env, o, fid, jval.j): (*env)->SetStaticLongField(env, cls, fid, jval.j); break; case 'S': o?(*env)->SetShortField(env, o, fid, jval.s): (*env)->SetStaticShortField(env, cls, fid, jval.s); break; case '[': case 'L': o?(*env)->SetObjectField(env, o, fid, jval.l): (*env)->SetStaticObjectField(env, cls, fid, jval.l); break; default: if (cls_local) releaseObject(env, cls); if (otr) releaseObject(env, otr); done_sigbuf(&sig); error("unknown field siganture %s", sig.sigbuf); } done_sigbuf(&sig); if (cls_local) releaseObject(env, cls); if (otr) releaseObject(env, otr); return ref; } rJava/src/arrayc.c0000644000175100001440000002742615133274032013562 0ustar hornikusers/* R-callable functions to convert arrays into R objects * * rJava R/Java interface (C)Copyright 2003-2007 Simon Urbanek * (see rJava project root for licensing details) */ #include "rJava.h" /** get contents of the object array in the form of list of ext. pointers */ REPC SEXP RgetObjectArrayCont(SEXP e) { SEXP ar; jarray o; int l,i; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return R_NilValue; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetObjectArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert object array of length %d\n",l)); if (l<1) return R_NilValue; PROTECT(ar=allocVector(VECSXP,l)); i=0; while (iGetObjectArrayElement(env, o, i); _mp(MEM_PROF_OUT(" %08x LNEW object array element [%d]\n", (int) ae, i)) SET_VECTOR_ELT(ar, i, j2SEXP(env, ae, 1)); i++; } UNPROTECT(1); _prof(profReport("RgetObjectArrayCont[%d]:",o)); return ar; } /** get contents of the object array in the form of STRSXP vector */ REPC SEXP RgetStringArrayCont(SEXP e) { SEXP ar = R_NilValue ; if (e==R_NilValue) return R_NilValue; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); ar = getStringArrayCont( (jarray)EXTPTR_PTR(e) ) ; } else error("invalid object parameter"); return ar; } /** get contents of the integer array object */ REPC SEXP RgetIntArrayCont(SEXP e) { SEXP ar; jarray o; int l; jint *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetIntArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert int array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jint*)(*env)->GetIntArrayElements(env, o, 0); if (!ap) error("cannot obtain integer array contents"); PROTECT(ar=allocVector(INTSXP,l)); if (l>0) memcpy(INTEGER(ar),ap,sizeof(jint)*l); UNPROTECT(1); (*env)->ReleaseIntArrayElements(env, o, ap, 0); _prof(profReport("RgetIntArrayCont[%d]:",o)); return ar; } /** get contents of the boolean array object */ REPC SEXP RgetBoolArrayCont(SEXP e) { SEXP ar; jarray o; int l; jboolean *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetBoolArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert bool array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jboolean*)(*env)->GetBooleanArrayElements(env, o, 0); if (!ap) error("cannot obtain boolean array contents"); PROTECT(ar=allocVector(LGLSXP,l)); { /* jboolean = byte, logical = int, need to convert */ int i = 0; while (i < l) { LOGICAL(ar)[i] = ap[i]; i++; } } UNPROTECT(1); (*env)->ReleaseBooleanArrayElements(env, o, ap, 0); _prof(profReport("RgetBoolArrayCont[%d]:",o)); return ar; } /** get contents of a character array object */ REPC SEXP RgetCharArrayCont(SEXP e) { SEXP ar; jarray o; int l; jchar *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetCharArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert char array of length %d\n",l)); if (l<0) return R_NilValue; ap = (*env)->GetCharArrayElements(env, o, 0); if (!ap) error("cannot obtain char array contents"); PROTECT(ar=allocVector(INTSXP,l)); { /* jchar = 16-bit, need to convert */ int i = 0; while (i < l) { INTEGER(ar)[i] = ap[i]; i++; } } UNPROTECT(1); (*env)->ReleaseCharArrayElements(env, o, ap, 0); _prof(profReport("RgetCharArrayCont[%d]:",o)); return ar; } /** get contents of a short array object */ REPC SEXP RgetShortArrayCont(SEXP e) { SEXP ar; jarray o; int l; jshort *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetBoolArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert short array of length %d\n",l)); if (l<0) return R_NilValue; ap = (*env)->GetShortArrayElements(env, o, 0); if (!ap) error("cannot obtain short array contents"); PROTECT(ar=allocVector(INTSXP,l)); { /* jshort = 16-bit, need to convert */ int i = 0; while (i < l) { INTEGER(ar)[i] = ap[i]; i++; } } UNPROTECT(1); (*env)->ReleaseShortArrayElements(env, o, ap, 0); _prof(profReport("RgetShortArrayCont[%d]:",o)); return ar; } /** get contents of the byte array object */ REPC SEXP RgetByteArrayCont(SEXP e) { SEXP ar; jarray o; int l; jbyte *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetByteArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert byte array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jbyte*)(*env)->GetByteArrayElements(env, o, 0); if (!ap) error("cannot obtain byte array contents"); PROTECT(ar=allocVector(RAWSXP,l)); if (l>0) memcpy(RAW(ar),ap,l); UNPROTECT(1); (*env)->ReleaseByteArrayElements(env, o, ap, 0); _prof(profReport("RgetByteArrayCont[%d]:",o)); return ar; } /** get contents of the double array object */ REPC SEXP RgetDoubleArrayCont(SEXP e) { SEXP ar; jarray o; int l; jdouble *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetDoubleArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert double array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jdouble*)(*env)->GetDoubleArrayElements(env, o, 0); if (!ap) error("cannot obtain double array contents"); PROTECT(ar=allocVector(REALSXP,l)); if (l>0) memcpy(REAL(ar),ap,sizeof(jdouble)*l); UNPROTECT(1); (*env)->ReleaseDoubleArrayElements(env, o, ap, 0); _prof(profReport("RgetDoubleArrayCont[%d]:",o)); return ar; } /** get contents of the float array object (double) */ REPC SEXP RgetFloatArrayCont(SEXP e) { SEXP ar; jarray o; int l; jfloat *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetFloatArrayCont: jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert float array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jfloat*)(*env)->GetFloatArrayElements(env, o, 0); if (!ap) error("cannot obtain float array contents"); PROTECT(ar=allocVector(REALSXP,l)); { /* jfloat must be coerced into double .. we use just a cast for each element */ int i=0; while (iReleaseFloatArrayElements(env, o, ap, 0); _prof(profReport("RgetFloatArrayCont[%d]:",o)); return ar; } /** get contents of the long array object (int) */ REPC SEXP RgetLongArrayCont(SEXP e) { SEXP ar; jarray o; int l; jlong *ap; JNIEnv *env=getJNIEnv(); profStart(); if (e==R_NilValue) return e; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error("invalid object parameter"); _dbg(rjprintf("RgetLongArrayCont: jarray %d\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert long array of length %d\n",l)); if (l<0) return R_NilValue; ap=(jlong*)(*env)->GetLongArrayElements(env, o, 0); if (!ap) error("cannot obtain long contents"); PROTECT(ar=allocVector(REALSXP,l)); { /* long must be coerced into double .. we use just a cast for each element, bad idea? */ int i=0; while (iReleaseLongArrayElements(env, o, ap, 0); _prof(profReport("RgetLongArrayCont[%d]:",o)); return ar; } /* these below have been factored out of the ones above so that they can also be used internally in jni code */ /** * get contents of the String array in the form of STRSXP vector * * @param e a pointer to a String[] object * * @return a STRSXP vector mirroring the java array */ HIDE SEXP getStringArrayCont(jarray o) { SEXP ar; int l,i; const char *c; JNIEnv *env=getJNIEnv(); profStart(); _dbg(rjprintf("RgetStringArrayCont: jarray %x\n",o)); if (!o) return R_NilValue; l=(int)(*env)->GetArrayLength(env, o); _dbg(rjprintf(" convert string array of length %d\n",l)); if (l<0) return R_NilValue; PROTECT(ar=allocVector(STRSXP,l)); i=0; while (iGetObjectArrayElement(env, o, i); _mp(MEM_PROF_OUT(" %08x LNEW object array element [%d]\n", (int) sobj, i)) c=0; if (sobj) { /* we could (should?) check the type here ... if (!(*env)->IsInstanceOf(env, sobj, javaStringClass)) { printf(" not a String\n"); } else */ c=(*env)->GetStringUTFChars(env, sobj, 0); } if (!c) SET_STRING_ELT(ar, i, R_NaString); else { SET_STRING_ELT(ar, i, mkCharUTF8(c)); (*env)->ReleaseStringUTFChars(env, sobj, c); } if (sobj) releaseObject(env, sobj); i++; } UNPROTECT(1); _prof(profReport("RgetStringArrayCont[%d]:",o)) return ar; } /** * Get the list of class names of a java object * This is a jni wrapper around the RJavaTools.getSimpleClassNames method */ HIDE jarray getSimpleClassNames( jobject o, jboolean addConditionClasses ){ JNIEnv *env=getJNIEnv(); jarray a ; profStart(); a = (jarray) (*env)->CallStaticObjectMethod(env, rj_RJavaTools_Class, mid_rj_getSimpleClassNames, o, addConditionClasses ) ; _prof(profReport("getSimpleClassNames[%d]:",o)) ; return a ; } /** * Get the list of class names of a java object, and * structure it as a STRSXP vector */ HIDE SEXP getSimpleClassNames_asSEXP( jobject o, jboolean addConditionClasses ){ if( !o ){ SEXP res = PROTECT( allocVector( STRSXP, 4) ) ; SET_STRING_ELT( res, 0, mkChar( "Exception" ) ) ; SET_STRING_ELT( res, 1, mkChar( "Throwable" ) ) ; SET_STRING_ELT( res, 2, mkChar( "error" ) ) ; SET_STRING_ELT( res, 3, mkChar( "condition" ) ) ; UNPROTECT(1); return res ; } else{ return getStringArrayCont( getSimpleClassNames( o, addConditionClasses ) ); } } /** * Returns the STRSXP vector of simple class names of the object o */ REPC SEXP RgetSimpleClassNames( SEXP e, SEXP addConditionClasses ){ SEXP ar = R_NilValue ; if (e==R_NilValue) return R_NilValue; jobject jobj ; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); jobj = (jobject)EXTPTR_PTR(e) ; } else { error("invalid object parameter"); } Rboolean add ; switch(TYPEOF(addConditionClasses)) { case LGLSXP: add = LOGICAL(addConditionClasses)[0]; break; case INTSXP: add = INTEGER(addConditionClasses)[0]; break; default: add = asLogical(addConditionClasses); } ar = getSimpleClassNames_asSEXP( jobj , (jboolean)add ) ; return ar; } rJava/src/Makevars.win0000644000175100001440000000177615133274032014425 0ustar hornikusers# To compile the Windows version, you need to: # - set JAVA_HOME to the JDK root (used for includes only) # in addition if the pre-compiled stuff is not present, then also: # - generate libjvm.dll.a from JDK's jvm.dll # (run `make' in `jvm-w32') # - copy WinRegistry.dll into inst/libs # You can modify the following line as the unlima ratio fallback. # Shouldn't be necessary, because JAVA_HOME and autodetection # have higher precedence. DEFAULT_JAVA_HOME=C:\\jdk1.4.2_04 # this file is generated by configure.win and honors JAVA_HOME env.var -include Makevars.java ifeq ($(JAVA_HOME),) JAVA_HOME:=$(DEFAULT_JAVA_HOME) endif $(warning JAVA_HOME is $(JAVA_HOME)) # normally you don't have to touch this unless you want to add # debugging flags like -DRJ_DEBUG or -DRJ_PROFILE to PKG_CFLAGS JAVA_INCLUDES=$(JAVA_HOME)/include $(JAVA_HOME)/include/win32 PKG_CPPFLAGS = -D_R_ -DWin32 -Ijvm-w32 -I$(RHOME)/src/include $(JAVA_INCLUDES:%=-I%) PKG_LIBS = -Ljvm-w32 -ljvm.dll $(warning PKG_CPPFLAGS are $(PKG_CPPFLAGS)) rJava/src/java/0000755000175100001440000000000015133274037013050 5ustar hornikusersrJava/src/java/RJavaTools_Test$ExampleClass.class0000644000175100001440000000071115133274037021467 0ustar hornikusersÊþº¾2  )(Ljava/lang/Object;Ljava/lang/String;ZZ)VCodeLineNumberTable((Ljava/lang/Object;Ljava/lang/String;Z)V()V SourceFileRJavaTools_Test.java  RJavaTools_Test$ExampleClass ExampleClass InnerClassesjava/lang/ObjectRJavaTools_Test *·± *·±  *·±     rJava/src/java/PrimitiveArrayException.java0000644000175100001440000000044515133274032020537 0ustar hornikusers/** * Generated when one tries to convert an arrays into * a primitive array of the wrong type */ public class PrimitiveArrayException extends Exception{ public PrimitiveArrayException(String type){ super( "cannot convert to single dimension array of primitive type" + type ) ; } } rJava/src/java/ObjectArrayException.java0000644000175100001440000000040115133274032017765 0ustar hornikusers/** * Generated when one tries to access an array of primitive * values as an array of Objects */ public class ObjectArrayException extends Exception{ public ObjectArrayException(String type){ super( "array is of primitive type : " + type ) ; } } rJava/src/java/RJavaClassLoader$RJavaObjectInputStream.class0000644000175100001440000000156515133274037023541 0ustar hornikusersÊþº¾2-      this$0LRJavaClassLoader;*(LRJavaClassLoader;Ljava/io/InputStream;)VCodeLineNumberTable Exceptions! resolveClass.(Ljava/io/ObjectStreamClass;)Ljava/lang/Class;" SourceFileRJavaClassLoader.java  #$ %&' ()* +,'RJavaClassLoader$RJavaObjectInputStreamRJavaObjectInputStream InnerClassesjava/io/ObjectInputStreamjava/io/IOException java/lang/ClassNotFoundException(Ljava/io/InputStream;)Vjava/io/ObjectStreamClassgetName()Ljava/lang/String;RJavaClassLoadergetPrimaryLoader()LRJavaClassLoader;java/lang/ClassforName=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;    + *+µ*,·± rs t $ +¶¸¸° v rJava/src/java/RJavaTools_Test.java0000644000175100001440000006424215133274032016741 0ustar hornikusers // :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Constructor ; import java.lang.reflect.* ; import java.util.Map ; import java.util.Set ; import java.util.HashMap; public class RJavaTools_Test { private static class ExampleClass { public ExampleClass( Object o1, String o2, boolean o3, boolean o4){} public ExampleClass( Object o1, String o2, boolean o3){} public ExampleClass(){} } /* so that we can check about access to private fields and methods */ private int bogus = 0 ; private int getBogus(){ return bogus ; } private static int staticbogus ; private static int getStaticBogus(){ return staticbogus ; } public int x = 0 ; public static int static_x = 0; public int getX(){ return x ; } public static int getStaticX(){ return static_x ; } public void setX( Integer x ){ this.x = x.intValue(); } // {{{ main public static void main( String[] args){ try{ runtests() ; } catch( TestException e){ fails( e ) ; System.exit(1); } } public static void runtests() throws TestException { System.out.println( "Testing RJavaTools.getConstructor" ) ; constructors() ; success() ; System.out.println( "Testing RJavaTools.classHasField" ) ; classhasfield() ; success(); System.out.println( "Testing RJavaTools.classHasMethod" ) ; classhasmethod() ; success() ; System.out.println( "Testing RJavaTools.classHasClass" ) ; classhasclass() ; success(); System.out.println( "Testing RJavaTools.hasField" ) ; hasfield() ; success(); System.out.println( "Testing RJavaTools.hasClass" ) ; hasclass() ; success(); System.out.println( "Testing RJavaTools.getClass" ) ; getclass() ; success() ; System.out.println( "Testing RJavaTools.hasMethod" ) ; hasmethod() ; success() ; System.out.println( "Testing RJavaTools.isStatic" ) ; isstatic() ; success() ; System.out.println( "Testing RJavaTools.getCompletionName" ) ; getcompletionname() ; success(); System.out.println( "Testing RJavaTools.getFieldNames" ) ; getfieldnames() ; success() ; System.out.println( "Testing RJavaTools.getMethodNames" ) ; getmethodnames() ; success() ; System.out.println( "Testing RJavaTools.getStaticFields" ) ; getstaticfields() ; success() ; System.out.println( "Testing RJavaTools.getStaticMethods" ) ; getstaticmethods() ; success() ; System.out.println( "Testing RJavaTools.getStaticClasses" ) ; getstaticclasses() ; success() ; System.out.println( "Testing RJavaTools.invokeMethod" ) ; invokemethod() ; success() ; System.out.println( "Testing RJavaTools.getFieldTypeName" ) ; getfieldtypename(); success() ; System.out.println( "Testing RJavaTools.getMethod" ) ; System.out.println( "NOT YET AVAILABLE" ) ; System.out.println( "Testing RJavaTools.newInstance" ) ; System.out.println( "NOT YET AVAILABLE" ) ; } // }}} // {{{ fails private static void fails( TestException e ){ System.err.println( "\n" ) ; e.printStackTrace() ; System.err.println( "FAILED" ) ; } // }}} // {{{ success private static void success(){ System.out.println( "PASSED" ) ; } // }}} // {{{ @Test getFieldNames private static void getfieldnames() throws TestException{ String[] names; // {{{ getFieldNames(DummyPoint, false) -> c('x', 'y' ) System.out.print( " * getFieldNames(DummyPoint, false)" ) ; names = RJavaTools.getFieldNames( DummyPoint.class, false ) ; if( names.length != 2 ){ throw new TestException( "getFieldNames(DummyPoint, false).length != 2" ) ; } for( int i=0; i<2; i++){ if( !( "x".equals(names[i]) || "y".equals(names[i] ) ) ){ throw new TestException( "getFieldNames(DummyPoint, false).length != c('x','y') " ) ; } } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(Point, true ) --> character(0) System.out.print( " * getFieldNames(DummyPoint, true )" ) ; names = RJavaTools.getFieldNames( DummyPoint.class, true ) ; if( names.length != 0 ){ throw new TestException( "getFieldNames(DummyPoint, true ) != character(0)" ); } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(RJavaTools_Test, true ) --> static_x System.out.print( " * getFieldNames(RJavaTools_Test, true )" ) ; names = RJavaTools.getFieldNames( RJavaTools_Test.class, true ) ; if( names.length != 1 ){ throw new TestException( "getFieldNames(RJavaTools_Test, true ).length != 1" ); } if( ! "static_x".equals( names[0] ) ){ throw new TestException( "getFieldNames(RJavaTools_Test, true )[0] != 'static_x' " ); } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(RJavaTools_Test, false ) --> c('x', 'static_x') System.out.print( " * getFieldNames(RJavaTools_Test, false )" ) ; names = RJavaTools.getFieldNames( RJavaTools_Test.class, false ) ; if( names.length != 2 ){ throw new TestException( "getFieldNames(RJavaTools_Test, false ).length != 2" ); } for( int i=0; i<2; i++){ if( ! ( "x".equals( names[i] ) || "static_x".equals(names[i]) ) ){ throw new TestException( "getFieldNames(RJavaTools_Test, false ) != c('x', 'static_x') " ); } } System.out.println( " : ok " ) ; // }}} } // }}} // {{{ @Test getMethodNames private static void getmethodnames() throws TestException{ String[] names ; String[] expected ; int cpt = 0; // {{{ getMethodNames(RJavaTools_Test, true) -> c('getStaticX()', 'main(', 'runtests' ) System.out.print( " * getMethodNames(RJavaTools_Test, true)" ) ; names = RJavaTools.getMethodNames( RJavaTools_Test.class, true ) ; if( names.length != 3 ){ throw new TestException( "getMethodNames(RJavaTools_Test, true).length != 3 (" + names.length + ")" ) ; } expected= new String[]{ "getStaticX()", "main(", "runtests()" }; cpt = 0; for( int i=0; i character(0) ) System.out.print( " * getMethodNames(Object, true)" ) ; names = RJavaTools.getMethodNames( Object.class, true ) ; if( names.length != 0 ){ throw new TestException( "getMethodNames(Object, true).length != 0 (" + names.length + ")" ) ; } System.out.println( " : ok " ) ; // }}} // {{{ getMethodNames(RJavaTools_Test, false) %contains% { "getX()", "getStaticX()", "setX(", "main(" } System.out.print( " * getMethodNames(RJavaTools_Test, false)" ) ; names = RJavaTools.getMethodNames( RJavaTools_Test.class, false ) ; cpt = 0; expected = new String[]{ "getX()", "getStaticX()", "setX(", "main(" }; for( int i=0; i false try{ System.out.print( " * isStatic(RJavaTools_Test.x)" ) ; f = RJavaTools_Test.class.getField("x") ; if( RJavaTools.isStatic( f) ){ throw new TestException( "isStatic(RJavaTools_Test.x) == true" ) ; } System.out.println( " = false : ok " ) ; } catch( NoSuchFieldException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.getX) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.getX() )" ) ; m = RJavaTools_Test.class.getMethod("getX", (Class[])null ) ; if( RJavaTools.isStatic( m ) ){ throw new TestException( "isStatic(RJavaTools_Test.getX() ) == false" ) ; } System.out.println( " = false : ok " ) ; } catch( NoSuchMethodException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.static_x) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.static_x)" ) ; f = RJavaTools_Test.class.getField("static_x") ; if( ! RJavaTools.isStatic( f) ){ throw new TestException( "isStatic(RJavaTools_Test.static_x) == false" ) ; } System.out.println( " = true : ok " ) ; } catch( NoSuchFieldException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.getStaticX) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.getStaticX() )" ) ; m = RJavaTools_Test.class.getMethod("getStaticX", (Class[])null ) ; if( ! RJavaTools.isStatic( m ) ){ throw new TestException( "isStatic(RJavaTools_Test.getStaticX() ) == false" ) ; } System.out.println( " = true : ok " ) ; } catch( NoSuchMethodException e){ throw new TestException( e.getMessage() ) ; } // }}} /* classes */ // {{{ isStatic(RJavaTools_Test.TestException) -> true System.out.print( " * isStatic(RJavaTools_Test.TestException )" ) ; Class cl = RJavaTools_Test.TestException.class ; if( ! RJavaTools.isStatic( cl ) ){ throw new TestException( "isStatic(RJavaTools_Test.TestException) == false" ) ; } System.out.println( " = true : ok " ) ; // }}} // {{{ isStatic(RJavaTools_Test.DummyNonStaticClass) -> false System.out.print( " * isStatic(RJavaTools_Test.DummyNonStaticClass )" ) ; cl = RJavaTools_Test.DummyNonStaticClass.class ; if( RJavaTools.isStatic( cl ) ){ throw new TestException( "isStatic(RJavaTools_Test.DummyNonStaticClass) == true" ) ; } System.out.println( " = false : ok " ) ; // }}} } // }}} // {{{ @Test constructors private static void constructors() throws TestException { /* constructors */ Constructor cons ; boolean error ; // {{{ getConstructor( String, null ) System.out.print( " * getConstructor( String, null )" ) ; try{ cons = RJavaTools.getConstructor( String.class, (Class[])null, (boolean[])null ) ; } catch( Exception e ){ throw new TestException( "getConstructor( String, null )" ) ; } System.out.println( " : ok " ) ; // }}} // {{{ getConstructor( Integer, { String.class } ) System.out.print( " * getConstructor( Integer, { String.class } )" ) ; try{ cons = RJavaTools.getConstructor( Integer.class, new Class[]{ String.class }, new boolean[]{false} ) ; } catch( Exception e){ throw new TestException( "getConstructor( Integer, { String.class } )" ) ; } System.out.println( " : ok " ) ; // }}} // disabled for now // // {{{ getConstructor( JButton, { String.class, ImageIcon.class } ) // System.out.print( " * getConstructor( JButton, { String.class, ImageIcon.class } )" ) ; // try{ // cons = RJavaTools.getConstructor( JButton.class, // new Class[]{ String.class, ImageIcon.class }, // new boolean[]{ false, false} ) ; // } catch( Exception e){ // throw new TestException( "getConstructor( JButton, { String.class, ImageIcon.class } )" ) ; // } // System.out.println( " : ok " ) ; // // }}} // {{{ getConstructor( Integer, null ) -> exception error = false ; System.out.print( " * getConstructor( Integer, null )" ) ; try{ cons = RJavaTools.getConstructor( Integer.class, (Class[])null, (boolean[])null ) ; } catch( Exception e){ error = true ; } if( !error ){ throw new TestException( "getConstructor( Integer, null ) did not generate error" ) ; } System.out.println( " -> exception : ok " ) ; // }}} // disabled for now // // {{{ getConstructor( JButton, { String.class, JButton.class } ) -> exception // error = false ; // System.out.print( " * getConstructor( JButton, { String.class, JButton.class } )" ) ; // try{ // cons = RJavaTools.getConstructor( JButton.class, // new Class[]{ String.class, JButton.class }, // new boolean[]{ false, false } ) ; // } catch( Exception e){ // error = true ; // } // if( !error ){ // throw new TestException( "getConstructor( JButton, { String.class, JButton.class } ) did not generate error" ) ; // } // System.out.println( " -> exception : ok " ) ; // // }}} Object o1 = null ; Object o2 = null ; ExampleClass foo = new ExampleClass(o1,(String)o2,false) ; // {{{ getConstructor( ExampleClass, { null, null, false } error = false ; System.out.print( " * getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : " ) ; try{ cons = RJavaTools.getConstructor( ExampleClass.class, new Class[]{ Object.class, Object.class, Boolean.TYPE}, new boolean[]{ true, true, false} ); } catch(Exception e){ error = true ; e.printStackTrace() ; } if( error ){ throw new TestException( "getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : exception " ) ; } System.out.println( " ok" ) ; // }}} } // }}} // {{{ @Test methods private static void methods() throws TestException{ } // }}} // {{{ @Test hasfields private static void hasfield() throws TestException{ DummyPoint p = new DummyPoint() ; System.out.println( " java> DummyPoint p = new DummyPoint()" ) ; System.out.print( " * hasField( p, 'x' ) " ) ; if( !RJavaTools.hasField( p, "x" ) ){ throw new TestException( " hasField( DummyPoint, 'x' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasField( p, 'iiiiiiiiiiiii' ) " ) ; if( RJavaTools.hasField( p, "iiiiiiiiiiiii" ) ){ throw new TestException( " hasField( DummyPoint, 'iiiiiiiiiiiii' ) == true" ) ; } System.out.println( " false : ok" ) ; /* testing a private field */ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * testing a private field " ) ; if( RJavaTools.hasField( ob, "bogus" ) ){ throw new TestException( " hasField returned true on private field" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test hasmethod private static void hasmethod() throws TestException{ DummyPoint p = new DummyPoint() ; System.out.println( " java> DummyPoint p = new DummyPoint()" ) ; System.out.print( " * hasMethod( p, 'move' ) " ) ; if( !RJavaTools.hasMethod( p, "move" ) ){ throw new TestException( " hasField( DummyPoint, 'move' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasMethod( p, 'iiiiiiiiiiiii' ) " ) ; if( RJavaTools.hasMethod( p, "iiiiiiiiiiiii" ) ){ throw new TestException( " hasMethod( Point, 'iiiiiiiiiiiii' ) == true" ) ; } System.out.println( " false : ok" ) ; /* testing a private method */ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * testing a private method " ) ; if( RJavaTools.hasField( ob, "getBogus" ) ){ throw new TestException( " hasMethod returned true on private method" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test hasclass private static void hasclass() throws TestException{ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * hasClass( RJavaTools_Test, 'TestException' ) " ) ; if( ! RJavaTools.hasClass( ob, "TestException" ) ){ throw new TestException( " hasClass( RJavaTools_Test, 'TestException' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) " ) ; if( ! RJavaTools.hasClass( ob, "DummyNonStaticClass" ) ){ throw new TestException( " hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) == false" ) ; } System.out.println( " true : ok" ) ; } // }}} // {{{ @Test hasclass private static void getclass() throws TestException{ Class cl ; System.out.print( " * getClass( RJavaTools_Test, 'TestException', true ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "TestException", true ); if( cl != RJavaTools_Test.TestException.class ){ throw new TestException( " getClass( RJavaTools_Test, 'TestException', true ) != TestException" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "DummyNonStaticClass", true ); if( cl != null ){ throw new TestException( " getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getClass( RJavaTools_Test, 'DummyNonStaticClass', false ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "DummyNonStaticClass", false ); if( cl != RJavaTools_Test.DummyNonStaticClass.class ){ throw new TestException( " getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null" ) ; } System.out.println( " : ok" ) ; } // }}} // {{{ @Test classhasfield private static void classhasfield() throws TestException{ } // }}} // {{{ @Test classhasclass private static void classhasclass() throws TestException{ System.out.print( " * classHasClass( RJavaTools_Test, 'TestException', true ) " ) ; if( ! RJavaTools.classHasClass( RJavaTools_Test.class , "TestException", true ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'TestException', true ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) " ) ; if( RJavaTools.classHasClass( RJavaTools_Test.class , "DummyNonStaticClass", true ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) == true" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) " ) ; if( ! RJavaTools.classHasClass( RJavaTools_Test.class , "DummyNonStaticClass", false ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) == false" ) ; } System.out.println( " true : ok" ) ; } // }}} // {{{ @Test classhasmethod private static void classhasmethod() throws TestException{ System.out.print( " * classHasMethod( RJavaTools_Test, 'getX', false ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getX", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getX', false ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticX', false ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticX", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getStaticX', false ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getX', true ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getX", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getX', true ) == true (non static method)" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticX', true ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticX", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getStaticX', true ) == false (static)" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getBogus', false ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getBogus", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getBogus', false ) == true (private method)" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticBogus', true ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticBogus", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getBogus', true ) == true (private method)" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test getstaticfields private static void getstaticfields() throws TestException{ Field[] f ; System.out.print( " * getStaticFields( RJavaTools_Test ) " ) ; f = RJavaTools.getStaticFields( RJavaTools_Test.class ) ; if( f.length != 1 ){ throw new TestException( " getStaticFields( RJavaTools_Test ).length != 1" ) ; } if( ! "static_x".equals( f[0].getName() ) ){ throw new TestException( " getStaticFields( RJavaTools_Test )[0] != 'static_x'" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getStaticFields( Object ) " ) ; f = RJavaTools.getStaticFields( Object.class ) ; if( f != null ){ throw new TestException( " getStaticFields( Object ) != null" ) ; } System.out.println( " : ok" ) ; } // }}} // {{{ @Test getstaticmethods private static void getstaticmethods() throws TestException{ Method[] m ; // {{{ getStaticMethods( RJavaTools_Test ) System.out.print( " * getStaticMethods( RJavaTools_Test ) " ) ; m = RJavaTools.getStaticMethods( RJavaTools_Test.class ) ; String[] expected = new String[]{ "getStaticX" , "main", "runtests" }; int count = 0; if( m.length != expected.length ){ throw new TestException( " getStaticMethods( RJavaTools_Test ).length != 2" ) ; } for( int i=0; i()VCodeLineNumberTable(II)VgetX()Dmoveclone()Ljava/lang/Object; SourceFileDummyPoint.java    DummyPointjava/lang/Objectjava/lang/Cloneable!    #*·±   3*·*µ*µ±   *´‡¯  5*Y´`µ*Y´`µ±  (»Y*´*´·°rJava/src/java/RJavaImport.class0000644000175100001440000000656415133274037016310 0ustar hornikusersÊþº¾2° 3W 1XY W 1Z[ W 1\ 1] 1^ _`a Wb cdef Dg h Ei jk jlm Dno jp qr st uvwx y 1z{ | } 1~ j Oq O€ O‚ Rƒ R„… 1†‡ˆDEBUGZimportedPackagesLjava/util/Vector;cacheLjava/util/Map;loaderLjava/lang/ClassLoader;(Ljava/lang/ClassLoader;)VCodeLineNumberTablelookup%(Ljava/lang/String;)Ljava/lang/Class; StackMapTable‰Šlookup_exists(Ljava/lang/String;)Zexists_ importPackage(Ljava/lang/String;)V([Ljava/lang/String;)VgetKnownClasses()[Ljava/lang/String;‹Œ4(Ljava/lang/String;Ljava/util/Set;)Ljava/lang/Class;()V SourceFileRJavaImport.java =T ;<java/util/Vector 78java/util/HashMap 9: FB 56Ž java/lang/StringBuilder [J] lookup( ' ‘’' ) =  ' “” •” –K— ˜™ š›java/lang/String œBjava/lang/Exception ž Ÿ  [J] ‘¡ packages š¢. [J] trying class :  [JE] £” IH [J] exists( ' ‘¤ ¥™ JK ¦§ ¨©! [J] getKnownClasses().length = ª« ¬­ ®¯ RJavaImport ABjava/lang/Objectjava/io/Serializablejava/lang/Classjava/io/PrintStream java/util/Set[Ljava/lang/String;java/util/Iteratorjava/lang/SystemoutLjava/io/PrintStream;append-(Ljava/lang/String;)Ljava/lang/StringBuilder;getName()Ljava/lang/String;toStringprintln java/util/Map containsKey(Ljava/lang/Object;)Zget&(Ljava/lang/Object;)Ljava/lang/Object;forNameput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;size()I(I)Ljava/lang/StringBuilder;(I)Ljava/lang/Object; getMessage(Z)Ljava/lang/StringBuilder;addkeySet()Ljava/util/Set;toArray(([Ljava/lang/Object;)[Ljava/lang/Object;iterator()Ljava/util/Iterator;hasNext()Znext()Ljava/lang/Object;!134 56789:;< =>?H *·*+µ*»Y·µ*»Y·µ±@23 456AB?«S*+· M² ™H² » Y· ¶+¶¶,ǧ» Y· ¶,¶¶¶¶¶¶¶,°@@AQBC2ÿ-1DE ÿ1DE FB?óM*´+¹™*´+¹ÀN-¸:°N+¸M§N,Æ*´++¹W,°*´¶>² ™!² » Y· ¶¶¶¶¶ž6¢”*´¶ À:» Y· ¶!¶+¶¶:² ™² » Y· "¶¶¶¶¸M§(:² ™ ² » Y· #¶¶$¶¶¶,Æ*´+,¶¹W,°„§ÿl°%&',/{ÉÌ@nFHJK#L&M'T,U0V4W@XB[J\n]r^{`‰a£bÃcÉfÌdÎeñgõhi^ mCG ÿ&1DGü+üýMÿ1D$úGH?\0*+¶%=² ™%² » Y· &¶+¶¶¶'¶¶¬@tu.vCü.IH?E*´+¹™¬*+· Ƨ¬@ z|C @JK?& *´+¶(W±@ … †JL?I=+¾¢*+2¶)„§ÿð±@ŽŽ‘C üúMN?~@*´¹*L+¹+=½N+-¹,W² ™² » Y· -¶-¾¶¶¶-°@˜ ™š›œ>C þ>OP AQ?-+¹.N-¹/™-¹0À1:*¶2M,Æ,°§ÿß°@¢£¤¥"¦(§+¨C-ýRÿ ODRÿORST?³ ±@UVrJava/src/java/RJavaArrayTools_Test.class0000644000175100001440000005613215133274037020130 0ustar hornikusersÊþº¾2T ‚› œž Ÿ  ¡¢ £ œ¤¥ ¦ §¨ ©ª «¬ ­® ¯° ±² ³´ µ œ¶· ¸¹º» Ÿ¼ ½¾¿ ÀÁ ½ÃÄÅ ½ÆÇÈ ½ÉÊË ½ÌÍÎÏÐ ½ÑÒÓ ½ÔÕÖ× ½ØÙÚÛÜÝÞßàáâ ½ãäåæçèéêëìíîïðñòóôõö@$™™™™™š ÷øùúûü ½ýþÿ ½ ½ ½  ½    ½ ½ ½ !"#$%&'()*+,-./0123456789 ½:;< ½=>? ½@AB ½CDE ½FGHIJ ½KLM ½NOPQR ½STUVWXYZ[\]^_ ½`ab ½cde ½fgh ½ijk ½lmnop ½qrs ½tuvwxy ½z{| ½}~ ½€‚ ½ƒ„… ½†‡ˆ‰Š ½‹Œ ½Ž ½‘’“”•–—˜™š›œžŸ  ½¡¢ –£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàá ½âãä ½åæç ½èéê ½ëìí ½îïðñò ½óôõ ½ö÷øùúû ½üýþÿ      t ½ t@$()VCodeLineNumberTablemain([Ljava/lang/String;)V StackMapTableruntests Exceptionsfails(LTestException;)Vsuccessisarray getdimlengthgetdims gettruelengthisrect gettypenameisprimrep SourceFileRJavaArrayTools_Test.java ƒ„  !Test suite for RJavaArrayTools" #$ Š„ TestException Œ %&Testing RJavaArrayTools.isArray „ Ž„*Testing RJavaArrayTools.isRectangularArray “„*Testing RJavaArrayTools.getDimensionLength „%Testing RJavaArrayTools.getDimensions ‘„%Testing RJavaArrayTools.getTrueLength ’„)Testing RJavaArrayTools.getObjectTypeName •„+Testing RJavaArrayTools.isPrimitiveTypeName —„Testing RJavaTools.rep ˜„ '! („FAILEDPASSED isArray( int ) )$* +, isArray( int ) ƒ$ false : ok isArray( boolean ) +- isArray( boolean )  isArray( byte ) +. isArray( byte )  isArray( long ) +/ isArray( long )  isArray( short ) +0 isArray( short )  isArray( double ) isArray( double )  isArray( char ) +1 isArray( char )  isArray( float ) +2 isArray( float )  isArray( String )dd +3 isArray( String )  isArray( int[] ) !isArray( int[] )  true : ok/ isArray( double[] (but declared as 0bject) )' !isArray( Object o = new double[2]; )  isArray( null ) isArray( null)  >> actual arrays int[] o = new int[10] ; 45"getDimensionLength( int[10] ) != 1NotAnArrayExceptionnot an array int[10] 1 : ok  int[] o = new int[0] ;!getDimensionLength( int[0] ) != 1not an array int[0][[Ljava/lang/Object; new Object[10][10]-getDimensionLength( new Object[10][10] ) != 2not an array Object[10][10] 2 : ok [[[Ljava/lang/Object; new Object[10][10][10]0getDimensionLength( new Object[10][10][3] ) != 3not an array Object[10][10][3] 3 : ok  >> Object new Double('10.2') 6 782getDimensionLength(Double) did not throw exception -> NotAnArrayException : ok  >> Testing primitive types getDimensionLength( int ) 491 getDimensionLength( int ) not throwing exception ok getDimensionLength( boolean ) 4:5 getDimensionLength( boolean ) not throwing exception : ok getDimensionLength( byte ) 4;2 getDimensionLength( byte ) not throwing exception getDimensionLength( long ) 4<2 getDimensionLength( long ) not throwing exception getDimensionLength( short ) 4=3 getDimensionLength( short ) not throwing exception : ok getDimensionLength( double )4 getDimensionLength( double ) not throwing exception getDimensionLength( char ) 4>3 getDimensionLength( char ) not throwing exception  getDimensionLength( float ) 4?4 getDimensionLength( float ) not throwing exception  getDimensionLength( null )java/lang/NullPointerException;getDimensionLength( null ) throwing wrong kind of exception3 getDimensionLength( null ) not throwing exception @A#getDimensions( int[10]).length != 1 getDimensions( int[10])[0] != 10 c( 10 ) : ok +getDimensions( Object[10][10] ).length != 2(getDimensions( Object[10][10] )[0] != 10(getDimensions( Object[10][10] )[1] != 10 c(10,10) : ok /getDimensions( Object[10][10][10] ).length != 3,getDimensions( Object[10][10][10] )[0] != 10,getDimensions( Object[10][10][10] )[1] != 10not an array Object[10][10][10] c(10,10,10) : ok  >> zeroes "getDimensions( int[0]).length != 1getDimensions( int[0])[0] != 0 c(0) : ok  new Object[10][10][0].getDimensions( Object[10][10][0] ).length != 3+getDimensions( Object[10][10][0] )[0] != 10+getDimensions( Object[10][10][0] )[1] != 10*getDimensions( Object[10][10][0] )[1] != 0not an array Object[10][10][0] c(10,10,0) : ok  new Object[10][0][10]-getDimensions( Object[10][0][0] ).length != 3*getDimensions( Object[10][0][0] )[0] != 10)getDimensions( Object[10][0][0] )[1] != 0not an array Object[10][0][10] c(10,0,0) : ok -getDimensions(Double) did not throw exception getDimensions( int ) @B, getDimensions( int ) not throwing exception getDimensions( boolean ) @C0 getDimensions( boolean ) not throwing exception getDimensions( byte ) @D- getDimensions( byte ) not throwing exception getDimensions( long ) @E- getDimensions( long ) not throwing exception getDimensions( short ) @F. getDimensions( short ) not throwing exception getDimensions( double )/ getDimensions( double ) not throwing exception getDimensions( char ) @G. getDimensions( char ) not throwing exception  getDimensions( float ) @H/ getDimensions( float ) not throwing exception  getDimensions( null )6getDimensions( null ) throwing wrong kind of exception. getDimensions( null ) not throwing exception I5getTrueLength( int[10]) != 10 10 : ok &getTrueLength( Object[10][10] ) != 100 100 : ok +getTrueLength( Object[10][10][10] ) != 1000 1000 : ok getTrueLength( int[0]) != 0'getTrueLength( Object[10][10][0] ) != 0 0 : ok &getTrueLength( Object[10][0][0] ) != 0-getTrueLength(Double) did not throw exception getTrueLength( int ) I9, getTrueLength( int ) not throwing exception getTrueLength( boolean ) I:0 getTrueLength( boolean ) not throwing exception getTrueLength( byte ) I;- getTrueLength( byte ) not throwing exception getTrueLength( long ) I<- getTrueLength( long ) not throwing exception getTrueLength( short ) I=. getTrueLength( short ) not throwing exception getTrueLength( double )/ getTrueLength( double ) not throwing exception getTrueLength( char ) I>. getTrueLength( char ) not throwing exception  getTrueLength( float ) I?/ getTrueLength( float ) not throwing exception  getTrueLength( null )6getTrueLength( null ) throwing wrong kind of exception. getTrueLength( null ) not throwing exception  isRectangularArray( int ) J, isRectangularArray( int )  isRectangularArray( boolean ) J- isRectangularArray( boolean )  isRectangularArray( byte ) J. isRectangularArray( byte )  isRectangularArray( long ) J/ isRectangularArray( long )  isRectangularArray( short ) J0 isRectangularArray( short )  isRectangularArray( double ) isRectangularArray( double )  isRectangularArray( char ) J1 isRectangularArray( char )  isRectangularArray( float ) J2 isRectangularArray( float )  isRectangularArray( String ) J3 isRectangularArray( String )  isRectangularArray( int[] ) !isRectangularArray( int[] ) : isRectangularArray( double[] (but declared as 0bject) )2 !isRectangularArray( Object o = new double[2]; )  isRectangularArray( null ) isRectangularArray( null) [[I$ isRectangularArray( new int[3][4] )& !isRectangularArray( new int[3][4] ) [I& isRectangularArray( new int[2][2,4] )( !isRectangularArray( new int[2][2,4] ) + isRectangularArray( new int[2][2][10,25] )- !isRectangularArray( new int[2][2][10,25] ) KLI M3 getObjectTypeName(int[]) != 'I'  I : ok  boolean[]Z$getObjectTypeName(boolean[]) != 'Z' not an array boolean[10] Z : ok  byte[]B!getObjectTypeName(byte[]) != 'B' not an array byte[10] B : ok  long[]J!getObjectTypeName(long[]) != 'J' not an array long[10] J : ok  short[]S"getObjectTypeName(short[]) != 'S' not an array short[10] S : ok  double[]D#getObjectTypeName(double[]) != 'D' not an array double[10] D : ok  char[]C!getObjectTypeName(char[]) != 'C' not an array char[10] C : ok  float[]F"getObjectTypeName(float[]) != 'F' not an array float[10] F : ok  >> multi dim primitive arrays int[][] ; boolean[][][[Z byte[][][[B long[][][[J short[][][[S double[][][[D char[][][[C float[][][[Fjava.lang.Object4getObjectTypeName(Object[][]) != 'java.lang.Object'  : ok >getObjectTypeName( Object[10][10][10] ) != 'java.lang.Object' !getObjectTypeName(int[0]) != 'I' =getObjectTypeName( Object[10][10][0] ) != 'java.lang.Object' 2 getObjectTypeName( char ) not throwing exception  getObjectTypeName( float ) K?3 getObjectTypeName( float ) not throwing exception  getObjectTypeName( null ):getObjectTypeName( null ) throwing wrong kind of exception2 getObjectTypeName( null ) not throwing exception  isPrimitiveTypeName( 'I' ) NOI not primitive true : ok  isPrimitiveTypeName( 'Z' ) Z not primitive isPrimitiveTypeName( 'B' ) B not primitive isPrimitiveTypeName( 'J' ) J not primitive isPrimitiveTypeName( 'S' ) S not primitive isPrimitiveTypeName( 'D' ) D not primitive isPrimitiveTypeName( 'C' ) C not primitive isPrimitiveTypeName( 'F' ) F not primitive+ isPrimitiveTypeName( 'java.lang.Object' ) Object primitive false : ok  DummyPoint ƒP rep( DummyPoint, 10) ˜Q [LDummyPoint;java/lang/Throwablerep(DummyPoint, 10) failed rep(DummyPoint, 10).length != 10 RS#rep(DummyPoint, 10)[5].getX() != 10: ok RJavaArrayTools_Testjava/lang/Object[[[Ijava/lang/Stringjava/lang/SystemoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vexit(I)VerrprintStackTraceprintRJavaArrayToolsisArray(I)Z(Z)Z(B)Z(J)Z(D)Z(C)Z(F)Z(Ljava/lang/Object;)ZgetDimensionLength(Ljava/lang/Object;)Ijava/lang/DoublevalueOf(D)Ljava/lang/Double;(I)I(Z)I(B)I(J)I(D)I(C)I(F)I getDimensions(Ljava/lang/Object;)[I(I)[I(Z)[I(B)[I(J)[I(D)[I(C)[I(F)[I getTrueLengthisRectangularArraygetObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;equalsisPrimitiveTypeName(Ljava/lang/String;)Z(II)V((Ljava/lang/Object;I)[Ljava/lang/Object;getX()D!‚ ƒ„…*·±† ‡ˆ…e²¶¸§ L+¸¸¸± †"    ‰N Š„…õy²¶² ¶¸ ¸ ² ¶¸ ¸ ²¶¸¸ ²¶¸¸ ²¶¸¸ ²¶¸¸ ²¶¸¸ ²¶¸¸ ±†j!$, /!2#:$=%@'H(K)N+V,Y-\/d0g1j3r4u5x7‹ Œ…9²¶*¶²¶±†<= >? Ž„…% ²¶±† DE „…•—²¶ ¸!™ »Y"·#¿²$¶²%¶ ¸&™ »Y'·#¿²$¶²(¶ ¸)™ »Y*·#¿²$¶²+¶ ¸,™ »Y-·#¿²$¶².¶ ¸/™ »Y0·#¿²$¶²1¶ ¸/™ »Y2·#¿²$¶²3¶ a¸4™ »Y5·#¿²$¶²6¶ ¸7™ »Y8·#¿²$¶²9¶ :¸;™ »Y<·#¿²$¶¼ K²=¶ *¸;š »Y>·#¿²?¶¼L²@¶ +¸;š »YA·#¿²?¶²B¶ ¸;™ »YC·#¿²$¶±†Î3LMNP!T)U0V:XB\J]Q^[`cdkerf|h„lŒm“np¥t­u´v¾xÆ|Î}Ö~à€è„ð…÷†ˆ ŒŽ#+”/•7–>—H™PTž\Ÿc m¢u¦}§„¨Žª–®‰  ! !ü$ü$‚ ‹ „…®òD¶ ¼ K²E¶ *¸FŸ »YG·#¿§L»YI·#¿²J¶¼ K²K¶ *¸FŸ »YL·#¿§L»YM·#¿²J¶  ÅNL²O¶ +¸FŸ »YP·#¿§M»YQ·#¿²R¶   ÅSM²T¶ ,¸FŸ »YU·#¿§N»YV·#¿²W¶²X¶²Y¶ >Z¸\¸FW§:>š »Y]·#¿²^¶²_¶²`¶ >¸aW§:>š »Yb·#¿²c¶²d¶ >¸eW§:>š »Yf·#¿²g¶²h¶ >¸iW§:>š »Yj·#¿²g¶²k¶ > ¸lW§:>š »Ym·#¿²c¶²n¶ >¸oW§:>š »Yp·#¿²q¶²r¶ >¸oW§:>š »Ys·#¿²g¶²t¶ >a¸uW§:>š »Yv·#¿²g¶²w¶ > ¸xW§:>š »Yy·#¿²g¶²z¶ >¸FW§:>§:»Y|·#¿š »Y}·#¿²g¶±'*HI[^H‚”—H½ÏÒH÷H058H\adHˆH´¹¼HàåèH H8>AHejmH‘–™{‘– H†âx´· ¸º»'¿*½+¾5À=ÄAÅIÇQÈ[Ì^Ê_ËiÍqÑz҂ԊՔٗטآڪ޵߽áÅâÏæÒäÓåÝçåëííõî÷ðóñòô õ÷û&þ.ÿ058:<JR Z \ adfhv~†ˆ’”¢ª"²#´%¹(¼&¾'À)Î*Ö.Þ/à1å4è2ê3ì5ú6: ; =@>?A&B.F6G8I>LAJCKEMSN[RcSeUjXmVoWqYZ‡`a‘c–h™d›eh f¢g¬iºjÂm‰y+ü'BH %BH ü*NBH ü,SBH ÿ&NSH aH YH YH YH YH YH ZH YH Y{FH ‹ ‘„…-OK ¼ L²E¶ +¸~K*¾Ÿ »Y·#¿*. Ÿ »Y€·#¿§M»YI·#¿²¶  ÅNM²O¶ ,¸~K*¾Ÿ »Y‚·#¿*. Ÿ »Yƒ·#¿*. Ÿ »Y„·#¿§N»YQ·#¿²…¶   ÅSN²T¶ -¸~K*¾Ÿ »Y†·#¿*. Ÿ »Y‡·#¿*. Ÿ »Yˆ·#¿*. Ÿ »Yˆ·#¿§:»Y‰·#¿²ж²‹¶¼ L²K¶ +¸~K*¾Ÿ »YŒ·#¿*.™ »Y·#¿§:»YM·#¿²޶  ÅSN²¶ -¸~K*¾Ÿ »Y·#¿*. Ÿ »Y‘·#¿*. Ÿ »Y’·#¿*.™ »Y“·#¿§:»Y”·#¿²•¶  ÅSN²–¶ -¸~K*¾Ÿ »Y—·#¿*. Ÿ »Y˜·#¿*.™ »Y™·#¿*.™ »Y™·#¿§:»Yš·#¿²›¶²X¶²Y¶ 6Z¸\¸~K§:6š »Yœ·#¿²^¶²_¶²¶ 6¸žW§:6š »YŸ·#¿²c¶² ¶ 6¸¡W§:6š »Y¢·#¿²g¶²£¶ 6¸¤W§:6š »Y¥·#¿²g¶²¦¶ 6 ¸§W§:6š »Y¨·#¿²c¶²©¶ 6¸ªW§:6š »Y«·#¿²q¶²¬¶ 6¸ªW§:6š »Y­·#¿²g¶²®¶ 6a¸¯W§:6š »Y°·#¿²g¶²±¶ 6 ¸²W§:6š »Y³·#¿²g¶²´¶ 6¸~W§:6§:»Yµ·#¿š »Y¶·#¿²g¶±69H]–™H¿  H5Z]HƒÌÏHõ<?HfpsH¢§ªHÑÖÙHH/47H^cfH’•H¼ÂÅHìñôH #{ +H†¦©rvwyz{$},~6‚9€:DƒL‡Uˆ]Šb‹hŒrŽz„‘Œ’––™”𕤗¬›·œ¿žÄŸÊ Ô¢Ü£æ¥î¦ø¨© ­ «¬®!³)¶-·5¹:º@»J½P¾ZÂ]À_ÁiÃqÇ{ȃʈˎ̘ΠϪѲҼÔÂÕÌÙÏ×ÑØÛÚãÞíßõáúâã åæè"é,ë2ì<ð?îAïKñS÷[ùcúfüpÿsýuþx}‡— Ÿ ¢ §ª¬¯¾ÆÎÑÖÙÛÞíõ"ý#%(& ' )*$.,//1447293<5K6S:[;^=c@f>h?kAzB‚FŠGI’L•J—KšM©N±R¹S¼UÂXÅVÇWÊYÙZá^é_ìañdôböcùeflmo t#p%q(t+r-s7uFvNz‰˜>ý$BH ü-NBH ü/SBH 0BH .BH .BH ÿ'NSHbHZHZHZHZHZH[HZHZ{GH ‹ ’„…Íh; ¼ L²E¶ +¸·; Ÿ »Y¸·#¿§M»YI·#¿²¹¶  ÅNM²O¶ ,¸·;dŸ »Yº·#¿§N»YQ·#¿²»¶   ÅSN²T¶ -¸·;èŸ »Y¼·#¿§:»Y‰·#¿²½¶²‹¶¼ L²K¶ +¸·;™ »Y¾·#¿§:»YM·#¿²޶  ÅSN²¶ -¸·;™ »Y¿·#¿§:»Y”·#¿²À¶  ÅSN²–¶ -¸·;™ »YÁ·#¿§:»Yš·#¿²À¶²X¶²Y¶ 6Z¸\¸·;§:6š »Y·#¿²^¶²_¶²ö 6¸ÄW§:6š »YÅ·#¿²c¶²ƶ 6¸ÇW§:6š »YÈ·#¿²g¶²ɶ 6¸ÊW§:6š »YË·#¿²g¶²̶ 6 ¸ÍW§:6š »Yη#¿²c¶²϶ 6¸ÐW§:6š »YÑ·#¿²q¶²Ò¶ 6¸ÐW§:6š »YÓ·#¿²g¶²Ô¶ 6a¸ÕW§:6š »YÖ·#¿²g¶²×¶ 6 ¸ØW§:6š »YÙ·#¿²g¶²Ú¶ 6¸·W§:6§:»YÛ·#¿š »YÜ·#¿²g¶±$'HK`cH‰Ÿ¢HÊÝàHHBUXH‰ŒH»ÀÃHêïòH!HHMPHw|H¦«®HÕÛÞH  H49<{49DH†>ƒ„†‡ˆ$Œ'Š(‹2:‘C’K”P•V–`šc˜d™n›vŸ ‰¢Ž£•¤Ÿ©¢§¤¨®ª¶¯¾²Â³ÊµÏ¶Ó·Ý»à¹âºì¼ôÀþÁà ÄÅÉÇÈ(Ê0Î:ÏBÑGÒKÓU×XÕZÖdØlÞtà|áã‰æŒäŽå‘ç–è ê¨ï°ò¸ó»õÀøÃöÅ÷Èù×úßþçÿêïòô÷   !#&5=EHMPRUdl"t#w%|(&'„)“*›.£/¦1«4®2°3³5Â6Ê:Ò;Õ=Û@Þ>à?ãAòBúFGI L JKM!N)T1U4W9\<X>YA\DZF[P]_^gb‰‡1ý$BH ü-NBH ü0SBH .BH ,BH ,BH ÿ'NSHbHZHZHZHZHZH[HZHZ{GH ‹ “„…—7²ݶ ¸Þ™ »Yß·#¿²$¶²à¶ ¸á™ »Yâ·#¿²$¶²ã¶ ¸ä™ »Yå·#¿²$¶²æ¶ ¸ç™ »Yè·#¿²$¶²é¶ ¸ê™ »Yë·#¿²$¶²ì¶ ¸ê™ »Yí·#¿²$¶²î¶ a¸ï™ »Yð·#¿²$¶²ñ¶ ¸ò™ »Yó·#¿²$¶²ô¶ :¸õ™ »Yö·#¿²$¶¼ K²÷¶ *¸õš »Yø·#¿²?¶¼L²ù¶ +¸õš »Yú·#¿²?¶²û¶ ¸õ™ »Yü·#¿²$¶ÅýM²þ¶ ,¸õš »Yÿ·#¿²?¶½N-¼ S-¼ S²¶ -¸õ™»Y·#¿²$¶½ý:½S2¼ S2¼ S²¶ ¸õ™»Y·#¿²$¶±†Gijkm!q)r0s:uByJzQ{[}ck‚rƒ|…„‰ŒŠ“‹¥‘­’´“¾•ƙΚ֛àè¡ð¢÷£¥ ©ª«#­+±/²7³>´H¶PºT»\¼c½m¿uÃ}ĄŎǖË̥ͬζоÔÃÕÉÖÏØØÙßÚêÜòàøáâ ãåæ#ç.é6ë‰* ! !ü$ü$‚ ü'ýü3ýüC”‹ •„… tP²E¶ ¼ ¸K*¶š»Y·#¿§L»YI·#¿² ¶² ¶ ¼¸K* ¶š»Y ·#¿§L»Y ·#¿²¶²¶ ¼¸K*¶š»Y·#¿§L»Y·#¿²¶²¶ ¼ ¸K*¶š»Y·#¿§L»Y·#¿²¶²¶ ¼ ¸K*¶š»Y·#¿§L»Y·#¿²¶²¶ ¼¸K*¶š»Y ·#¿§L»Y!·#¿²"¶²#¶ ¼¸K*$¶š»Y%·#¿§L»Y&·#¿²'¶²(¶ ¼¸K*)¶š»Y*·#¿§L»Y+·#¿²,¶²-¶².¶ Åý¸K*¶š»Y·#¿§L»YI·#¿² ¶²/¶ Å0¸K* ¶š»Y ·#¿§L»Y ·#¿²¶²1¶ Å2¸K*¶š»Y·#¿§L»Y·#¿²¶²3¶ Å4¸K*¶š»Y·#¿§L»Y·#¿²¶²5¶ Å6¸K*¶š»Y·#¿§L»Y·#¿²¶²7¶ Å8¸K*¶š»Y ·#¿§L»Y!·#¿²"¶²9¶ Å:¸K*$¶š»Y%·#¿§L»Y&·#¿²'¶²;¶ Å<¸K*)¶š»Y*·#¿§L»Y+·#¿²,¶  ÅNL²O¶ +¸K*=¶š»Y>·#¿§M»YQ·#¿²?¶   ÅSM²T¶ ,¸K*=¶š»Y@·#¿§N»Y‰·#¿²½¶²‹¶¼ N²K¶ -¸K*¶š»YA·#¿§:»YM·#¿²?¶  ÅSM²¶ ,¸K*=¶š»YB·#¿§:»Y”·#¿²?¶  ÅSM²–¶ ,¸K*=¶š»YC·#¿§:»Yš·#¿²À¶²X¶²Y¶ 6Z¸\¸K§:6š»YD·#¿²^¶²_¶²E¶ 6¸FW§:6š»YG·#¿²c¶²H¶ 6¸IW§:6š»YJ·#¿²g¶²K¶ 6¸LW§:6š»YM·#¿²g¶²N¶ 6 ¸OW§:6š»YP·#¿²c¶²Q¶ 6¸RW§:6š»YS·#¿²q¶²T¶ 6¸RW§:6š»YU·#¿²g¶²V¶ 6a¸WW§:6š»YX·#¿²g¶²Y¶ 6 ¸ZW§:6š»Y[·#¿²g¶²\¶ 6¸W§:6§:»Y]·#¿š»Y^·#¿²g¶± $'HD`cH H¾ÚÝHûH8TWHu‘”H²ÎÑHøH7VYHw–™H·ÖÙH÷H7VYHw–™H·ÖÙHÿHC]`H‡¡¤HËåèH),HS]`H‘–™HÂÇÊHóøûH$),HUZ]H†‹ŽH·½ÀHéîñH"{*H†ôö÷ø$ü'ú(û2ý;DKU` cdo xˆ’ ¡¬µ¾ÅÏÚ#Ý!Þ"é$ò(û*+ ,0./&1/587?8I9T=W;X<c>lBuD|E†F‘J”H•I K©O²Q¹RÃSÎWÑUÒVÝXæ[ï^ø`a bfde%g.k7mAnKoVsYqZretnxwz{‹|–€™~𥮅·‡ÁˆË‰ÖÙ‹ÚŒåŽî’÷”• –š˜™%›.Ÿ7¡A¢K£V§Y¥Z¦e¨n¬w®¯‹°–´™²š³¥µ®¹·»Á¼Ë½ÖÁÙ¿ÚÀåÂîÈ÷ÉÿËÌÍÑÏÐ'Ò0Ö;×CÙHÚRÛ]à`Þaßkásæ{éê‡ìŒí–î¡ò¤ð¦ñ°ó¹÷ÃøËúÐûÚüåèþêÿôý  ), . 8@HPS]`beju!}%…(Ž)‘+–.™,›-ž/®0¶4¿5Â7Ç:Ê8Ì9Ï;ß<ç@ðAóCøFûDýEGHL!M$O)R,P.Q1SATIXRYU[Z^]\_]b_r`zdƒe†g‹jŽhi“k£l«p´q·s½vÀtÂuÅwÕxÝ|æ}éî‚ñ€óöƒ„Š‹’"Ž$'’*,‘7“G”O˜‰ò^ü$–ÿHü –-BH -BH -BH -BH -BH -BH -BH 9BH 0BH 0BH 0BH 0BH 0BH 0BH 0BH ü3NBH ü5SBH ü5BH 4BH 4BH ÿ'–NSHcH[H[H[H[H[H\H[H[{GH ‹ —„…¬W²_¶ ¸`š»Ya·#¿²b¶²c¶  ¸`š»Yd·#¿²b¶²e¶ ¸`š»Yf·#¿²b¶²g¶ ¸`š»Yh·#¿²b¶²i¶ ¸`š»Yj·#¿²b¶²k¶ ¸`š»Yl·#¿²b¶²m¶ $¸`š»Yn·#¿²b¶²o¶ )¸`š»Yp·#¿²b¶²q¶ =¸`™»Yr·#¿²s¶±†2 ž&ŸL r¡˜¢¾£ä¤ ¥0§9¨M©Vª‰ %%%%%%%%‹ ˜„…Ïd»tY  ·uKL²v¶ * ¸wÀxL§M»Yz·#¿+¾ Ÿ»Y{·#¿+2¶|}—™»Y·#¿²€¶±!$y†6 ¯ ±²´!·$µ%¶0¸7¹B»O¼Z¾cÀ‰ÿ$txy ‹™šrJava/src/java/RJavaTools.class0000644000175100001440000002344715133274037016135 0ustar hornikusersÊþº¾2C dª « ¬ c­ ® c¯° ª ± ²³ ´ µ¶ · c¸¹ º» c¼½ c¾ ¿¬ ÀÁÂà ª ÄÅ Æ ¿µ dÇ cÈ cÉ ¬ µ ¬ µ cÊ cË ‹Ì ‹ÍÎ ‹ÏÐ .Ñ cÒ cÓ Ì Í ÔÕ Ö× Ø ‹À cÙ Ú cÛÜ 7Ý Þß d® àß áß âß ãß äß åß æ cçè cé êëìí î ï ðñòóôõö÷ø ùú [Ýû [ü [Æ ý þÿ()VCodeLineNumberTablegetClass7(Ljava/lang/Class;Ljava/lang/String;Z)Ljava/lang/Class; StackMapTablegetStaticClasses%(Ljava/lang/Class;)[Ljava/lang/Class;isStatic(Ljava/lang/Class;)ZgetStaticFields-(Ljava/lang/Class;)[Ljava/lang/reflect/Field;getStaticMethods.(Ljava/lang/Class;)[Ljava/lang/reflect/Method; getFieldNames'(Ljava/lang/Class;Z)[Ljava/lang/String;getMethodNamesgetMemberNames1([Ljava/lang/reflect/Member;Z)[Ljava/lang/String;getCompletionName.(Ljava/lang/reflect/Member;)Ljava/lang/String;(Ljava/lang/reflect/Member;)ZhasField'(Ljava/lang/Object;Ljava/lang/String;)ZhasClass classHasField'(Ljava/lang/Class;Ljava/lang/String;Z)ZclassHasMethod classHasClass hasMethod newInstanceJ(Ljava/lang/Class;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object; Exceptions arg_is_null([Ljava/lang/Object;)[Z invokeMethodn(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;getConstructorF(Ljava/lang/Class;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Constructor;  isPrimitive getMethodS(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Method;isMoreSpecific7(Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;)ZA(Ljava/lang/reflect/Constructor;Ljava/lang/reflect/Constructor;)Z'([Ljava/lang/Class;[Ljava/lang/Class;)Z getClasses&(Ljava/lang/Object;)[Ljava/lang/Class; getClassNames'(Ljava/lang/Object;)[Ljava/lang/String;getSimpleClassNames((Ljava/lang/Object;Z)[Ljava/lang/String;getSimpleClassName&(Ljava/lang/Object;)Ljava/lang/String; getSimpleName&(Ljava/lang/String;)Ljava/lang/String;getFieldTypeName7(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String; SourceFileRJavaTools.java ef œ   ¤¥   nojava/util/Vector  java/lang/Class  java/lang/reflect/Modifier  n~java/lang/reflect/Field java/lang/reflect/Method yzjava/lang/String |}  )java/lang/StringBuilder (  i ‚ƒ …ƒ „ƒ ‘’  !"java/lang/Throwable ‡#+java/lang/reflect/InvocationTargetException $% Ž –— &'[Ljava/lang/Class; ‘(java/lang/NoSuchMethodException )* •o +o ˜š,No constructor matching the given parameters e,- ./012345 –6 ˜™+No suitable method for the given parameters ˜› 7 Exceptionerror condition 89 :; <=intdoublebooleanbytelongfloatshortchar <>java/lang/StringBuffer[] ? @A Bjava/lang/NoSuchFieldException RJavaToolsjava/lang/Object[Ljava/lang/reflect/Field;java/lang/reflect/Method;[Ljava/lang/String;[Z[Ljava/lang/Object;java/lang/reflect/Constructor [Ljava/lang/reflect/Constructor;java/lang/SecurityException()[Ljava/lang/Class;getName()Ljava/lang/String;equals(Ljava/lang/Object;)Zaddsize()ItoArray(([Ljava/lang/Object;)[Ljava/lang/Object; getModifiers getFields()[Ljava/lang/reflect/Field; getMethods()[Ljava/lang/reflect/Method;java/lang/reflect/MembergetParameterTypesappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString()Ljava/lang/Class; isAccessible()Z setAccessible(Z)V'([Ljava/lang/Object;)Ljava/lang/Object;getTargetException()Ljava/lang/Throwable;invoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;3([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;getConstructors"()[Ljava/lang/reflect/Constructor;isAssignableFrom(Ljava/lang/String;)Vjava/lang/BooleanTYPELjava/lang/Class;java/lang/Integerjava/lang/Doublejava/lang/Floatjava/lang/Longjava/lang/Shortjava/lang/Character@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method; getSuperclass lastIndexOf(I)IcharAt(I)C substring(II)Ljava/lang/String;(I)Ljava/lang/String;,(Ljava/lang/String;)Ljava/lang/StringBuffer;getField-(Ljava/lang/String;)Ljava/lang/reflect/Field;getType!cd efg*·±h$ ijg{;*¶N6-¾¢--2¶¸+¶™™ -2¸™-2°„§ÿÒ°h./0.13/94ký5%ú lmg½V*¶L+ǰ»Y·M+¾>6¢+2:¸™ ,¶ W„§ÿâ,¶ š°,¶ ½ :,¶ W°h:?@ BCDE%F-G4D:JAKCMLNSOkü 5þ ú nog3*¶ ~™§¬hYk@ pqgÂW*¶L+¾š°»Y·M+¾>6¢+2:¸™ ,¶ W„§ÿâ,¶ š°,¶ ½:,¶ W°h>cd e ghi j&k.l5i;oBpDrMsTtkü rþ ú stgÂW*¶L»Y·M+¾š°+¾>6¢+2:¸™ ,¶ W„§ÿâ,¶ š°,¶ ½:,¶ W°h>~ €ƒ„ …&†.‡5„;ŠB‹DMŽTkýuýú vwg! *¶¸°h› xwg! *¶¸°h§ yzg„M*¾>š½°™T»Y·:6¢"*2:¸™¸¶ W„§ÿÞ¶ š½°¶ ½M,¶ W§"½M6¢,*2¸S„§ÿì,°hV«¬­ ®°±²$³*´2µ=²C¸K¹P»Y¼`½c¿hÀqÁ|À‚Äký{ýú úüú |}gH*Á™ *¹°*Á™3*À¶¾š§L»Y·*¹¶¶+¶¶°°hÔÕÖ(×EÙk A n~g5*¹ ~™§¬hãk@ €g" *¶!+¸"¬hñ €g" *¶!+¸#¬hÿ ‚ƒgx8*¶N6-¾¢*+-2¶$¶™™-2¶%~™¬„§ÿÕ¬h.06kýr%ú „ƒgx8*¶N6-¾¢*+-2¶&¶™™-2¶'~™¬„§ÿÕ¬h#$%.&0$6'kýu%ú …ƒgx8*¶N6-¾¢*+-2¶¸¶™™ -2¸™¬„§ÿÕ¬h678.9076:ký5%ú †€g" *¶!+¸(¬hH ‡ˆg† z+¾¼N6+¾¢-+2ǧT„§ÿæ*,-¸):¶*6š¶+§:6+¶-:š&¶+§:¶/¿:š ¶+¿°9?B,GO^.GOf^hfhRSTUT%X-[4\9^?aB_D`GfOkTl^g`ifkmltmwnk‚ ý‰ÿ Š5‰‰ÿ Š5‰‰úÿ Š5‰‹,V.G,þ ,ÿ Š5‰‹dŒ,Žg)*ǰ*¾¼L=*¾¢+*2ǧT„§ÿé+°hrs tu!t'wk2ý‰ÿЉ‰ÿЉ‰ú g" [*,-¸0¸1:¶26š¶3§:6+-¶4:š&¶3§:¶/¿: š ¶3 ¿°",'0?.'0G?IGhB „…‡Š"ˆ$‰'0”5•?A’G”N•U–X—kMÿ" dŠ5,W.G,þ ,ÿ dŠ5dŒ, ‘’gà Î*ǰN+Æ+¾š*À5¶6N-°*+¶6N-Æ-°§:N*¶8:6¾¢2:¶9:+¾¾Ÿ§b+¾66 6  ¢<, 3™+ 2¸:™%6 §%+ 2Æ 2+ 2¶;š 6 § „ §ÿà ™-Æ -¸<™N„§ÿ}-Ç »7Y=·>¿-°'+7hŽ#¨©«®¯°µ"¶&·(º+¸-½/¾5¿@ÀGÁNÂVÃYÄ]Å`ÆjÇqÉ{Ê~ËΗÏšÐÆ£ÕµÖ¸¿¾ÙÂÚÌÝkGü ‹ B7ý “ý ‹5þ úÿ 5‰‹“ú Œ”7•og‚L*²?¶@š?*²A¶@š5*²B¶@š+*²C¶@š!*²D¶@š*²E¶@š *²F¶@™§¬hãä,å@æKãkûF@ –—gô ä*ǰ,Æ,¾š *+À5¶G°*+,¶G:ư§::*¶:6¾¢“2:¶&+¶š§w¶:,¾¾Ÿ§e,¾6 6 6   ¢<- 3™, 2¸:™%6 §%, 2Æ 2, 2¶;š 6 § „ §ÿà ™Æ ¸H™:„§ÿkÇ »7YI·>¿°(,7hŽ#÷øûü!&),. 1 7 B IUX_gjnq{‚Œ’¨«®´#È$Ì Ò'×(á*kb üÿ 5‰7þ uüü5þ úÿ 5‰uúŒ”7 ˜™g0*¶M+¶N,-¸J¬h78 9 ˜šg0*¶9M+¶9N,-¸J¬hFG H ˜›g N*¾=>6¢9*2+2¥(*2+2¶;™ „ÿ§+2+2¶;™„„§ÿÇž§¬h* YZ[\]'^-_;`>[Dbkþ$ú@ œgu/»Y·L*¶!M,Æ+,¶ W,¶KM§ÿñ+¶ ½ N+-¶ W-°h"kl mnoq'r-sk ý   žŸgx2»Y·L*¶!M,Æ+,¶¶ W,¶KM§ÿî+¶ ½N+-¶ W-°h"|} ~€"‚*ƒ0„k ý    ¡gál=»Y·N*¶!:Æ*¶¸:L¶™=-¶ W¶K:§ÿ×™š -L¶ W-M¶ W-N¶ W-¶ ½:-¶ W°hFŽ ‘’“)”+–2—<™@šD›KRžY¡b¢i£kþ üú ¢£g# *¶!¶¸°h¨ ¤¥g°è*[¶O<›**[¶O`¶PL **[¶O`*;¶O¶QK§f*¶P=I  RK§TD  SK§HZ  TK§<B  UK§0J  VK§$F  WK§S  XK§ C YK*$¶O=› *`¶ZK*.¶O>› *`¶ZK›*»[Y*·\:6£]¶^W„§ÿï¶_°*°hŠ"¬­ ®¯2±8²>³D´JµP¶V·\¸b¹hºn»t¼z½€¾†¿ŒÀ’Á•ƜǠȨ˯̳Í»пÑÉÓÒÔÚÓàÖæØk&ü2ü úüüý[ù ¦§gfM*+¶`¶a¶M§NM,°bhåçëèêìkÿ b¨©rJava/src/java/RJavaArrayTools$ArrayDimensionMismatchException.class0000644000175100001440000000122015133274037025373 0ustar hornikusersÊþº¾2(     (II)VCodeLineNumberTable SourceFileRJavaArrayTools.javajava/lang/StringBuilder dimension of indexer ( !" !#) too large for array (depth =) $% &'/RJavaArrayTools$ArrayDimensionMismatchExceptionArrayDimensionMismatchException InnerClassesjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;(Ljava/lang/String;)VRJavaArrayTools!  B&*»Y·¶¶¶¶¶¶· ± )%*   rJava/src/java/TestException.java0000644000175100001440000000025315133274032016504 0ustar hornikusers/** * Generated as part of testing rjava internal java tools */ public class TestException extends Exception{ public TestException(String message){super(message);} } rJava/src/java/DummyPoint.java0000644000175100001440000000055615133274032016021 0ustar hornikusers public class DummyPoint implements Cloneable { public int x; public int y ; public DummyPoint(){ this( 0, 0 ) ; } public DummyPoint( int x, int y){ this.x = x ; this.y = y ; } public double getX(){ return (double)x ; } public void move(int x, int y){ this.x += x ; this.y += y ; } public Object clone() { return new DummyPoint(x, y); } } rJava/src/java/RectangularArrayExamples.class0000644000175100001440000001151015133274037021042 0ustar hornikusersÊþº¾2s OPQRSTUVWXY OZ [ \ ]^_ `abcdefghijkl()VCodeLineNumberTable#getIntDoubleRectangularArrayExample()[[I StackMapTable'getBooleanDoubleRectangularArrayExample()[[Z$getByteDoubleRectangularArrayExample()[[B$getLongDoubleRectangularArrayExample()[[J%getShortDoubleRectangularArrayExample()[[S&getDoubleDoubleRectangularArrayExample()[[D$getCharDoubleRectangularArrayExample()[[C%getFloatDoubleRectangularArrayExample()[[F&getStringDoubleRectangularArrayExample()[[Ljava/lang/String;*getDummyPointDoubleRectangularArrayExample()[[LDummyPoint;#getIntTripleRectangularArrayExample()[[[I'getBooleanTripleRectangularArrayExample()[[[Z$getByteTripleRectangularArrayExample()[[[B$getLongTripleRectangularArrayExample()[[[J%getShortTripleRectangularArrayExample()[[[S&getDoubleTripleRectangularArrayExample()[[[D$getCharTripleRectangularArrayExample()[[[C%getFloatTripleRectangularArrayExample()[[[F&getStringTripleRectangularArrayExample()[[[Ljava/lang/String;*getDummyPointTripleRectangularArrayExample()[[[LDummyPoint; SourceFileRectangularArrayExamples.java ![[I[[Z[[B[[J[[S[[D[[C[[F[[Ljava/lang/String;java/lang/StringBuilder mn mo pq[[LDummyPoint; DummyPoint r[[[I[[[Z[[[B[[[J[[[S[[[D[[[C[[[F[[[Ljava/lang/String;[[[LDummyPoint;RectangularArrayExamplesjava/lang/Objectappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;(II)V! !"*·±# $%"|.ÅK<=¢>¢*2O„„§ÿï„§ÿâ*°#"  & ,&þ üúú '("†5ÅK<=¢&>¢*2T„š§<§ÿè„§ÿÛ*°#" -3&þ ü@úú )*"}/ÅK<=¢ >¢*2‘T„„§ÿî„§ÿá*°#"!" #$%$'#-(&þ üúú +,"}/ÅK<=¢ >¢*2…P„„§ÿî„§ÿá*°#",- ./0/'.-3&þ üúú -."}/ÅK<=¢ >¢*2“V„„§ÿî„§ÿá*°#"78 9:;:'9->&þ üúú /0"1ÅK<=¢">¢*2‡cR„„§ÿì„§ÿß*°#"BC DEF E)D/I&þ üúú 12"}/ÅK<=¢ >¢*2’U„„§ÿî„§ÿá*°#"MN OPQP'O-T&þ üúú 34"1Å K<=¢">¢*2† bQ„„§ÿì„§ÿß*°#"XY Z[\ [)Z/_&þ  üúú 56"Ž@Å K<=¢1>¢$*2» Y·  ¶¶¶S„„§ÿÝ„§ÿÐ*°#"cd efg/f8e>j&þ  üú%ú 78"„6ÅK<=¢'>¢*2»Y·S„„§ÿç„§ÿÚ*°#"no pqr%q.p4u&þ üúú 9:"žAÅK<=¢1>¢$6¢*22O„„§ÿë„§ÿÝ„§ÿÐ*°#* {| }~!€*3~9}?„&þ üüúúú ;<"¨HÅK<=¢8>¢+6¢*22T„š§<§ÿä„§ÿÖ„§ÿÉ*°#* ˆ‰ Š‹Œ!*Œ:‹@ŠF‘&þ üü@úúú =>"ŸBÅK<=¢2>¢%6¢*22‘T„„§ÿê„§ÿÜ„§ÿÏ*°#* •– —˜™!š+™4˜:—@ž&þ üüúúú ?@"ŸBÅK<=¢2>¢%6¢*22…P„„§ÿê„§ÿÜ„§ÿÏ*°#* ¢£ ¤¥¦!§+¦4¥:¤@«&þ üüúúú AB"ŸBÅK<=¢2>¢%6¢*22“V„„§ÿê„§ÿÜ„§ÿÏ*°#* ¯° ±²³!´+³4²:±@¸&þ üüúúú CD"¡DÅK<=¢4>¢'6¢*22‡cR„„§ÿè„§ÿÚ„§ÿÍ*°#* ¼½ ¾¿À!Á-À6¿<¾BÅ&þ üüúúú EF"ŸBÅK<=¢2>¢%6¢*22’U„„§ÿê„§ÿÜ„§ÿÏ*°#* ÉÊ ËÌÍ!Î+Í4Ì:Ë@Ò&þ üüúúú GH"¡DÅK<=¢4>¢'6¢*22 †bQ„„§ÿè„§ÿÚ„§ÿÍ*°#* Ö× ØÙÚ!Û-Ú6Ù<ØBß&þ üüúúú IJ"°SÅK<=¢C>¢66¢'*22» Y·  ¶¶¶S„„§ÿÙ„§ÿË„§ÿ¾*°#* ãä åæç!è<çEæKåQì&þ üüú)úú KL"¦IÅK<=¢9>¢,6¢*22»Y·S„„§ÿã„§ÿÕ„§ÿÈ*°#* ðñ òóô!õ2ô;óAòGù&þ üüúúúMNrJava/src/java/RJavaTools_Test$DummyNonStaticClass.class0000644000175100001440000000056515133274037023021 0ustar hornikusersÊþº¾2  this$0LRJavaTools_Test;(LRJavaTools_Test;)VCodeLineNumberTable SourceFileRJavaTools_Test.java  #RJavaTools_Test$DummyNonStaticClassDummyNonStaticClass InnerClassesjava/lang/Object()VRJavaTools_Test! " *+µ*·±    rJava/src/java/RJavaClassLoader$UnixDirectory.class0000644000175100001440000000064015133274037022014 0ustar hornikusersÊþº¾2  this$0LRJavaClassLoader;'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTable SourceFileRJavaClassLoader.java  RJavaClassLoader$UnixDirectory UnixDirectory InnerClassesRJavaClassLoader$UnixFileUnixFileRJavaClassLoader  , *+µ*+,·± ¸¹ º  rJava/src/java/RJavaTools_Test.class0000644000175100001440000004202715133274037017127 0ustar hornikusersÊþº¾2m \7 F8 F9 F: F; w< F=> F? @A @BC DE FF FGH FIJ FKL FMN FOP FQR FST FUV FWX FYZ F[\ F]^ F_` Fab Fcd Fef Fghij @kl mnop Dqr stu v Vwxyz{|}~€‚ƒ„ s…† O7‡ Oˆ O‰Š O‹ŒŽ‘’“”•–—˜ v™ sš›œ gžŸ ¡¢£ v¤¥¦§ rž¨©ª«¬­ s®¯°±²³´µ¶·¸ s¹º»¼½¾¿ sÀÁÂÃÄÅÆÇÈ –ÉÊ ËÌ mÍÎ :7ÏÐ sÑÒÓÔÕÖ× F7ØÙÚÛ sÜÝÞßà áâ sãäåæþçè séêëìíîï sðñòóôõö s÷øùúûüýþÿ  s   s    s ï7 1 1 \ s s!"#$DummyNonStaticClass InnerClasses TestException ExampleClassbogusI staticbogusxstatic_x()VCodeLineNumberTablegetBogus()IgetStaticBogusgetX getStaticXsetX(Ljava/lang/Integer;)Vmain([Ljava/lang/String;)V StackMapTableruntests Exceptionsfails"(LRJavaTools_Test$TestException;)Vsuccess getfieldnames%getmethodnamesgetcompletionname&'isstatic constructors(methodshasfield hasmethodhasclassgetclass classhasfield classhasclassclasshasmethodgetstaticfields)getstaticmethods*getstaticclasses invokemethod+,getfieldtypename SourceFileRJavaTools_Test.java      - RJavaTools_Test$TestException . /0 12!Testing RJavaTools.getConstructor3 45 !  Testing RJavaTools.classHasField (!Testing RJavaTools.classHasMethod * Testing RJavaTools.classHasClass )Testing RJavaTools.hasField $Testing RJavaTools.hasClass &Testing RJavaTools.getClass 'Testing RJavaTools.hasMethod %Testing RJavaTools.isStatic  $Testing RJavaTools.getCompletionName  Testing RJavaTools.getFieldNames !Testing RJavaTools.getMethodNames "Testing RJavaTools.getStaticFields +#Testing RJavaTools.getStaticMethods -#Testing RJavaTools.getStaticClasses /Testing RJavaTools.invokeMethod 0#Testing RJavaTools.getFieldTypeName 3Testing RJavaTools.getMethodNOT YET AVAILABLETesting RJavaTools.newInstance 62 7FAILEDPASSED& * getFieldNames(DummyPoint, false) 85 DummyPoint9 :;,getFieldNames(DummyPoint, false).length != 2 5 <=y6getFieldNames(DummyPoint, false).length != c('x','y')  : ok & * getFieldNames(DummyPoint, true )0getFieldNames(DummyPoint, true ) != character(0)+ * getFieldNames(RJavaTools_Test, true )RJavaTools_Test1getFieldNames(RJavaTools_Test, true ).length != 17getFieldNames(RJavaTools_Test, true )[0] != 'static_x' , * getFieldNames(RJavaTools_Test, false )2getFieldNames(RJavaTools_Test, false ).length != 2=getFieldNames(RJavaTools_Test, false ) != c('x', 'static_x') + * getMethodNames(RJavaTools_Test, true) >;java/lang/StringBuilder3getMethodNames(RJavaTools_Test, true).length != 3 ( ?@ ?A) BCjava/lang/String getStaticX()main( runtests()PgetMethodNames(RJavaTools_Test, true) != {'getStaticX()','main(', 'runtests()' }" * getMethodNames(Object, true)java/lang/Object*getMethodNames(Object, true).length != 0 (, * getMethodNames(RJavaTools_Test, false)getX()setX(HgetMethodNames(RJavaTools_Test, false) did not contain expected methods * * getCompletionName(RJavaTools_Test.x) DE FG,getCompletionName(RJavaTools_Test.x) != 'x'  == 'x' : ok java/lang/NoSuchFieldException HC1 * getCompletionName(RJavaTools_Test.static_x):getCompletionName(RJavaTools_Test.static_x) != 'static_x'  == 'static_x' : ok 0 * getCompletionName(RJavaTools_Test.getX() )[Ljava/lang/Class; IJ8getCompletionName(RJavaTools_Test.getX() ) != ''getX()'  == 'getX()' : ok java/lang/NoSuchMethodException9 * getCompletionName(RJavaTools_Test.setX( Integer ) )java/lang/Classjava/lang/Integer=getCompletionName(RJavaTools_Test.setX(Integer) ) != 'setX('  == 'setX(' : ok ! * isStatic(RJavaTools_Test.x) KL#isStatic(RJavaTools_Test.x) == true = false : ok ' * isStatic(RJavaTools_Test.getX() )*isStatic(RJavaTools_Test.getX() ) == false( * isStatic(RJavaTools_Test.static_x)+isStatic(RJavaTools_Test.static_x) == false = true : ok - * isStatic(RJavaTools_Test.getStaticX() )0isStatic(RJavaTools_Test.getStaticX() ) == false. * isStatic(RJavaTools_Test.TestException ) KM0isStatic(RJavaTools_Test.TestException) == false4 * isStatic(RJavaTools_Test.DummyNonStaticClass )#RJavaTools_Test$DummyNonStaticClass5isStatic(RJavaTools_Test.DummyNonStaticClass) == true$ * getConstructor( String, null )[Z NOjava/lang/ExceptiongetConstructor( String, null )1 * getConstructor( Integer, { String.class } )+getConstructor( Integer, { String.class } )% * getConstructor( Integer, null )6getConstructor( Integer, null ) did not generate error -> exception : ok RJavaTools_Test$ExampleClass PM * getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : Q RSQgetConstructor( ExampleClass, {Object.class, Object.class, boolean}) : exception  ok) java> DummyPoint p = new DummyPoint() * hasField( p, 'x' ) TU% hasField( DummyPoint, 'x' ) == false true : ok% * hasField( p, 'iiiiiiiiiiiii' )  iiiiiiiiiiiii0 hasField( DummyPoint, 'iiiiiiiiiiiii' ) == true false : ok * testing a private field ( hasField returned true on private field * hasMethod( p, 'move' ) move VU( hasField( DummyPoint, 'move' ) == false& * hasMethod( p, 'iiiiiiiiiiiii' ) , hasMethod( Point, 'iiiiiiiiiiiii' ) == true * testing a private method * hasMethod returned true on private method3 * hasClass( RJavaTools_Test, 'TestException' ) WU6 hasClass( RJavaTools_Test, 'TestException' ) == false true : ok9 * hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) < hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) == false9 * getClass( RJavaTools_Test, 'TestException', true ) XYD getClass( RJavaTools_Test, 'TestException', true ) != TestException : ok? * getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) A getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null@ * getClass( RJavaTools_Test, 'DummyNonStaticClass', false ) > * classHasClass( RJavaTools_Test, 'TestException', true ) Z[A classHasClass( RJavaTools_Test, 'TestException', true ) == falseD * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) F classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) == trueE * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) H classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) == false7 * classHasMethod( RJavaTools_Test, 'getX', false ) \[: classHasMethod( RJavaTools_Test, 'getX', false ) == false= * classHasMethod( RJavaTools_Test, 'getStaticX', false ) @ classHasMethod( RJavaTools_Test, 'getStaticX', false ) == false6 * classHasMethod( RJavaTools_Test, 'getX', true ) L classHasMethod( RJavaTools_Test, 'getX', true ) == true (non static method)< * classHasMethod( RJavaTools_Test, 'getStaticX', true ) H classHasMethod( RJavaTools_Test, 'getStaticX', true ) == false (static); * classHasMethod( RJavaTools_Test, 'getBogus', false ) N classHasMethod( RJavaTools_Test, 'getBogus', false ) == true (private method)@ * classHasMethod( RJavaTools_Test, 'getStaticBogus', true ) M classHasMethod( RJavaTools_Test, 'getBogus', true ) == true (private method)) * getStaticFields( RJavaTools_Test ) ]^/ getStaticFields( RJavaTools_Test ).length != 1 _C4 getStaticFields( RJavaTools_Test )[0] != 'static_x' * getStaticFields( Object ) " getStaticFields( Object ) != null* * getStaticMethods( RJavaTools_Test ) `a0 getStaticMethods( RJavaTools_Test ).length != 2M getStaticMethods( RJavaTools_Test ) != c('main', 'getStaticX', 'runtests' ) ! * getStaticMethods( Object ) # getStaticMethods( Object ) != null! * getStaticClasses( Object ) bc# getStaticClasses( Object ) != null* * getStaticClasses( RJavaTools_Test ) 0 getStaticClasses( RJavaTools_Test ).length != 1E getStaticClasses( RJavaTools_Test ) != RJavaTools_Test.TestException. * testing enforcing accessibility (bug# 128)java/util/HashMap de fg Xhiterator[Ljava/lang/Object; ijjava/lang/Throwable) : FAILED (expected for JDK-17 and above)% * getFieldTypeName( DummyPoint, x ) klint(getFieldTypeName( DummyPoint, x ) != int: ok[Ljava/lang/String;java/lang/reflect/Fieldjava/lang/reflect/Methodjava/lang/reflect/Constructor[Ljava/lang/reflect/Field;java/lang/reflect/Method; java/util/Map java/util/SetintValuejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)VerrprintStackTraceprint RJavaTools getFieldNames'(Ljava/lang/Class;Z)[Ljava/lang/String;equals(Ljava/lang/Object;)ZgetMethodNamesappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;getField-(Ljava/lang/String;)Ljava/lang/reflect/Field;getCompletionName.(Ljava/lang/reflect/Member;)Ljava/lang/String; getMessage getMethod@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;isStatic(Ljava/lang/reflect/Member;)Z(Ljava/lang/Class;)ZgetConstructorF(Ljava/lang/Class;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Constructor;((Ljava/lang/Object;Ljava/lang/String;Z)Vjava/lang/BooleanTYPELjava/lang/Class;hasField'(Ljava/lang/Object;Ljava/lang/String;)Z hasMethodhasClassgetClass7(Ljava/lang/Class;Ljava/lang/String;Z)Ljava/lang/Class; classHasClass'(Ljava/lang/Class;Ljava/lang/String;Z)ZclassHasMethodgetStaticFields-(Ljava/lang/Class;)[Ljava/lang/reflect/Field;getNamegetStaticMethods.(Ljava/lang/Class;)[Ljava/lang/reflect/Method;getStaticClasses%(Ljava/lang/Class;)[Ljava/lang/Class;put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;entrySet()Ljava/util/Set;()Ljava/lang/Class; invokeMethodn(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;getFieldTypeName7(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String;!F\   /*·*µ*µ±      *´¬     ²¬   *´¬    ²¬  ! *+¶µ±   Q¸§ L+¸ ¸ ± !%"# $&F  ²  ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸²  ¶ ¸!¸² "¶ ¸#¸² $¶ ¸%¸² &¶ ¸'¸² (¶ ¸)¸² *¶ ¸+¸² ,¶ ¸-¸² .¶ ¸/¸² 0¶ ² 1¶ ² 2¶ ² 1¶ ± â8)* +-./1$2'3*5265789@:C;F=N>Q?TA\B_CbEjFmGpIxJ{K~M†N‰OŒQ”R—SšU¢V¥W¨Y°Z³[¶]¾^Á_ÄaÌbÏcÒeÚfÝgàièjëkîmönþpqs  9²34¶ *¶5²36¶ ± yz {|  % ² 7¶ ± ‚  ½ ² 8¶9:¸;K*¾Ÿ »Y<·=¿<¢)>*2¶?š@*2¶?š »YA·=¿„§ÿز B¶ ² C¶9:¸;K*¾™ »YD·=¿² B¶ ² E¶9F¸;K*¾Ÿ »YG·=¿H*2¶?š »YI·=¿² B¶ ² J¶9F¸;K*¾Ÿ »YK·=¿<¢)>*2¶?šH*2¶?š »YL·=¿„§ÿز B¶ ± ~Š‹Œ&<‘FL”T˜\™cšh›rz¡‚¢‰£¤™¦¤§®©¶­¾®Å¯Ë°Õ²Ü³ò´ü²· º üü$ú%&&ü$ú  =Y=² M¶9F¸NK*¾Ÿ$»Y»OY·PQ¶R*¾¶ST¶R¶U·=¿½VYWSYXSYYSL=>*¾¢,6+¾¢*2+2¶?™ „§ „§ÿã„§ÿÔ+¾Ÿ»Y»OY·PZ¶R¶S¶U·=¿² B¶ ² [¶9\¸NK*¾™$»Y»OY·P]¶R*¾¶ST¶R¶U·=¿² B¶ ² ^¶9F¸NK=½VY_SYWSY`SYXSL>*¾¢,6+¾¢*2+2¶?™ „§ „§ÿã„§ÿÔ+¾Ÿ »Ya·=¿² B¶ ± –%ÁÄ ÅÆÇ8ÉLÊNËVÌ`ÍmÎpÏsÌyËӅԠ֨ڰ۷ܼÝÝßåãíäôåöæçè!é.ê1ë4è:ç@ïFðPòXö6þ8ÿüúú <ü3üúú  ² b¶9F>¶cK>*¸d¶?š »Ye·=¿² f¶ §N»Y-¶h·=¿² i¶9FH¶cKH*¸d¶?š »Yj·=¿² k¶ §N»Y-¶h·=¿² l¶9FmÀn¶oL_+¸d¶?š²3+¸d¶ »Yp·=¿² q¶ §N»Y-¶s·=¿² t¶9Fu½vYwS¶oL`+¸d¶?š²3+¸d¶ »Yx·=¿² y¶ §N»Y-¶s·=¿±.1g>log|¸»rÈ  r Ž#&. 12 >FNZdlop|„œ¦ °"¸%»#¼$È*Ð+á,í-÷.0 3 1 26= ü&ÿ gü %Jg ü3ÿ rü 8Jr    _5² z¶9F>¶cK*¸{™ »Y|·=¿² }¶ §M»Y,¶h·=¿² ~¶9FmÀn¶oL+¸{™ »Y·=¿² }¶ §M»Y,¶s·=¿² €¶9FH¶cK*¸{š »Y·=¿² ‚¶ §M»Y,¶h·=¿² ƒ¶9F„Àn¶oL+¸{š »Y…·=¿² ‚¶ §M»Y,¶s·=¿² †¶9M,¸‡š »Yˆ·=¿² ‚¶ ² ‰¶9ŠM,¸‡™ »Y‹·=¿² }¶ ±),g9firvŸ¢g¯Üßr ®+@ABC!E)H,F-G9MANMOTP^RfUiSjTvZ~[†\]—_Ÿb¢`£a¯g·hÃiÊjÔlÜoßmànìuôv÷wþxz~€",ƒ4…Dü!ÿ gü ü$ÿ rü  Jg $Jr üv# ! ýý² Œ¶9VÀnÀ¸ŽK§M»Y·=¿² B¶ ² ‘¶9w½vYVS¼YT¸ŽK§M»Y’·=¿² B¶ <² “¶9wÀnÀ¸ŽK§M<š »Y”·=¿² •¶ MN»–Y,-ÀV·—:<² ˜¶9–½vY\SY\SY²™S¼YTYTYT¸ŽK§ :<¶š™ »Y›·=¿² œ¶ ±4JMjx{±ÚÝ Ž#‘”’“$•,™4›JžMœNXŸ`°b±j³x¶{´|µ~·‚¸Œº”Ï–ИѧÓ©Ô±ÖÚÜÝÙßÚáÛæÝêÞôàüä: Yü "h ÿ"" ÿP"\\–  # ± ê $ ë‚»:Y·K² ž¶ ² Ÿ¶9*>¸ š »Y¡·=¿² ¢¶ ² £¶9*¤¸ ™ »Y¥·=¿² ¦¶ »FY·§L² ¨¶9+©¸ ™ »Yª·=¿² ¦¶ ± Bðñòó!ô+ö3ø;ùDúNüVÿ^foyü+:"ü*F % ë‚»:Y·K² ž¶ ² «¶9*¬¸­š »Y®·=¿² ¢¶ ² ¯¶9*¤¸­™ »Y°·=¿² ¦¶ »FY·§L² ±¶9+²¸ ™ »Y³·=¿² ¦¶ ± B !+3;DNV^foy!#ü+:"ü*F & šO»FY·§K² ´¶9*µ¸¶š »Y··=¿² ¸¶ ² ¹¶9*º¸¶š »Y»·=¿² ¸¶ ± * )+,-#/+132<3F5N7 ü#F" ' Þz² ¼¶9Fµ¸½K*¥ »Y¾·=¿² ¿¶ ² À¶9Fº¸½K*Æ »YÁ·=¿² ¿¶ ² ¶9Fº¸½K*Š¥ »YÁ·=¿² ¿¶ ± B>?@A!C)E1F:G>HHJPLXMaNgOqQyS ü!v&( ( ± Y ) Ãp² ö9Fµ¸Äš »YÅ·=¿² ¸¶ ² ƶ9Fº¸Ä™ »YÇ·=¿² ¦¶ ² ȶ9Fº¸Äš »YÉ·=¿² ¸¶ ± 6 ^_`b%d-e8fBhJjRk]lgnop$$ * eß² ʶ9Fm¸Ëš »YÌ·=¿² ¸¶ ² Ͷ9F„¸Ëš »Yη=¿² ¸¶ ² ϶9Fm¸Ë™ »Yз=¿² ¦¶ ² Ѷ9F„¸Ëš »YÒ·=¿² ¸¶ ² Ó¶9F²¸Ë™ »YÔ·=¿² ¦¶ ² Õ¶9Fָ˙ »Y×·=¿² ¦¶ ± fvwxz%|-}8~B€J‚Rƒ]„g†oˆw‰‚ŠŒŒ”Žœ§±’¹”Á•Ì–Ö˜Þš$$$$$ + »c² ض9F¸ÙK*¾Ÿ »YÚ·=¿H*2¶Û¶?š »YÜ·=¿² ¿¶ ² ݶ9\¸ÙK*Æ »YÞ·=¿² ¿¶ ± 6 ¡¢£¤¦,§6©>«F¬L­P®Z°b² ü,# - 5¦² ß¶9F¸àK½VY„SYáSYâSL=*¾+¾Ÿ »Yã·=¿>*¾¢/6+¾¢*2¶ä+2¶?™ „§ „§ÿà„§ÿÑ+¾Ÿ »Yå·=¿² ¿¶ ² æ¶9\¸àK*Æ »Yç·=¿² ¿¶ ± Zº»¼"½$¾+¿5Á=ÂGÃWÄZÅ]ÂcÁiÉoÊyÌЉÑÒ“ÓÕ¥Øþ5.üüúú# / µ]² è¶9\¸éK*Æ »Yê·=¿² ¿¶ ² ë¶9F¸éK*¾Ÿ »Yì·=¿*2¥ »Yí·=¿² ¿¶ ± 6 àáâãå$é,ê2ë8ìBîJïTñ\ô ün% 0 ¬K² î¶9»ïY·ðK*>>¹ñW*¹òL+¶ó+ôÀõÀn¸öM§ M² ø¶ ±² B¶ ±"58÷ . ûüýþ"589ABJÿ812÷  3 f,² ù¶9:>¸úK*û¶?š »Yü·=¿² ý¶ ±   #+ü#V4 ³± 56ÿŠFþF –F rJava/src/java/ArrayWrapper.java0000644000175100001440000002257015133274032016333 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Array ; /** * Utility class to deal with arrays */ public class ArrayWrapper extends RJavaArrayIterator { /** * is this array rectangular */ private boolean isRect ; /** * The type name of the objects stored */ private String typeName ; /** * true if the array stores primitive types */ private boolean primitive ; private int length ; /** * Constructor * * @param array the array to check * @throws NotAnArrayException if array is not an array */ public ArrayWrapper(Object array) throws NotAnArrayException { super( RJavaArrayTools.getDimensions(array) ); this.array = array ; typeName = RJavaArrayTools.getObjectTypeName(array ); primitive = RJavaArrayTools.isPrimitiveTypeName( typeName ) ; if( dimensions.length == 1){ isRect = true ; } else{ isRect = isRectangular_( array, 0 ); } // reset the dimensions if the array is not rectangular if( !isRect ){ dimensions = null ; length = -1; } else{ length = 1; for( int i=0; i> actual arrays" ) ; // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ if( RJavaArrayTools.getDimensionLength( o ) != 1 ){ throw new TestException( "getDimensionLength( int[10] ) != 1" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " 1 : ok " ); // }}} // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ if( RJavaArrayTools.getDimensionLength( o ) != 1 ){ throw new TestException( "getDimensionLength( int[0] ) != 1" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " 1 : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ if( RJavaArrayTools.getDimensionLength( ob ) != 2 ){ throw new TestException( "getDimensionLength( new Object[10][10] ) != 2" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " 2 : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ if( RJavaArrayTools.getDimensionLength( obj ) != 3 ){ throw new TestException( "getDimensionLength( new Object[10][10][3] ) != 3" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][3]" ) ; } System.out.println( " 3 : ok " ); // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ RJavaArrayTools.getDimensionLength( Double.valueOf(10.3) ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getDimensionLength(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getDimensionLength( int )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getDimensionLength( boolean )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getDimensionLength( byte )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getDimensionLength( long )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getDimensionLength( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getDimensionLength( short )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getDimensionLength( double )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getDimensionLength( char )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getDimensionLength( float )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getDimensionLength( null )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getDimensionLength( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getDimensionLength( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ getdims private static void getdims() throws TestException{ int[] res = null ; // {{{ actual arrays // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getDimensions( o ); if( res.length != 1 ){ throw new TestException( "getDimensions( int[10]).length != 1" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( int[10])[0] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " c( 10 ) : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getDimensions( ob ) ; if( res.length != 2 ){ throw new TestException( "getDimensions( Object[10][10] ).length != 2" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10] )[1] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " c(10,10) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][10][10] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[1] != 10" ); } if( res[2] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[1] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " c(10,10,10) : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getDimensions( o ) ; if( res.length != 1 ){ throw new TestException( "getDimensions( int[0]).length != 1" ); } if( res[0] != 0){ throw new TestException( "getDimensions( int[0])[0] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " c(0) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][10][0] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10][0] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10][0] )[1] != 10" ); } if( res[2] != 0 ){ throw new TestException( "getDimensions( Object[10][10][0] )[1] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " c(10,10,0) : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][0][0] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][0][0] )[0] != 10" ); } if( res[1] != 0 ){ throw new TestException( "getDimensions( Object[10][0][0] )[1] != 0" ); } if( res[2] != 0 ){ throw new TestException( "getDimensions( Object[10][0][0] )[1] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " c(10,0,0) : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getDimensions( Double.valueOf(10.3) ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getDimensions(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getDimensions( int )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getDimensions( boolean )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getDimensions( byte )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getDimensions( long )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getDimensions( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getDimensions( short )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getDimensions( double )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getDimensions( char )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getDimensions( float )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getDimensions( null )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getDimensions( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getDimensions( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ gettruelength private static void gettruelength() throws TestException{ int res = 0 ; // {{{ actual arrays // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getTrueLength( o ); if( res != 10 ){ throw new TestException( "getTrueLength( int[10]) != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " 10 : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( ob ) ; if( res != 100 ){ throw new TestException( "getTrueLength( Object[10][10] ) != 100" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " 100 : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 1000 ){ throw new TestException( "getTrueLength( Object[10][10][10] ) != 1000" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " 1000 : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getTrueLength( o ) ; if( res != 0 ){ throw new TestException( "getTrueLength( int[0]) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " c(0) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 0 ){ throw new TestException( "getTrueLength( Object[10][10][0] ) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " 0 : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 0){ throw new TestException( "getTrueLength( Object[10][0][0] ) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " 0 : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getTrueLength( Double.valueOf(10.3) ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getTrueLength(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getTrueLength( int )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getTrueLength( boolean )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getTrueLength( byte )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getTrueLength( long )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getTrueLength( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getTrueLength( short )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getTrueLength( double )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getTrueLength( char )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getTrueLength( float )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getTrueLength( null )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getTrueLength( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getTrueLength( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ isRectangular private static void isrect() throws TestException { // {{{ int System.out.print( " isRectangularArray( int )" ) ; if( RJavaArrayTools.isRectangularArray( 0 ) ){ throw new TestException( " isRectangularArray( int ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ boolean System.out.print( " isRectangularArray( boolean )" ) ; if( RJavaArrayTools.isRectangularArray( true ) ){ throw new TestException( " isRectangularArray( boolean ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ byte System.out.print( " isRectangularArray( byte )" ) ; if( RJavaArrayTools.isRectangularArray( (byte)0 ) ){ throw new TestException( " isRectangularArray( byte ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ long System.out.print( " isRectangularArray( long )" ) ; if( RJavaArrayTools.isRectangularArray( (long)0 ) ){ throw new TestException( " isRectangularArray( long ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ short System.out.print( " isRectangularArray( short )" ) ; if( RJavaArrayTools.isRectangularArray( (double)0 ) ){ throw new TestException( " isRectangularArray( short ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ double System.out.print( " isRectangularArray( double )" ) ; if( RJavaArrayTools.isRectangularArray( 0.0 ) ){ throw new TestException( " isRectangularArray( double ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ char System.out.print( " isRectangularArray( char )" ) ; if( RJavaArrayTools.isRectangularArray( 'a' ) ){ throw new TestException( " isRectangularArray( char ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ float System.out.print( " isRectangularArray( float )" ) ; if( RJavaArrayTools.isRectangularArray( 0.0f ) ){ throw new TestException( " isRectangularArray( float ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ String System.out.print( " isRectangularArray( String )" ) ; if( RJavaArrayTools.isRectangularArray( "dd" ) ){ throw new TestException( " isRectangularArray( String ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ int[] int[] x = new int[2] ; System.out.print( " isRectangularArray( int[] )" ) ; if( ! RJavaArrayTools.isRectangularArray( x ) ){ throw new TestException( " !isRectangularArray( int[] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ Object o = new double[2] Object o = new double[2]; System.out.print( " isRectangularArray( double[] (but declared as 0bject) )" ) ; if( ! RJavaArrayTools.isRectangularArray( o ) ){ throw new TestException( " !isRectangularArray( Object o = new double[2]; ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ null System.out.print( " isRectangularArray( null )" ) ; if( RJavaArrayTools.isRectangularArray( null ) ){ throw new TestException( " isRectangularArray( null) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ 2d rectangular int[][] x2d = new int[3][4]; System.out.print( " isRectangularArray( new int[3][4] )" ) ; if( ! RJavaArrayTools.isRectangularArray( x2d ) ){ throw new TestException( " !isRectangularArray( new int[3][4] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ 2d not rectangular int[][] x2d_not = new int[2][] ; x2d_not[0] = new int[2] ; x2d_not[1] = new int[3] ; System.out.print( " isRectangularArray( new int[2][2,4] )" ) ; if( RJavaArrayTools.isRectangularArray( x2d_not ) ){ throw new TestException( " !isRectangularArray( new int[2][2,4] ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ 3d not rectangular int[][][] x3d_not = new int[1][][] ; x3d_not[0] = new int[2][]; x3d_not[0][0] = new int[1] ; x3d_not[0][1] = new int[2] ; System.out.print( " isRectangularArray( new int[2][2][10,25] )" ) ; if( RJavaArrayTools.isRectangularArray( x3d_not ) ){ throw new TestException( " !isRectangularArray( new int[2][2][10,25] ) " ) ; } System.out.println( " false : ok" ) ; // }}} } // }}} // {{{ getObjectTypeName private static void gettypename() throws TestException { String res ; // {{{ actual arrays // {{{ int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new int[1] ); if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " I : ok " ); // }}} // {{{ boolean[] ; System.out.print( " boolean[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new boolean[1] ); if( !res.equals("Z") ){ throw new TestException( "getObjectTypeName(boolean[]) != 'Z' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array boolean[10]" ) ; } System.out.println( " Z : ok " ); // }}} // {{{ byte[] ; System.out.print( " byte[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new byte[1] ); if( !res.equals("B") ){ throw new TestException( "getObjectTypeName(byte[]) != 'B' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array byte[10]" ) ; } System.out.println( " B : ok " ); // }}} // {{{ long[] ; System.out.print( " long[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new long[1] ); if( !res.equals("J") ){ throw new TestException( "getObjectTypeName(long[]) != 'J' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array long[10]" ) ; } System.out.println( " J : ok " ); // }}} // {{{ short[] ; System.out.print( " short[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new short[1] ); if( !res.equals("S") ){ throw new TestException( "getObjectTypeName(short[]) != 'S' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array short[10]" ) ; } System.out.println( " S : ok " ); // }}} // {{{ double[] ; System.out.print( " double[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new double[1] ); if( !res.equals("D") ){ throw new TestException( "getObjectTypeName(double[]) != 'D' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array double[10]" ) ; } System.out.println( " D : ok " ); // }}} // {{{ char[] ; System.out.print( " char[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new char[1] ); if( !res.equals("C") ){ throw new TestException( "getObjectTypeName(char[]) != 'C' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array char[10]" ) ; } System.out.println( " C : ok " ); // }}} // {{{ float[] ; System.out.print( " float[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new float[1] ); if( !res.equals("F") ){ throw new TestException( "getObjectTypeName(float[]) != 'F' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array float[10]" ) ; } System.out.println( " F : ok " ); // }}} System.out.println(" >> multi dim primitive arrays" ) ; // {{{ int[] o = new int[10] ; System.out.print( " int[][] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new int[1][1] ); if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " I : ok " ); // }}} // {{{ boolean[] ; System.out.print( " boolean[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new boolean[1][1] ); if( !res.equals("Z") ){ throw new TestException( "getObjectTypeName(boolean[]) != 'Z' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array boolean[10]" ) ; } System.out.println( " Z : ok " ); // }}} // {{{ byte[] ; System.out.print( " byte[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new byte[1][1] ); if( !res.equals("B") ){ throw new TestException( "getObjectTypeName(byte[]) != 'B' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array byte[10]" ) ; } System.out.println( " B : ok " ); // }}} // {{{ long[] ; System.out.print( " long[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new long[1][1] ); if( !res.equals("J") ){ throw new TestException( "getObjectTypeName(long[]) != 'J' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array long[10]" ) ; } System.out.println( " J : ok " ); // }}} // {{{ short[] ; System.out.print( " short[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new short[1][1] ); if( !res.equals("S") ){ throw new TestException( "getObjectTypeName(short[]) != 'S' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array short[10]" ) ; } System.out.println( " S : ok " ); // }}} // {{{ double[] ; System.out.print( " double[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new double[1][1] ); if( !res.equals("D") ){ throw new TestException( "getObjectTypeName(double[]) != 'D' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array double[10]" ) ; } System.out.println( " D : ok " ); // }}} // {{{ char[] ; System.out.print( " char[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new char[1][1] ); if( !res.equals("C") ){ throw new TestException( "getObjectTypeName(char[]) != 'C' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array char[10]" ) ; } System.out.println( " C : ok " ); // }}} // {{{ float[] ; System.out.print( " float[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new float[1][1] ); if( !res.equals("F") ){ throw new TestException( "getObjectTypeName(float[]) != 'F' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array float[10]" ) ; } System.out.println( " F : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( ob ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName(Object[][]) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][10][10] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " 1000 : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; int[] o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( o ) ; if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[0]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][10][0] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][0][0] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " 0 : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getObjectTypeName( Double.valueOf(10.3) ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getObjectTypeName(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getObjectTypeName( int )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getObjectTypeName( boolean )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getObjectTypeName( byte )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getObjectTypeName( long )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getObjectTypeName( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getObjectTypeName( short )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getObjectTypeName( double )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getObjectTypeName( char )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getObjectTypeName( float )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getObjectTypeName( null )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getObjectTypeName( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getObjectTypeName( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ isPrimitiveTypeName private static void isprim() throws TestException{ System.out.print( " isPrimitiveTypeName( 'I' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("I") ) throw new TestException("I not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'Z' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("Z") ) throw new TestException("Z not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'B' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("B") ) throw new TestException("B not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'J' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("J") ) throw new TestException("J not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'S' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("S") ) throw new TestException("S not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'D' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("D") ) throw new TestException("D not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'C' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("C") ) throw new TestException("C not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'F' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("F") ) throw new TestException("F not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'java.lang.Object' ) " ) ; if( RJavaArrayTools.isPrimitiveTypeName("java.lang.Object") ) throw new TestException("Object primitive") ; System.out.println( " false : ok " ); } // }}} // {{{ rep private static void rep() throws TestException{ DummyPoint p = new DummyPoint(10, 10) ; DummyPoint[] res = null; System.out.print( " rep( DummyPoint, 10)" ); try{ res = (DummyPoint[])RJavaArrayTools.rep( p, 10 ); } catch( Throwable e){ throw new TestException( "rep(DummyPoint, 10) failed" ) ; } if( res.length != 10 ){ throw new TestException( "rep(DummyPoint, 10).length != 10" ) ; } if( res[5].getX() != 10.0 ){ throw new TestException( "rep(DummyPoint, 10)[5].getX() != 10" ) ; } System.out.println( ": ok " ); } /// }}} } rJava/src/java/RectangularArrayExamples.java0000644000175100001440000001275015133274032020660 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Utility class that makes example rectangular java arrays of 2 and 3 dimensions * for all primitive types, String and Point (as an example of array of non primitive object) */ public class RectangularArrayExamples { // {{{ Example 2d rect arrays public static int[][] getIntDoubleRectangularArrayExample(){ int[][] x = new int[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k ; } } return x; } public static boolean[][] getBooleanDoubleRectangularArrayExample(){ boolean[][] x = new boolean[5][2]; boolean current = false; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, current = !current){ x[i][j] = current ; } } return x ; } public static byte[][] getByteDoubleRectangularArrayExample(){ byte[][] x = new byte[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (byte)k ; } } return x; } public static long[][] getLongDoubleRectangularArrayExample(){ long[][] x = new long[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (long)k ; } } return x; } public static short[][] getShortDoubleRectangularArrayExample(){ short[][] x = new short[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (short)k ; } } return x; } public static double[][] getDoubleDoubleRectangularArrayExample(){ double[][] x = new double[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k + 0.0 ; } } return x; } public static char[][] getCharDoubleRectangularArrayExample(){ char[][] x = new char[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (char)k ; } } return x; } public static float[][] getFloatDoubleRectangularArrayExample(){ float[][] x = new float[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k + 0.0f ; } } return x; } public static String[][] getStringDoubleRectangularArrayExample(){ String[][] x = new String[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = "" + k ; } } return x; } public static DummyPoint[][] getDummyPointDoubleRectangularArrayExample(){ DummyPoint[][] x = new DummyPoint[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = new DummyPoint(k,k) ; } } return x; } // }}} // {{{ Example 3d rect arrays public static int[][][] getIntTripleRectangularArrayExample(){ int[][][] x = new int[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = current ; } } } return x; } public static boolean[][][] getBooleanTripleRectangularArrayExample(){ boolean[][][] x = new boolean[5][3][2]; boolean current = false ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current= !current){ x[i][j][k] = current ; } } } return x; } public static byte[][][] getByteTripleRectangularArrayExample(){ byte[][][] x = new byte[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (byte)current ; } } } return x; } public static long[][][] getLongTripleRectangularArrayExample(){ long[][][] x = new long[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (long)current ; } } } return x; } public static short[][][] getShortTripleRectangularArrayExample(){ short[][][] x = new short[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (short)current ; } } } return x; } public static double[][][] getDoubleTripleRectangularArrayExample(){ double[][][] x = new double[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = 0.0 + current ; } } } return x; } public static char[][][] getCharTripleRectangularArrayExample(){ char[][][] x = new char[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (char)current ; } } } return x; } public static float[][][] getFloatTripleRectangularArrayExample(){ float[][][] x = new float[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = 0.0f + current ; } } } return x; } public static String[][][] getStringTripleRectangularArrayExample(){ String[][][] x = new String[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = ""+current ; } } } return x; } public static DummyPoint[][][] getDummyPointTripleRectangularArrayExample(){ DummyPoint[][][] x = new DummyPoint[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = new DummyPoint( current, current ) ; } } } return x; } // }}} } rJava/src/java/Makefile0000644000175100001440000000127115133274037014511 0ustar hornikusersJAVA_SRC=$(wildcard *.java) JFLAGS=-source 1.6 -target 1.6 JAVAC=javac JAVA=java JAVADOC=javadoc JAVADOCFLAGS=-author -version -breakiterator -link http://java.sun.com/j2se/1.4.2/docs/api all: compile test compile: $(JAVA_SRC) $(JAVAC) $(JFLAGS) $(JAVA_SRC) test_RJavaTools: compile $(JAVA) RJavaTools_Test test_RJavaArrayTools: compile $(JAVA) RJavaArrayTools_Test test_ArrayWrapper: $(JAVA) ArrayWrapper_Test test_RectangularArrayBuilder: $(JAVA) RectangularArrayBuilder_Test test: compile test_RJavaTools test_RJavaArrayTools test_ArrayWrapper test_RectangularArrayBuilder javadoc: $(JAVADOC) $(JAVADOCFLAGS) -d javadoc $(JAVA_SRC) clean: rm -rfv *.class *~ .PHONY: all clean rJava/src/java/RJavaArrayIterator.class0000644000175100001440000000314415133274036017614 0ustar hornikusersÊþº¾2F . / 01 2 3 4 5 6 7 8 9 : ;<=> dimensions[IndIindexdimprodarrayLjava/lang/Object; incrementpositionstartgetArray()Ljava/lang/Object;CodeLineNumberTablegetArrayClassName()Ljava/lang/String; getDimensions()[I()V([I)V StackMapTable(I)VnexthasNext()Z SourceFileRJavaArrayIterator.java  ?@A B  #$       #%C DERJavaArrayIteratorjava/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetNamejava/lang/reflect/Arrayget'(Ljava/lang/Object;I)Ljava/lang/Object;!*´° # *´¶¶°!"*´°#$E*·*µ*µ*µ*µ±  !"#%y*·*+µ*+¾µ*´¤Z**´d¼ µ**´d¼ µ=*´d¢6*´O*´š +.§+.*´d.hO**´.µ „§ÿÆ*µ *µ ±:$% &'(#)/*;+B,^-h*n0s1x2&8ÿ1'ÿ''ÿ ''ú#(( *¼ YO· ± 4 5)”*´L=*´¾¢=+*´.¸ Lš**´.µ §*Y´ *´.*´d.h`µ „§ÿÀ*´¾d=›5*´.`*´.  *´O§*´*´.`O§ „ÿ§ÿÍ*Y´ `µ +°>:;<=>,@D;JEVFgGqIJ‚EˆN’O&ý$úüú*+4*´ *´ ¢§¬S&@,-rJava/src/java/RJavaArrayTools.class0000644000175100001440000004064215133274037017130 0ustar hornikusersÊþº¾2+ 9: 9£ •; <=> —;? @;¨ A;B C;¦ ’;D E;F G; H 1IJ K 1LMN ÂOP ÂQR STUVWXYZ[ (9 (\ (] Š^ (_ Š` <a <bc 1d Še Âf Âg Âh Šij 8k 8lmn ;S 1o pq pr Šs pt pu pv pw px py pz p{ Š| Š} Š~ РЀ Š Š‚ Šƒ Š„… S† p‡ pˆ p‰ pŠ p‹ pŒ p pŽ p Š Š‘ Š’ Š“ Š” Š• Š– Š— Š˜ Š™š h9 h h› hœ pž hŸ  1¡¢ rK Š£ ¤¥ ¦§ ¨ © hª« Ь ­ ®¯ ° 1±² ³ 1´µ L ¶ 1· Џ ’¹º€ •» —¼ ’½ÿ÷ÿÿÿÿÿÿ о¿ ŠÀ ’Á •ÃÄ —Å ŠÆð¢ ’ÇÈArrayDimensionMismatchException InnerClassesprimitiveClassesLjava/util/Map; NA_INTEGERI ConstantValueNA_REALDNA_bitsJ()VCodeLineNumberTableinitPrimitiveClasses()Ljava/util/Map;getObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String; StackMapTable Exceptions(I)I(Z)I(B)I(J)I(S)I(D)I(C)I(F)ImakeArraySignature'(Ljava/lang/String;I)Ljava/lang/String;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;ÉisSingleDimensionArray(Ljava/lang/Object;)ZÊisPrimitiveTypeName(Ljava/lang/String;)ZisRectangularArray Deprecated(I)Z(Z)Z(B)Z(J)Z(S)Z(D)Z(C)Z(F)ZgetDimensionLength(Ljava/lang/Object;)I getDimensions(Ljava/lang/Object;)[IË(I)[I(Z)[I(B)[I(J)[I(S)[I(D)[I(C)[I(F)[I getTrueLengthisArrayget((Ljava/lang/Object;[I)Ljava/lang/Object;getInt(Ljava/lang/Object;[I)I getBoolean(Ljava/lang/Object;[I)ZgetByte(Ljava/lang/Object;[I)BgetLong(Ljava/lang/Object;[I)JgetShort(Ljava/lang/Object;[I)S getDouble(Ljava/lang/Object;[I)DgetChar(Ljava/lang/Object;[I)CgetFloat(Ljava/lang/Object;[I)F'(Ljava/lang/Object;I)Ljava/lang/Object;(Ljava/lang/Object;I)I(Ljava/lang/Object;I)Z(Ljava/lang/Object;I)B(Ljava/lang/Object;I)J(Ljava/lang/Object;I)S(Ljava/lang/Object;I)D(Ljava/lang/Object;I)C(Ljava/lang/Object;I)FcheckDimensions(Ljava/lang/Object;[I)Vset)(Ljava/lang/Object;[ILjava/lang/Object;)V(Ljava/lang/Object;[II)V(Ljava/lang/Object;[IZ)V(Ljava/lang/Object;[IB)V(Ljava/lang/Object;[IJ)V(Ljava/lang/Object;[IS)V(Ljava/lang/Object;[ID)V(Ljava/lang/Object;[IC)V(Ljava/lang/Object;[IF)V((Ljava/lang/Object;ILjava/lang/Object;)V(Ljava/lang/Object;II)V(Ljava/lang/Object;IZ)V(Ljava/lang/Object;IB)V(Ljava/lang/Object;IJ)V(Ljava/lang/Object;IS)V(Ljava/lang/Object;ID)V(Ljava/lang/Object;IC)V(Ljava/lang/Object;IF)VgetArrayunique(([Ljava/lang/Object;)[Ljava/lang/Object;Ì duplicated([Ljava/lang/Object;)[Z anyDuplicated([Ljava/lang/Object;)Isort)([Ljava/lang/Object;Z)[Ljava/lang/Object;revcopygetIterableContent)(Ljava/lang/Iterable;)[Ljava/lang/Object;Írep((Ljava/lang/Object;I)[Ljava/lang/Object;ÎgetCloneMethod-(Ljava/lang/Class;)Ljava/lang/reflect/Method;Ï cloneObject&(Ljava/lang/Object;)Ljava/lang/Object; unboxDoubles([Ljava/lang/Double;)[DÐÑ unboxIntegers([Ljava/lang/Integer;)[IÒ unboxBooleans([Ljava/lang/Boolean;)[IÓisNA boxDoubles([D)[Ljava/lang/Double; boxIntegers([I)[Ljava/lang/Integer; boxBooleans([I)[Ljava/lang/Boolean; SourceFileRJavaArrayTools.java ©ªjava/util/HashMap ÔÕÖ ×ØZBÙÚSÛCÜFÝ Þß ÝàNotAnArrayException ©á âã\[+L? äå; æçprimitive type : int ©èprimitive type : boolean primitive type : byte primitive type : long primitive type : short primitive type : double primitive type : char primitive type : float java/lang/StringBuffer éê éë ÃÄ ìã  ¡ íÁ Þ$java/lang/Class îï ÝÁ ð³ ñò óÁ ÏÐ ArrayWrapper ©ô õàjava/lang/NullPointerException array is null öß÷ øÐ Þð ß àñ âò äó æô èõ êö ì÷ îø Þß àá âã äå æç èé êë ìí îï/RJavaArrayTools$ArrayDimensionMismatchException ©ù û ú û ü ý þ ÿ   ûü ûý ûþ ûÿ û û û û û ùújava/util/Vector Á ò [Ljava/lang/Object; java/lang/Comparable NotComparableException      à  java/lang/Cloneable  ! à java/lang/Throwable  $+java/lang/reflect/InvocationTargetException  clone  ß ¥¦  RJavaArrayTools !ò "à #$ §¨java/lang/Double /Ì %&java/lang/Integer %'java/lang/Boolean %( ­® )*java/lang/Object java/lang/ClassNotFoundExceptionjava/lang/String[I[Zjava/util/Iteratorjava/lang/reflect/Methodjava/lang/reflect/Method;[D[Ljava/lang/Double;[Ljava/lang/Integer;[Ljava/lang/Boolean;TYPELjava/lang/Class; java/util/Mapput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/lang/Bytejava/lang/Longjava/lang/Shortjava/lang/Characterjava/lang/FloatgetClass()Ljava/lang/Class;()Z(Ljava/lang/Class;)VgetName()Ljava/lang/String; replaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;replaceD(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;(Ljava/lang/String;)Vappend(C)Ljava/lang/StringBuffer;,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString containsKeyforName=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; lastIndexOflength()Iequals(Ljava/lang/Object;)V isRectangulargetComponentTypejava/lang/reflect/Array getLength(II)VsetInt setBooleansetBytesetLongsetShort setDoublesetCharsetFloataddsize newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;toArrayisAssignableFrom(Ljava/lang/Class;)Zjava/util/Arrays([Ljava/lang/Object;)Vjava/lang/Iterableiterator()Ljava/util/Iterator;hasNextnext()Ljava/lang/Object;()[Ljava/lang/Object; isAccessible setAccessible(Z)Vinvoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;castgetCause()Ljava/lang/Throwable;getDeclaredMethods()[Ljava/lang/reflect/Method;getParameterTypes()[Ljava/lang/Class; getSuperclass doubleValue()DintValue booleanValuedoubleToRawLongBits(D)JvalueOf(D)Ljava/lang/Double;(I)Ljava/lang/Integer;(Z)Ljava/lang/Boolean;longBitsToDouble(J)D!Š  ¡¢£¤‹¥¦§¨t©ª«*·±¬ ­®«¦j»Y·K*²¹W*²¹W* ² ¹W* ² ¹W* ²¹W*²¹W*²¹W*²¹W*°¬* %&' (,)8*D+P,\-h. ¯°«\**¶L+¶š »Y+·¿+¶M,¶¶°¬9:<=±ü1² ¯³«" »Y· ¿¬?² ¯´«" »Y!· ¿¬@² ¯µ«" »Y"· ¿¬A² ¯¶«" »Y#· ¿¬B² ¯·«" »Y$· ¿¬C² ¯¸«" »Y%· ¿¬D² ¯¹«" »Y&· ¿¬E² ¯º«" »Y'· ¿¬F² »¼«|5»(Y·)M>¢,[¶*W„§ÿñ,*¶+W*¸,š ,;¶*W,¶-°¬"LMNMP"Q)R0T± ý (ú ½¾«I ².*¹/™².*¹0À1°*+¸2°¬Z []±²¿ ÀÁ«[(*¸3š»Y*¶·¿*¶¶L+[¶4™¬¬¬cef&g± ü² ÃÄ«±d*¶5¤¬*¶6™¬*¶6™¬* ¶6™¬* ¶6™¬* ¶6™¬*¶6™¬*¶6™¬*¶6™¬¬¬* m no p+q6rAsLtWubv± ÅÁ«)*¸3š¬<*¸7 ¬»8Y*·9¶:<§M<¬ $!$¬"‚ ƒ …†!‰$‡%ˆ'б  ü NÆ ÅÇ«¬¬ ÅÈ«¬¬ ÅÉ«¬¬‘ ÅÊ«¬¬’ ÅË«¬¬“ ÅÌ«¬¬” ÅÍ«¬¬• ÅΫ¬¬– ÏЫ9*Ç »;Y<·=¿*¶L+¶š »Y+·¿=+¶™„+¶>L§ÿñ¬¬"¢£¤#¥%¦,§/¨7ª±ü1ü²; ϳ«" »Y· ¿¬­² Ï´«" »Y!· ¿¬®² ϵ«" »Y"· ¿¬¯² ϶«" »Y#· ¿¬°² Ï·«" »Y$· ¿¬±² ϸ«" »Y%· ¿¬²² Ϲ«" »Y&· ¿¬³² Ϻ«" »Y'· ¿¬´² ÑÒ«v*Ç »;Y<·=¿*¶L+¶š »Y+·¿*M*¸7>¼ :6+¶™),¸?6O„š§,¸@M+¶>L§ÿÖ¾¢O„§ÿï°¬NÀÂÃ#Ä%Æ*Ç/È2Ê9Ë?ÌFÍIÎNÏQÑWÒ_ÙgÚmÛsݱ&ü1ÿ1Óüú ²; ÑÔ«" »Y· ¿¬à² ÑÕ«" »Y!· ¿¬á² ÑÖ«" »Y"· ¿¬â² Ñ׫" »Y#· ¿¬ã² ÑØ«" »Y$· ¿¬ä² ÑÙ«" »Y%· ¿¬å² ÑÚ«" »Y&· ¿¬æ² ÑÛ«" »Y'· ¿¬ç² ÜЫ²Q*Ç »;Y<·=¿*¶L+¶š »Y+·¿*M>6+¶™!,¸?h>š¬„,¸@M+¶>L§ÿÞ¬¬6 óõö#÷%ù'ú*û1ü8ý>þAÿGO±ü1þ²; ܳ«" »Y· ¿¬² Ü´«" »Y!· ¿¬² ܵ«" »Y"· ¿¬² ܶ«" »Y#· ¿¬² Ü·«" »Y$· ¿¬ ² ܸ«" »Y%· ¿¬ ² ܹ«" »Y&· ¿¬ ² ܺ«" »Y'· ¿¬ ² ÝÁ«3*Ǭ*¶¶¬¬ ±Æ ÝÇ«¬¬ ÝÈ«¬¬ ÝÉ«¬¬ ÝÊ«¬¬ ÝË«¬¬ ÝÌ«¬¬! ÝÍ«¬¬" ÝΫ¬¬# Þß«'*+¸A++¾d.¸@°¬6²S àá«'*+¸A++¾d.¸B¬¬:²S âã«'*+¸A++¾d.¸C¬¬=²S äå«'*+¸A++¾d.¸D¬¬@²S æç«'*+¸A++¾d.¸E­¬C²S èé«'*+¸A++¾d.¸F¬¬F²S êë«'*+¸A++¾d.¸G¯¬I²S ìí«'*+¸A++¾d.¸H¬¬L²S îï«'*+¸A++¾d.¸I®¬O²S Þð«$ *¼ YO¸J°¬T²S àñ«$ *¼ YO¸K¬¬W²S âò«$ *¼ YO¸L¬¬Z²S äó«$ *¼ YO¸M¬¬]²S æô«$ *¼ YO¸N­¬`²S èõ«$ *¼ YO¸O¬¬c²S êö«$ *¼ YO¸P¯¬f²S ì÷«$ *¼ YO¸Q¬¬i²S îø«$ *¼ YO¸R®¬l²S ùú«M+¾=*¸7>¤ »SY·T¿±¬pqr su±ý²S ûü«,*+¸A++¾d.,¸U±¬ …†²S ûý«,*+¸A++¾d.¸V±¬ Š‹²S ûþ«,*+¸A++¾d.¸W±¬ ޲S ûÿ«,*+¸A++¾d.¸X±¬ ‘²S û«,*+¸A++¾d. ¸Y±¬ “”²S û«,*+¸A++¾d.¸Z±¬ –—²S û«,*+¸A++¾d.(¸[±¬ ™š²S û«,*+¸A++¾d.¸\±¬ œ²S û«,*+¸A++¾d.$¸]±¬ Ÿ ²S û«) *¼ YO,¸^±¬ ¤ ¥²S û«) *¼ YO¸_±¬ § ¨²S û«) *¼ YO¸`±¬ ª «²S û«) *¼ YO¸a±¬ ­ ®²S û «) *¼ YO ¸b±¬ ° ±²S û «) *¼ YO¸c±¬ ³ ´²S û «) *¼ YO(¸d±¬ ¶ ·²S û «) *¼ YO¸e±¬ ¹ º²S û «) *¼ YO$¸f±¬ ¼ ½²S ß«t+*+¸g+¾=*N6¤d¢-+.¸@N„§ÿì-°¬& ÂÃÅ Æ ÇÈÉ#Ê)ͱ þ²S «e £*¾<*¾¼M>*¾¢ ,T„§ÿó»hY·iN6¢^,3š§N*2:6`6¢9*2:,3™&¶j™š,T-¶kW6,T„§ÿÇ„§ÿ¢*¶¶>-¶l¸mÀn:-¶oW°¬^ØÙÚÛÚÞ"à+á5â;ã>åJæPçaèfékêrëuízå€à†ó™ô õ±L þ úþ hÿnhü0úÿnhù «Úd*¾<*¾¼M>*¾¢ ,T„§ÿó>¢D,3™§5*2:`6¢%*2:,3š¶j™,T„§ÿÛ„§ÿ½,°¬>ûüýþý!*/:@QV\b ± þ úü ý !ùú «9*¾<=¢0*2N`6¢*2:-¶j™¬„§ÿå„§ÿѬ¬*  (+17 ±ýý ùú «×i*¶¶>Mp,¶q™ »rY,·s¿*¾>*¸t:¸uš°¾l66¢)2:dd2SddS„§ÿÖ°¬>/0134#5(7,8/;6<@=G>U?`<fB±ü1ýnþ ø,²r «j+*¾<*¶¶>¸mÀnM>¢,dd*2S„§ÿî,°¬NOPQ#P)S± þnú «f'*¾<*¶¶>¸mÀnM>¢,*2S„§ÿò,°¬YZ[\[%^± þnú «e+»hY·iL*¹vM,¹w™+,¹x¶kW§ÿì+¶y°¬defg&i± ýh «N„*¶¸mÀnM*Ázš,°*¶¸{N-¶|6š-¶}§:66¢!*¶-*Àn¶¶€:,S„§ÿßš$-¶}§:¶‚¿:š -¶}¿,°(-0~5\j5\rjtr¬Zu vwz{#|(~-02€5…>†P‡V…\Œaj‰lŠrŒyŽ‚±8 ünÿn~üú#MG~þ ~ø²~  !««=M*Æ8*¶ƒL>+¾¢#+2M„,¶…¶6™ ,¶†¾š,°„§ÿÝ*¶‡K§ÿʰ¬* ”•– —˜™+š-—3;Ÿ±,ýÿ 1"úÿ1 #$«S*¶¸{L+¶|=š+¶}§N=N*¶+*Àn¶¶€Nš!+¶}§:¶‚¿:š+¶}¿-°~/;/C;EC¬F¥¦ §©¬ª«¯²/¶3·;³=´C¶I·N¸Qº±6ÿ~ÿG~ý ~ù²~ %&«”3*ǰ<*¾=¼N<¢-*2Ç ²ˆ§ *2¶‰R„§ÿã-°¬ÄÅ ÆÇ1ȱ3þ 'ÿ(''ÿ('' )*«“2*ǰ<*¾=¼ N<¢-*2Ç‹§ *2¶ŒO„§ÿä-°¬ÌÍ ÎÏ0б3þ Óÿ+ÓÓÿ+ÓÓ ,-«®:*ǰ<*¾=¼ N<¢%-*2Ç‹§*2¶™§O„§ÿÜ-°¬ÔÕ Ö×8رFþ Óÿ.ÓÓÿ .ÓÓÿ.ÓÓ /Ì«<&¸Ž²‘”š§¬¬Þ±@ 01«l1*ǰ<*¾=½’N<¢*1¸“š -*1¸”S„§ÿæ-°¬âã äå/æ± þ ( 23«k0*ǰ<*¾=½•N<¢*.‹Ÿ -*.¸–S„§ÿç-°¬êë ìí.î± þ + 45«š8*ǰ<*¾=½—N<¢"*.‹Ÿ-*.š§¸˜S„§ÿß-°¬òó ôõ6ö±4þ .ÿÓ..ÿÓ..6ª«<¸™³.š¸œ³ˆš¸œ¸Ž³‘±¬#ÀÁ78Ÿ SŠž rJava/src/java/RectangularArrayBuilder.java0000644000175100001440000001462515133274032020473 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Array ; /** * Builds rectangular java arrays */ public class RectangularArrayBuilder extends RJavaArrayIterator { // {{{ constructors /** * constructor * * @param payload one dimensional array * @param dimensions target dimensions * @throws NotAnArrayException if payload is not an array */ public RectangularArrayBuilder( Object payload, int[] dimensions) throws NotAnArrayException, ArrayDimensionException { super( dimensions ) ; if( !RJavaArrayTools.isArray(payload) ){ throw new NotAnArrayException( payload.getClass() ) ; } if( !RJavaArrayTools.isSingleDimensionArray(payload)){ throw new ArrayDimensionException( "not a single dimension array : " + payload.getClass() ) ; } if( dimensions.length == 1 ){ array = payload ; } else{ String typeName = RJavaArrayTools.getObjectTypeName( payload ); Class clazz = null ; try{ clazz = RJavaArrayTools.getClassForSignature( typeName, payload.getClass().getClassLoader() ); } catch( ClassNotFoundException e){/* should not happen */} array = Array.newInstance( clazz , dimensions ) ; if( typeName.equals( "I" ) ){ fill_int( (int[])payload ) ; } else if( typeName.equals( "Z" ) ){ fill_boolean( (boolean[])payload ) ; } else if( typeName.equals( "B" ) ){ fill_byte( (byte[])payload ) ; } else if( typeName.equals( "J" ) ){ fill_long( (long[])payload ) ; } else if( typeName.equals( "S" ) ){ fill_short( (short[])payload ) ; } else if( typeName.equals( "D" ) ){ fill_double( (double[])payload ) ; } else if( typeName.equals( "C" ) ){ fill_char( (char[])payload ) ; } else if( typeName.equals( "F" ) ){ fill_float( (float[])payload ) ; } else{ fill_Object( (Object[])payload ) ; } } } public RectangularArrayBuilder( Object payload, int length ) throws NotAnArrayException, ArrayDimensionException{ this( payload, new int[]{ length } ) ; } // java < 1.5 kept happy public RectangularArrayBuilder(int x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public RectangularArrayBuilder(boolean x, int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public RectangularArrayBuilder(byte x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public RectangularArrayBuilder(long x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public RectangularArrayBuilder(short x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public RectangularArrayBuilder(double x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public RectangularArrayBuilder(char x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public RectangularArrayBuilder(float x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } public RectangularArrayBuilder(int x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public RectangularArrayBuilder(boolean x, int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public RectangularArrayBuilder(byte x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public RectangularArrayBuilder(long x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public RectangularArrayBuilder(short x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public RectangularArrayBuilder(double x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public RectangularArrayBuilder(char x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public RectangularArrayBuilder(float x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ fill_** private void fill_int( int[] payload ){ int k; while( hasNext() ){ int[] current = (int[])next() ; k = start ; for( int j=0; jinstances of the Number interface are treated specially, in order to * allow comparing Numbers of different classes, for example it is allowed * to compare a Double with an Integer. if the Numbers have the same class, * they are compared normally, otherwise they are first converted to Doubles * and then compared

* * @param a an object * @param b another object * * @return the result of a.compareTo(b) if this makes sense * @throws NotComparableException if the two objects are not comparable */ public static int compare( Object a, Object b ) throws NotComparableException{ int res ; if( a.equals( b ) ) return 0 ; // treat Number s separately if( a instanceof Number && b instanceof Number && !( a.getClass() == b.getClass() ) ){ Double _a = Double.valueOf( ((Number)a).doubleValue() ); Double _b = Double.valueOf( ((Number)b).doubleValue() ); return _a.compareTo( _b ); } if( ! ( a instanceof Comparable ) ) throw new NotComparableException( a ); if( ! ( b instanceof Comparable ) ) throw new NotComparableException( b ); try{ res = ( (Comparable)a ).compareTo( b ) ; } catch( ClassCastException e){ try{ res = - ((Comparable)b).compareTo( a ) ; } catch( ClassCastException f){ throw new NotComparableException( a, b ); } } return res ; } } rJava/src/java/NotComparableException.java0000644000175100001440000000132515133274032020314 0ustar hornikusers/** * Exception generated when two objects cannot be compared * * Such cases happen when an object does not implement the Comparable * interface or when the comparison produces a ClassCastException */ public class NotComparableException extends Exception{ public NotComparableException(Object a, Object b){ super( "objects of class " + a.getClass().getName() + " and " + b.getClass().getName() + " are not comparable" ) ; } public NotComparableException( Object o){ this( o.getClass().getName() ) ; } public NotComparableException( Class cl){ this( cl.getName() ) ; } public NotComparableException( String type ){ super( "class " + type + " does not implement java.util.Comparable" ) ; } } rJava/src/java/PrimitiveArrayException.class0000644000175100001440000000074415133274036020731 0ustar hornikusersÊþº¾2    (Ljava/lang/String;)VCodeLineNumberTable SourceFilePrimitiveArrayException.javajava/lang/StringBuilder :cannot convert to single dimension array of primitive type   PrimitiveArrayExceptionjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;!  4*»Y·¶+¶¶·±  rJava/src/java/NotAnArrayException.class0000644000175100001440000000104415133274036017772 0ustar hornikusersÊþº¾2"     (Ljava/lang/Class;)VCodeLineNumberTable(Ljava/lang/String;)V SourceFileNotAnArrayException.javajava/lang/StringBuilder not an array :   ! NotAnArrayExceptionjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;java/lang/ClassgetName()Ljava/lang/String;toString!   7*»Y·¶+¶¶¶·±   "*+·±   rJava/src/java/RectangularArrayBuilder.class0000644000175100001440000001170315133274037020656 0ustar hornikusersÊþº¾2Ò @o pqr Fs t puvw xy z { | } ?~ p H€ p‚ ƒ„… G†‡ ?ˆ‰Š ?‹Œ ?Ž ?‘’“ ?”•– ?—˜™ ?š›œ ?ž ?Ÿ ?  @x¡ }¢£¤¥¦§¨ ?© ?ª ?« ?¬­®(Ljava/lang/Object;[I)VCodeLineNumberTable StackMapTable¯°± Exceptions(Ljava/lang/Object;I)V(I[I)V(Z[I)V(B[I)V(J[I)V(S[I)V(D[I)V(C[I)V(F[I)V(II)V(ZI)V(BI)V(JI)V(SI)V(DI)V(CI)V(FI)Vfill_int([I)V fill_boolean([Z)V fill_byte([B)V fill_long([J)V fill_short([S)V fill_double([D)V fill_char([C)V fill_float([F)V fill_Object([Ljava/lang/Object;)V SourceFileRectangularArrayBuilder.java A\² ³´NotAnArrayException µ¶ A· ¸´ArrayDimensionExceptionjava/lang/StringBuilder A¹not a single dimension array : º» º¼ ½¾ A¿ ÀÁ Âà ÄÅ ÆÇ java/lang/ClassNotFoundExceptionÈ ÉÊI Ë´[I [\Z[Z ]^B[B _`J[J abS[S cdD[D efC[C ghF[F ij[Ljava/lang/Object; kl ABprimitive type : int primitive type : boolean primitive type : byte primitive type : long primitive type : short primitive type : double primitive type : char primitive type : float ÌÍ ÎÏ Ð… Ñ…RectangularArrayBuilderRJavaArrayIteratorjava/lang/Objectjava/lang/Stringjava/lang/ClassRJavaArrayToolsisArray(Ljava/lang/Object;)ZgetClass()Ljava/lang/Class;(Ljava/lang/Class;)VisSingleDimensionArray()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;-(Ljava/lang/Object;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;(Ljava/lang/String;)VarrayLjava/lang/Object;getObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;getClassLoader()Ljava/lang/ClassLoader;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;java/lang/reflect/Array newInstance'(Ljava/lang/Class;[I)Ljava/lang/Object;equalshasNext()Znext()Ljava/lang/Object;start increment!?@ABCë*,·+¸š»Y+¶·¿+¸š!»Y»Y·  ¶ +¶¶ ¶ ·¿,¾  *+µ§Ï+¸N:-+¶¶¸:§:*,¸µ-¶™*+À·§—-¶™*+À·§ƒ-¶™*+À·§o-¶™*+À ·!§[-"¶™*+À#·$§G-%¶™*+À&·'§3-(¶™*+À)·*§-+¶™*+À,·-§ *+À.·/±S`cDz =CK P!S#`$e&o'x(ƒ)Œ*—+ ,«-´.¿/È0Ó1Ü2ç3ð4û568<E9ÿ?F$ ÿ?FGHùIAJC) *+¼ YO·0±D > ?IAKC&*·1»Y2·3¿DBIALC&*·1»Y4·3¿DCIAMC&*·1»Y5·3¿DDIANC&*·1»Y6·3¿DEIAOC&*·1»Y7·3¿DFIAPC&*·1»Y8·3¿DGIAQC&*·1»Y9·3¿DHIARC&*·1»Y:·3¿DIIASC&*·1»Y2·3¿DKIATC&*·1»Y4·3¿DLIAUC&*·1»Y5·3¿DMIAVC&*·1»Y6·3¿DNIAWC&*·1»Y7·3¿DOIAXC&*·1»Y8·3¿DPIAYC&*·1»Y9·3¿DQIAZC&*·1»Y:·3¿DRI[\C6*¶;™1*¶<ÀN*´==6-¾¢-+.O„*´>`=§ÿè§ÿαD"XYZ[\%[2^5_Eþùú]^C6*¶;™1*¶<ÀN*´==6-¾¢-+3T„*´>`=§ÿè§ÿαD"cdefg%f2i5jEþùú_`C6*¶;™1*¶<ÀN*´==6-¾¢-+3T„*´>`=§ÿè§ÿαD"nopqr%q2t5uEþùúabC6*¶;™1*¶<À N*´==6-¾¢-+/P„*´>`=§ÿè§ÿαD"yz{|}%|25€Eþ ùúcdC6*¶;™1*¶<À#N*´==6-¾¢-+5V„*´>`=§ÿè§ÿαD"„…†‡ˆ%‡2Š5‹Eþ#ùúefC6*¶;™1*¶<À&N*´==6-¾¢-+1R„*´>`=§ÿè§ÿαD"‘’“%’2•5–Eþ&ùúghC6*¶;™1*¶<À)N*´==6-¾¢-+4U„*´>`=§ÿè§ÿαD"š›œž%2 5¡Eþ)ùúijC6*¶;™1*¶<À,N*´==6-¾¢-+0Q„*´>`=§ÿè§ÿαD"¥¦§¨©%¨2«5¬Eþ,ùúklC6*¶;™1*¶<À.N*´==6-¾¢-+2S„*´>`=§ÿè§ÿαD"°±²³´%³2¶5·Eþ.ùúmnrJava/src/java/FlatException.class0000644000175100001440000000042215133274036016641 0ustar hornikusersÊþº¾2   ()VCodeLineNumberTable SourceFileFlatException.java#Can only flatten rectangular arrays  FlatExceptionjava/lang/Exception(Ljava/lang/String;)V!#*·±   rJava/src/java/ObjectArrayException.class0000644000175100001440000000070115133274036020160 0ustar hornikusersÊþº¾2    (Ljava/lang/String;)VCodeLineNumberTable SourceFileObjectArrayException.javajava/lang/StringBuilder array is of primitive type :   ObjectArrayExceptionjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;!  4*»Y·¶+¶¶·±  rJava/src/java/ArrayDimensionException.java0000644000175100001440000000020415133274032020505 0ustar hornikuserspublic class ArrayDimensionException extends Exception{ public ArrayDimensionException(String message){ super( message ) ; } } rJava/src/java/ArrayWrapper_Test.java0000644000175100001440000013225415133274032017333 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Test suite for ArrayWrapper */ public class ArrayWrapper_Test { // {{{ main public static void main(String[] args ){ try{ runtests() ; } catch( TestException e){ e.printStackTrace(); System.exit(1); } System.out.println( "\nALL PASSED\n" ) ; System.exit( 0 ); } // }}} // {{{ runtests public static void runtests() throws TestException { // {{{ multi dim array of primitives // {{{ flat_int System.out.println( "flatten int[]" ); flatten_int_1(); System.out.println( "PASSED" ); System.out.println( "flatten int[][]" ); flatten_int_2(); System.out.println( "PASSED" ); System.out.println( "flatten int[][][]" ); flatten_int_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_boolean System.out.println( "flatten boolean[]" ); flatten_boolean_1(); System.out.println( "PASSED" ); System.out.println( "flatten boolean[][]" ); flatten_boolean_2(); System.out.println( "PASSED" ); System.out.println( "flatten boolean[][][]" ); flatten_boolean_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_byte System.out.println( "flatten byte[]" ); flatten_byte_1(); System.out.println( "PASSED" ); System.out.println( "flatten byte[][]" ); flatten_byte_2(); System.out.println( "PASSED" ); System.out.println( "flatten byte[][][]" ); flatten_byte_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_long System.out.println( "flatten long[]" ); flatten_long_1(); System.out.println( "PASSED" ); System.out.println( "flatten long[][]" ); flatten_long_2(); System.out.println( "PASSED" ); System.out.println( "flatten long[][][]" ); flatten_long_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_long System.out.println( "flatten short[]" ); flatten_short_1(); System.out.println( "PASSED" ); System.out.println( "flatten short[][]" ); flatten_short_2(); System.out.println( "PASSED" ); System.out.println( "flatten short[][][]" ); flatten_short_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_double System.out.println( "flatten double[]" ); flatten_double_1(); System.out.println( "PASSED" ); System.out.println( "flatten double[][]" ); flatten_double_2(); System.out.println( "PASSED" ); System.out.println( "flatten double[][][]" ); flatten_double_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_char System.out.println( "flatten char[]" ); flatten_char_1(); System.out.println( "PASSED" ); System.out.println( "flatten char[][]" ); flatten_char_2(); System.out.println( "PASSED" ); System.out.println( "flatten char[][][]" ); flatten_char_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_float System.out.println( "flatten float[]" ); flatten_float_1(); System.out.println( "PASSED" ); System.out.println( "flatten float[][]" ); flatten_float_2(); System.out.println( "PASSED" ); System.out.println( "flatten float[][][]" ); flatten_float_3(); System.out.println( "PASSED" ); // }}} // }}} // {{{ multi dim array of Object // {{{ flat_String System.out.println( "flatten String[]" ); flatten_String_1(); System.out.println( "PASSED" ); System.out.println( "flatten String[][]" ); flatten_String_2(); System.out.println( "PASSED" ); System.out.println( "flatten String[][][]" ); flatten_String_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_String System.out.println( "flatten Point[]" ); flatten_Point_1(); System.out.println( "PASSED" ); System.out.println( "flatten Point[][]" ); flatten_Point_2(); System.out.println( "PASSED" ); System.out.println( "flatten Point[][][]" ); flatten_Point_3(); System.out.println( "PASSED" ); // }}} // }}} } //}}} // {{{ flat multi dimen array of java primitives // {{{ flatten_int_1 private static void flatten_int_1() throws TestException{ int[] o = new int[5] ; for( int i=0;i<5;i++) o[i] = i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_int_2 private static void flatten_int_2() throws TestException{ int[][] o = RectangularArrayExamples.getIntDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[][]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_int_3 private static void flatten_int_3() throws TestException{ int[][][] o = RectangularArrayExamples.getIntTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_1 private static void flatten_boolean_1() throws TestException{ boolean[] o = new boolean[5] ; boolean current = false; for( int i=0;i<5;i++){ o[i] = current ; current = !current ; } ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(boolean[]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[]) >> FlatException") ; } current = false ; for( int i=0; i<5; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_2 private static void flatten_boolean_2() throws TestException{ boolean[][] o = RectangularArrayExamples.getBooleanDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(boolean[][]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(boolean[][]) >> FlatException") ; } boolean current = false ; for( int i=0; i<10; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_3 private static void flatten_boolean_3() throws TestException{ boolean[][][] o = RectangularArrayExamples.getBooleanTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(boolean[][][]) >> FlatException") ; } boolean current = false ; for( int i=0; i<30; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_1 private static void flatten_byte_1() throws TestException{ byte[] o = new byte[5] ; for( int i=0;i<5;i++) o[i] = (byte)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(byte[]).getObjectTypeName() != 'I'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_2 private static void flatten_byte_2() throws TestException{ byte[][] o = RectangularArrayExamples.getByteDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(byte[][]).getObjectTypeName() != 'B'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_3 private static void flatten_byte_3() throws TestException{ byte[][][] o = RectangularArrayExamples.getByteTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'B'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_1 private static void flatten_long_1() throws TestException{ long[] o = new long[5] ; for( int i=0;i<5;i++) o[i] = (long)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_2 private static void flatten_long_2() throws TestException{ long[][] o = RectangularArrayExamples.getLongDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[][]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_3 private static void flatten_long_3() throws TestException{ long[][][] o = RectangularArrayExamples.getLongTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[][][]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_1 private static void flatten_short_1() throws TestException{ short[] o = new short[5] ; for( int i=0;i<5;i++) o[i] = (short)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(long[]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_2 private static void flatten_short_2() throws TestException{ short[][] o = RectangularArrayExamples.getShortDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(short[][]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_3 private static void flatten_short_3() throws TestException{ short[][][] o = RectangularArrayExamples.getShortTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(short[][][]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_1 private static void flatten_double_1() throws TestException{ double[] o = new double[5] ; for( int i=0;i<5;i++) o[i] = i+0.0 ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_2 private static void flatten_double_2() throws TestException{ double[][] o = RectangularArrayExamples.getDoubleDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[][]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_3 private static void flatten_double_3() throws TestException{ double[][][] o = RectangularArrayExamples.getDoubleTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[][][]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_1 private static void flatten_char_1() throws TestException{ char[] o = new char[5] ; for( int i=0;i<5;i++) o[i] = (char)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (char)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_2 private static void flatten_char_2() throws TestException{ char[][] o = RectangularArrayExamples.getCharDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[][]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_3 private static void flatten_char_3() throws TestException{ char[][][] o = RectangularArrayExamples.getCharTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[][][]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (char)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_1 private static void flatten_float_1() throws TestException{ float[] o = new float[5] ; for( int i=0;i<5;i++) o[i] = (float)(i+0.0) ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_2 private static void flatten_float_2() throws TestException{ float[][] o = RectangularArrayExamples.getFloatDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[][]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_3 private static void flatten_float_3() throws TestException{ float[][][] o = RectangularArrayExamples.getFloatTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[][][]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (float)(i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} // {{{ flat array of String // {{{ flatten_String_1 private static void flatten_String_1() throws TestException{ String[] o = new String[5] ; for( int i=0;i<5;i++) o[i] = ""+i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(float[]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( ! flat[i].equals(""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_String_2 private static void flatten_String_2() throws TestException{ String[][] o = RectangularArrayExamples.getStringDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[][]) is primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(float[][]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( ! flat[i].equals( ""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_String_3 private static void flatten_String_3() throws TestException{ String[][][] o = RectangularArrayExamples.getStringTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[][][]) is primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(String[][][]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( !flat[i].equals( ""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} // {{{ flat array of Point // {{{ flatten_Point_1 private static void flatten_Point_1() throws TestException{ DummyPoint[] o = new DummyPoint[5] ; for( int i=0;i<5;i++) o[i] = new DummyPoint(i,i) ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat ; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(DummyPoint[]) >> FlatException") ; } DummyPoint p ; for( int i=0; i<5; i++){ p = flat[i] ; if( p.x != i || p.y != i) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_Point_2 private static void flatten_Point_2() throws TestException{ DummyPoint[][] o = RectangularArrayExamples.getDummyPointDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[][]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[][]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(DummyPoint[][]) >> FlatException") ; } DummyPoint p; for( int i=0; i<10; i++){ p = flat[i] ; if( p.x != i || p.y != i) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_Point_3 private static void flatten_Point_3() throws TestException{ DummyPoint[][][] o = RectangularArrayExamples.getDummyPointTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[][][]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[][][]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(Object[][][]) >> FlatException") ; } DummyPoint p; for( int i=0; i<30; i++){ p = flat[i]; if( p.x != i || p.y != i ) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} } rJava/src/java/RectangularArraySummary.class0000644000175100001440000000716615133274037020735 0ustar hornikusersÊþº¾2… C D EF G EH I .J KL EM NO P Q RS T U V W X Y Z[ \ K] ^_ `a b KcdelengthItypeNameLjava/lang/String; isprimitiveZ componentTypeLjava/lang/Class;(Ljava/lang/Object;[I)VCodeLineNumberTable StackMapTablefg Exceptionsh(Ljava/lang/Object;I)Vmin(Z)Ljava/lang/Object;maxrange(Z)[Ljava/lang/Object;(([Ljava/lang/Object;Z)Ljava/lang/Object;)([Ljava/lang/Object;Z)[Ljava/lang/Object;checkComparableObjects()VcontainsComparableObjects()Zsmaller'(Ljava/lang/Object;Ljava/lang/Object;)Zbigger SourceFileRectangularArraySummary.java )i jkl mn #$ op %& qrs tu vw '( java/lang/ClassNotFoundException :; )* xg[Ljava/lang/Object; 38 y= z{ >? 58 @? 69java/lang/Comparable |} ~r € <=NotComparableException )‚ ƒ„RectangularArraySummaryRJavaArrayIteratorjava/lang/Object[INotAnArrayException([I)VarrayLjava/lang/Object;RJavaArrayToolsgetObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;isPrimitiveTypeName(Ljava/lang/String;)ZgetClass()Ljava/lang/Class;java/lang/ClassgetClassLoader()Ljava/lang/ClassLoader;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class; dimensionshasNextnext()Ljava/lang/Object; compareTo(Ljava/lang/Object;)IgetComponentTypejava/lang/reflect/Array newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;(Ljava/lang/String;)VisAssignableFrom(Ljava/lang/Class;)Z! !"#$%&'( )*+8*,·*+µ*+¸µ**´¸µ**´+¶¶¸ µ §N*¶ ±/2 ," /3 7!-ÿ2./ 01)2+) *+¼ YO· ±, $ %0134+ä\*´™°M6*´¾ *´À¸°*¶™3*¶À¸N-Ç šÿè°š -M6§ÿÙ-,¸™ÿÑ-M§ÿÌ,°,B,- / 134#8*96::;@=E>G?M@UAZE-. þ.ÿ.. ÿ .54+ä\*´™°M6*´¾ *´À¸°*¶™3*¶À¸N-Ç šÿè°š -M6§ÿÙ-,¸™ÿÑ-M§ÿÌ,°,BOP S UWX#\*]6^:_@aEbGcMdUeZi-. þ.ÿ.. ÿ .67+v*´™°*´¾ *´À¸°M6*¶™M*¶À¸N-Ç šÿè°š -M6§ÿÙ-2,2¸™ ,-2S-2,2¸™ÿ»,-2S§ÿ²,°,Jst wx{ }#€*6‚:ƒ@…E†G‡M‰YŠ_Œkt“-0 þÿ ÿ 38+ÖI*¾=N66¢9*2:Ç š$°š N6§-À¹žN„§ÿÇ-°,:¡¢¤§¨©ª"¬'­*®0¯>°A§G´-;ÿ .ÿ.. ÿ. 58+ÖI*¾=N66¢9*2:Ç š$°š N6§-À¹œN„§ÿÇ-°,:¾¿ÁÄÅÆÇ"É'Ê*Ë0Ì>ÍAÄGÑ-;ÿ .ÿ.. ÿ. 69+v*¾=*¶¶¸ÀN66¢Y*2:Ç šD°š-S-S6§--2À¹œ-S-2À¹ž-S„§ÿ§-°,FÛÜÞáâ$ã)ä/æ4ç9è>éDìTíYðiñnát÷-<ÿÿ.ÿ:;+9*¶š»Y*´·¿±, üý-0<=+" *´ ¶¬, >?+6*À+¹œ§¬,-@ @?+6*À+¹ž§¬,-@ABrJava/src/java/RJavaComparator.class0000644000175100001440000000203615133274037017133 0ustar hornikusersÊþº¾28      !"# $ %& '()()VCodeLineNumberTablecompare'(Ljava/lang/Object;Ljava/lang/Object;)I StackMapTable Exceptions SourceFileRJavaComparator.java  *+java/lang/Number ,- ./0 12 34java/lang/ComparableNotComparableException 5 36java/lang/ClassCastException 7RJavaComparatorjava/lang/Objectequals(Ljava/lang/Object;)ZgetClass()Ljava/lang/Class; doubleValue()Djava/lang/DoublevalueOf(D)Ljava/lang/Double; compareTo(Ljava/lang/Double;)I(Ljava/lang/Object;)V(Ljava/lang/Object;)I'(Ljava/lang/Object;Ljava/lang/Object;)V!*·± *+¶™¬*Á™3+Á™,*¶+¶¥!*À¶¸N+À¶¸:-¶¬*Áš » Y*· ¿+Áš » Y+· ¿*À+¹ =§N+À*¹ t=§:» Y*+· ¿¬alo p| > #. :!A$Q%a(l/o)p+|.,-‹0, 6M ÿ  ÿ  rJava/src/java/TestException.class0000644000175100001440000000033615133274036016676 0ustar hornikusersÊþº¾2    (Ljava/lang/String;)VCodeLineNumberTable SourceFileTestException.java  TestExceptionjava/lang/Exception!*+·± rJava/src/java/RJavaImport.java0000644000175100001440000001033015133274032016101 0ustar hornikusers import java.util.regex.Pattern ; import java.util.regex.Matcher ; import java.util.Vector; import java.util.HashMap; import java.util.Map; import java.util.Collection; import java.util.Set ; import java.util.Iterator ; import java.io.Serializable; /** * Utilities to manage java packages and how they are "imported" to R * databases. This is the back door of the javaImport * system in the R side * * @author Romain Francois <francoisromain@free.fr> */ public class RJavaImport implements Serializable { /** * Debug flag. Prints some messages if it is set to TRUE */ public static boolean DEBUG = false ; /** * list of imported packages */ /* TODO: vector is not good enough, we need to control the order in which the packages appear */ private Vector/**/ importedPackages ; /** * maps a simple name to a fully qualified name */ /* String -> java.lang.String */ /* should we cache the Class instead ? */ private Map/**/ cache ; /** * associated class loader */ public ClassLoader loader ; /** * Constructor. Initializes the imported package vector and the cache */ public RJavaImport( ClassLoader loader ){ this.loader = loader ; importedPackages = new Vector/**/(); cache = new HashMap/**/() ; } /** * Look for the class in the set of packages * * @param clazz the simple class name * * @return an instance of Class representing the actual class */ public Class lookup( String clazz){ Class res = lookup_(clazz) ; if( DEBUG ) System.out.println( " [J] lookup( '" + clazz + "' ) = " + (res == null ? " " : ("'" + res.getName() + "'" ) ) ) ; return res ; } private Class lookup_( String clazz ){ Class res = null ; if( cache.containsKey( clazz ) ){ try{ String fullname = (String)cache.get( clazz ) ; Class cl = Class.forName( fullname ) ; return cl ; } catch( Exception e ){ /* does not happen */ } } /* first try to see if the class does not exist verbatim */ try{ res = Class.forName( clazz ) ; } catch( Exception e){} if( res != null ) { cache.put( clazz, clazz ) ; return res; } int npacks = importedPackages.size() ; if( DEBUG ) System.out.println( " [J] " + npacks + " packages" ) ; if( npacks > 0 ){ for( int i=0; i*/ set = cache.keySet() ; int size = set.size() ; String[] res = new String[size]; set.toArray( res ); if( DEBUG ) System.out.println( " [J] getKnownClasses().length = " + res.length ) ; return res ; } public static Class lookup( String clazz , Set importers ){ Class res ; Iterator iterator = importers.iterator() ; while( iterator.hasNext()){ RJavaImport importer = (RJavaImport)iterator.next() ; res = importer.lookup( clazz ) ; if( res != null ) return res ; } return null ; } } rJava/src/java/RectangularArraySummary.java0000644000175100001440000001366015133274032020540 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Array ; /** * Utility class to extract something from a rectangular array */ public class RectangularArraySummary extends RJavaArrayIterator { private int length ; private String typeName ; private boolean isprimitive ; private Class componentType ; /** * Constructor * * @param array the array to check * @throws NotAnArrayException if array is not an array */ public RectangularArraySummary(Object array, int[] dimensions) throws NotAnArrayException, NotComparableException { super( dimensions ); this.array = array ; typeName = RJavaArrayTools.getObjectTypeName(array ); isprimitive = RJavaArrayTools.isPrimitiveTypeName( typeName ) ; try{ componentType = RJavaArrayTools.getClassForSignature( typeName , array.getClass().getClassLoader() ) ; } catch( ClassNotFoundException e){} checkComparableObjects() ; } public RectangularArraySummary(Object array, int length ) throws NotAnArrayException, NotComparableException{ this( array, new int[]{ length } ); } /** * Iterates over the array to find the minimum value * (in the sense of the Comparable interface) */ public Object min( boolean narm ) { if( isprimitive ){ return null ; // TODO :implement } Object smallest = null ; Object current ; boolean found = false ; if( dimensions.length == 1 ){ return( min( (Object[])array, narm ) ) ; } else{ /* need to iterate */ while( hasNext() ){ current = min( (Object[])next(), narm ) ; if( current == null ){ if( !narm ) return null ; } else{ if( !found ){ smallest = current ; found = true ; } else if( smaller( current, smallest ) ) { smallest = current ; } } } return smallest ; } } /** * Iterates over the array to find the maximum value * (in the sense of the Comparable interface) */ public Object max( boolean narm ) { if( isprimitive ){ return null ; // TODO :implement } Object biggest = null ; Object current ; boolean found = false ; if( dimensions.length == 1 ){ return( max( (Object[])array, narm ) ) ; } else{ /* need to iterate */ while( hasNext() ){ current = max( (Object[])next(), narm ) ; if( current == null ){ if( !narm ) return null ; } else{ if( !found ){ biggest = current ; found = true ; } else if( bigger( current, biggest) ){ biggest = current ; } } } return biggest ; } } /** * Iterates over the array to find the range of the java array * (in the sense of the Comparable interface) */ public Object[] range( boolean narm ) { if( isprimitive ){ return null ; // TODO :implement } if( dimensions.length == 1 ){ return( range( (Object[])array, narm ) ) ; } else{ Object[] range = null ; Object[] current ; boolean found = false ; /* need to iterate */ while( hasNext() ){ current = range( (Object[])next(), narm ) ; if( current == null ){ if( !narm ) return null ; } else{ if( !found ){ range = current ; found = true ; } else { if( bigger( current[1], range[1] ) ){ range[1] = current[1] ; } if( smaller( current[0], range[0] ) ){ range[0] = current[0] ; } } } } return range ; } } /** * returns the minimum (in the sense of Comparable) of the * objects in the one dimensioned array */ private static Object min( Object[] x, boolean narm ){ int n = x.length ; Object smallest = null ; Object current ; boolean found_min = false; // find somewhere to start from () for( int i=0; i 0 ) { smallest = current ; } } } return smallest ; } /** * returns the minimum (in the sense of Comparable) of the * objects in the one dimensioned array */ private static Object max( Object[] x, boolean narm ){ int n = x.length ; Object biggest = null ; Object current ; boolean found_min = false; // find somewhere to start from () for( int i=0; i 0 ) { range[0] = current ; } } } } return range ; } public void checkComparableObjects() throws NotComparableException { if( ! containsComparableObjects() ) throw new NotComparableException( typeName ) ; } public boolean containsComparableObjects(){ return Comparable.class.isAssignableFrom( componentType ) ; } // TODO : use these private static boolean smaller( Object x, Object y){ return ( (Comparable)x ).compareTo(y) < 0 ; } private static boolean bigger( Object x, Object y){ return ( (Comparable)x ).compareTo(y) > 0 ; } } rJava/src/java/RJavaClassLoader.java0000644000175100001440000004556215133274032017042 0ustar hornikusers// :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: // {{{ imports import java.io.*; import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Vector; import java.util.Enumeration; import java.util.Iterator; import java.util.StringTokenizer; import java.util.zip.*; // }}} /** * Class loader used internally by rJava * * The class manages the class paths and the native libraries (jri, ...) */ public class RJavaClassLoader extends URLClassLoader { // {{{ fields /** * path of RJava */ String rJavaPath ; /** * lib sub directory of rJava */ String rJavaLibPath; /** * map of libraries */ HashMap/**/ libMap; /** * The class path vector */ Vector/**/ classPath; /** * singleton */ public static RJavaClassLoader primaryLoader = null; /** * Print debug messages if is set to true */ public static boolean verbose = false; /** * Should the system class loader be used to resolve classes * as well as this class loader */ public boolean useSystem = true; // }}} // {{{ UnixFile class /** * Light extension of File that handles file separators and updates */ class UnixFile extends File { /** * cached "last time modified" stamp */ long lastModStamp; /** * Constructor. Modifies the path so that * the proper path separator is used (most useful on windows) */ public UnixFile(String fn) { super( u2w(fn) ) ; lastModStamp=0; } /** * @return whether the file modified since last time the update method was called */ public boolean hasChanged() { long curMod = lastModified(); return (curMod != lastModStamp); } /** * Cache the result of the lastModified stamp */ public void update() { lastModStamp = lastModified(); } } // }}} // {{{ UnixJarFile /** * Specialization of UnixFile that deals with jar files */ class UnixJarFile extends UnixFile { /** * The cached jar file */ private ZipFile zfile ; /** * common prefix for all URLs within this jar file */ private String urlPrefix ; public UnixJarFile( String filename ){ super( filename ); } /* @Override */ public void update(){ try { if (zfile != null){ zfile.close(); } zfile = new ZipFile( this ) ; } catch (Exception tryCloseX) {} /* time stamp */ super.update( ) ; } /** * Get an input stream for a resource contained in the jar file * * @param name file name of the resource within the jar file * @return an input stream representing the resouce if it exists or null */ public InputStream getResourceAsStream( String name ){ if (zfile==null || hasChanged()) { update(); } try { if (zfile == null) return null; ZipEntry e = zfile.getEntry(name); if (e != null) return zfile.getInputStream(e); } catch(Exception e) { if (verbose) System.err.println("RJavaClassLoader$UnixJarFile: exception: "+e.getMessage()); } return null; } public URL getResource(String name ){ if( zfile == null || zfile.getEntry( name ) == null ){ return null ; } URL u = null ; if( urlPrefix == null ){ try{ urlPrefix = "jar:" + toURL().toString() + "!" ; } catch( java.net.MalformedURLException ex){ } } try{ u = new URL( urlPrefix + name ) ; } catch( java.net.MalformedURLException ex ){ /* not to worry */ } return u ; } } // }}} // {{{ UnixDirectory class /** * Specialization of UnixFile representing a directory */ /* it is not really a specialization but makes possible to dispatch on instanceof*/ class UnixDirectory extends UnixFile { public UnixDirectory( String dirname ){ super( dirname ) ; } } // }}} // {{{ getPrimaryLoader /** * Returns the singleton instance of RJavaClassLoader */ public static RJavaClassLoader getPrimaryLoader() { return primaryLoader; } // }}} // {{{ constructor /** * Constructor. The first time an RJavaClassLoader is created, it is * cached as the primary loader. * * @param path path of the rJava package * @param libpath lib sub directory of the rJava package */ public RJavaClassLoader(String path, String libpath) { this(path, libpath, null); } /** * Constructor. The first time an RJavaClassLoader is created, it is * cached as the primary loader. * * @param path path of the rJava package * @param libpath lib sub directory of the rJava package * @param parent parent loader if we should fall back upstream or NULL */ public RJavaClassLoader(String path, String libpath, RJavaClassLoader parent) { super(new URL[] {}, (parent == null) ? ClassLoader.getSystemClassLoader() : parent); // respect rJava.debug level String rjd = System.getProperty("rJava.debug"); if (rjd != null && rjd.length() > 0 && !rjd.equals("0")) verbose = true; if (verbose) System.out.println("RJavaClassLoader(\""+path+"\", \""+libpath+"\", "+ ((parent == null) ? "no parent" : parent) + ")"); if (primaryLoader==null) { primaryLoader = this; if (verbose) System.out.println(" - primary loader"); } else { if (verbose) System.out.println(" - NOT primrary (this="+this+", primary="+primaryLoader+")"); } libMap = new HashMap/**/(); classPath = new Vector/**/(); classPath.add(new UnixDirectory(path+"/java")); rJavaPath = path; rJavaLibPath = libpath; /* load the rJava library */ UnixFile so = new UnixFile(rJavaLibPath+"/rJava.so"); if (!so.exists()) so = new UnixFile(rJavaLibPath+"/rJava.dll"); if (so.exists()) libMap.put("rJava", so); /* load the jri library */ UnixFile jri = new UnixFile(path+"/jri/libjri.so"); String rarch = System.getProperty("r.arch"); if (rarch != null && rarch.length()>0) { UnixFile af = new UnixFile(path+"/jri"+rarch+"/libjri.so"); if (af.exists()) jri = af; else { af = new UnixFile(path+"/jri"+rarch+"/jri.dll"); if (af.exists()) jri = af; } } if (!jri.exists()) jri = new UnixFile(path+"/jri/libjri.jnilib"); if (!jri.exists()) jri = new UnixFile(path+"/jri/jri.dll"); if (jri.exists()) { libMap.put("jri", jri); if (verbose) System.out.println(" - registered JRI: "+jri); } /* if we are the primary loader, make us the context loader so projects that rely on the context loader pick us */ if (primaryLoader == this) Thread.currentThread().setContextClassLoader(this); if (verbose) { System.out.println("RJavaClassLoader initialized.\n\nRegistered libraries:"); for(Iterator entries = libMap.keySet().iterator(); entries.hasNext(); ) { Object key = entries.next(); System.out.println(" " + key + ": '" + libMap.get(key) + "'"); } System.out.println("\nRegistered class paths:"); for (Enumeration e = classPath.elements() ; e.hasMoreElements() ;) System.out.println(" '"+e.nextElement()+"'"); System.out.println("\n-- end of class loader report --"); } } // }}} // {{{ classNameToFile /** * convert . to / */ String classNameToFile(String cls) { return cls.replace('.','/'); } // }}} // {{{ findClass protected Class findClass(String name) throws ClassNotFoundException { Class cl = null; if (verbose) System.out.println(""+this+".findClass("+name+")"); if ("RJavaClassLoader".equals(name)) return getClass(); // {{{ use the usual method of URLClassLoader if (useSystem) { try { cl = super.findClass(name); if (cl != null) { if (verbose) System.out.println("RJavaClassLoader: found class "+name+" using URL loader"); return cl; } } catch (Exception fnf) { if (verbose) System.out.println(" - URL loader did not find it: " + fnf); } } if (verbose) System.out.println("RJavaClassLoader.findClass(\""+name+"\")"); // }}} // {{{ iterate through the elements of the class path InputStream ins = null; Exception defineException = null; Enumeration/**/ e = classPath.elements() ; while( e.hasMoreElements() ){ UnixFile cp = (UnixFile) e.nextElement(); if (verbose) System.out.println(" - trying class path \""+cp+"\""); try { ins = null; /* a file - assume it is a jar file */ if (cp instanceof UnixJarFile){ ins = ((UnixJarFile)cp).getResourceAsStream( classNameToFile(name) + ".class" ) ; if (verbose) System.out.println(" JAR file, can get '" + classNameToFile(name) + "'? " + ((ins == null) ? "NO" : "YES")); } else if ( cp instanceof UnixDirectory ){ UnixFile class_f = new UnixFile(cp.getPath()+"/"+classNameToFile(name)+".class"); if (class_f.isFile() ) { ins = new FileInputStream(class_f); } if (verbose) System.out.println(" Directory, can get '" + class_f + "'? " + ((ins == null) ? "NO" : "YES")); } /* some comments on the following : we could call ZipEntry.getSize in case of a jar file to find out the size of the byte[] directly also ByteBuffer seems more efficient, but the ByteBuffer class is java >= 1.4 and the defineClass method that uses the class is java >= 1.5 */ if (ins != null) { int al = 128*1024; byte fc[] = new byte[al]; int n = ins.read(fc); int rp = n; if( verbose ) System.out.println(" loading class file, initial n = "+n); while (n > 0) { if (rp == al) { int nexa = al*2; if (nexa<512*1024) nexa=512*1024; byte la[] = new byte[nexa]; System.arraycopy(fc, 0, la, 0, al); fc = la; al = nexa; } n = ins.read(fc, rp, fc.length-rp); if( verbose ) System.out.println(" next n = "+n+" (rp="+rp+", al="+al+")"); if (n>0) rp += n; } ins.close(); n = rp; if (verbose) System.out.println("RJavaClassLoader: loaded class "+name+", "+n+" bytes"); try { cl = defineClass(name, fc, 0, n); } catch (Exception dce) { // we want to save this one so we can pass it on defineException = dce; break; } if (verbose) System.out.println(" defineClass('" + name +"') returned " + cl); // System.out.println(" - class = "+cl); return cl; } } catch (Exception ex) { // System.out.println(" * won't work: "+ex.getMessage()); } } // }}} if (defineException != null) // we bailed out on class interpretation, re-throw it throw (new ClassNotFoundException("Class not found - candidate class binary found but could not be loaded", defineException)); // giving up if (cl == null) { if( verbose ) System.out.println(" >> ClassNotFoundException "); throw (new ClassNotFoundException()); } return cl; } // }}} // {{{ findResource public URL findResource(String name) { if (verbose) System.out.println("RJavaClassLoader: findResource('"+name+"')"); // {{{ use the standard way if (useSystem) { try { URL u = super.findResource(name); if (u != null) { if (verbose) System.out.println("RJavaClassLoader: found resource in "+u+" using URL loader."); return u; } } catch (Exception fre) { } } // }}} // {{{ iterate through the classpath if (verbose) System.out.println(" - resource not found with URL loader, trying alternative"); Enumeration/**/ e = classPath.elements() ; while( e.hasMoreElements()) { UnixFile cp = (UnixFile) e.nextElement(); try { /* is a file - assume it is a jar file */ if (cp instanceof UnixJarFile ) { URL u = ( (UnixJarFile)cp ).getResource( name ) ; if (u != null) { if (verbose) System.out.println(" - found in a JAR file, URL "+u); return u; } } else if(cp instanceof UnixDirectory ) { UnixFile res_f = new UnixFile(cp.getPath()+"/"+name); if (res_f.isFile()) { if (verbose) System.out.println(" - find as a file: "+res_f); return res_f.toURL(); } } } catch (Exception iox) { } } // }}} return null; } // }}} // {{{ addRLibrary /** add a library to path mapping for a native library */ public void addRLibrary(String name, String path) { libMap.put(name, new UnixFile(path)); } // }}} // {{{ addClassPath /** * adds an entry to the class path */ public void addClassPath(String cp) { UnixFile f = new UnixFile(cp); // use the URLClassLoader if (useSystem) { try { addURL(f.toURL()); if (verbose) System.out.println("RJavaClassLoader: added '" + cp + "' to the URL class path loader"); //return; // we need to add it anyway so it appears in .jclassPath() } catch (Exception ufe) { } } UnixFile g = null ; if( f.isFile() && (f.getName().endsWith(".jar") || f.getName().endsWith(".JAR"))) { g = new UnixJarFile(cp) ; if (verbose) System.out.println("RJavaClassLoader: adding Java archive file '"+cp+"' to the internal class path"); } else if( f.isDirectory() ){ g = new UnixDirectory(cp) ; if (verbose) System.out.println("RJavaClassLoader: adding class directory '"+cp+"' to the internal class path"); } else if (verbose) System.err.println(f.exists() ? ("WARNING: the path '"+cp+"' is neither a directory nor a .jar file, it will NOT be added to the internal class path!") : ("WARNING: the path '"+cp+"' does NOT exist, it will NOT be added to the internal class path!")); if (g != null && !classPath.contains(g)) { // this is the real meat - add it to our internal list classPath.add(g); // this is just cosmetics - it doesn't really have any meaning System.setProperty("java.class.path", System.getProperty("java.class.path")+File.pathSeparator+g.getPath()); } } /** * adds several entries to the class path */ public void addClassPath(String[] cp) { int i = 0; while (i < cp.length) addClassPath(cp[i++]); } // }}} // {{{ getClassPath /** * @return the array of class paths used by this class loader */ public String[] getClassPath() { int j = classPath.size(); String[] s = new String[j]; int i = 0; while (i < j) { s[i] = ((UnixFile) classPath.elementAt(i)).getPath(); i++; } return s; } // }}} // {{{ findLibrary protected String findLibrary(String name) { if (verbose) System.out.println("RJavaClassLoader.findLibrary(\""+name+"\")"); //if (name.equals("rJava")) // return rJavaLibPath+"/"+name+".so"; UnixFile u = (UnixFile) libMap.get(name); String s = null; if (u!=null && u.exists()) s=u.getPath(); if (verbose) System.out.println(" - mapping to "+((s==null)?"":s)); return s; } // }}} // {{{ bootClass /** * Boots the specified method of the specified class * * @param cName class to boot * @param mName method to boot (typically main). The method must take a String[] as parameter * @param args arguments to pass to the method */ public void bootClass(String cName, String mName, String[] args) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, java.lang.ClassNotFoundException { Class c = findClass(cName); resolveClass(c); java.lang.reflect.Method m = c.getMethod(mName, new Class[] { String[].class }); m.invoke(null, new Object[] { args }); } // }}} // {{{ setDebug /** * Set the debug level. At the moment, there is only verbose (level > 0) * or quiet * * @param level debug level. verbose (>0), quiet otherwise */ public static void setDebug(int level) { verbose=(level>0); } // }}} // {{{ u2w /** * Utility to convert paths for windows. Converts / to the path separator in use * * @param fn file name */ public static String u2w(String fn) { return (File.separatorChar != '/') ? fn.replace('/', File.separatorChar) : fn ; } // }}} // {{{ main /** * main method * *

This uses the system properties:

*
    *
  • rjava.path : path of the rJava package
  • *
  • rjava.lib : lib sub directory of the rJava package
  • *
  • main.class : main class to "boot", assumes Main if not specified
  • *
  • rjava.class.path : set of paths to populate the initiate the class path
  • *
* *

and boots the "main" method of the specified main.class, * passing the args down to the booted class

* *

This makes sure R and rJava are known by the class loader

*/ public static void main(String[] args) { String rJavaPath = System.getProperty("rjava.path"); if (rJavaPath == null) { System.err.println("ERROR: rjava.path is not set"); System.exit(2); } String rJavaLib = System.getProperty("rjava.lib"); if (rJavaLib == null) { // it is not really used so far, just for rJava.so, so we can guess rJavaLib = rJavaPath + File.separator + "libs"; } RJavaClassLoader cl = new RJavaClassLoader(u2w(rJavaPath), u2w(rJavaLib)); String mainClass = System.getProperty("main.class"); if (mainClass == null || mainClass.length()<1) { System.err.println("WARNING: main.class not specified, assuming 'Main'"); mainClass = "Main"; } String classPath = System.getProperty("rjava.class.path"); if (classPath != null) { StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator); while (st.hasMoreTokens()) { String dirname = u2w(st.nextToken()); cl.addClassPath(dirname); } } try { cl.bootClass(mainClass, "main", args); } catch (Exception ex) { System.err.println("ERROR: while running main method: "+ex); ex.printStackTrace(); } } // }}} //----- tools ----- // {{{ RJavaObjectInputStream class class RJavaObjectInputStream extends ObjectInputStream { public RJavaObjectInputStream(InputStream in) throws IOException { super(in); } protected Class resolveClass(ObjectStreamClass desc) throws ClassNotFoundException { return Class.forName(desc.getName(), false, RJavaClassLoader.getPrimaryLoader()); } } // }}} // {{{ toByte /** * Serialize an object to a byte array. (code by CB) * * @param object object to serialize * @return byte array that represents the object * @throws Exception */ public static byte[] toByte(Object object) throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream((OutputStream) os); oos.writeObject(object); oos.close(); return os.toByteArray(); } // }}} // {{{ toObject /** * Deserialize an object from a byte array. (code by CB) * * @param byteArray * @return the object that is represented by the byte array * @throws Exception */ public Object toObject(byte[] byteArray) throws Exception { InputStream is = new ByteArrayInputStream(byteArray); RJavaObjectInputStream ois = new RJavaObjectInputStream(is); Object o = (Object) ois.readObject(); ois.close(); return o; } // }}} // {{{ toObjectPL /** * converts the byte array into an Object using the primary RJavaClassLoader */ public static Object toObjectPL(byte[] byteArray) throws Exception{ return RJavaClassLoader.getPrimaryLoader().toObject(byteArray); } // }}} } rJava/src/java/NotComparableException.class0000644000175100001440000000166115133274036020507 0ustar hornikusersÊþº¾23     !" # $ $%&'('(Ljava/lang/Object;Ljava/lang/Object;)VCodeLineNumberTable(Ljava/lang/Object;)V(Ljava/lang/Class;)V(Ljava/lang/String;)V SourceFileNotComparableException.javajava/lang/StringBuilder )objects of class *+, -./ 01 and  are not comparable 21 class ( does not implement java.util.ComparableNotComparableExceptionjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;java/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetName()Ljava/lang/String;toString!V2*»Y·¶+¶¶¶¶,¶¶¶¶¶ · ±  . 1 ( *+¶¶· ±  % *+¶· ± 9*»Y· ¶+¶ ¶¶ · ± rJava/src/java/ArrayDimensionException.class0000644000175100001440000000036615133274036020706 0ustar hornikusersÊþº¾2    (Ljava/lang/String;)VCodeLineNumberTable SourceFileArrayDimensionException.java ArrayDimensionExceptionjava/lang/Exception!"*+·±  rJava/src/java/RJavaArrayIterator.java0000644000175100001440000000323215133274032017422 0ustar hornikusersimport java.lang.reflect.Array ; public abstract class RJavaArrayIterator { protected int[] dimensions; protected int nd ; protected int[] index ; protected int[] dimprod ; protected Object array ; protected int increment; protected int position ; protected int start ; public Object getArray(){ return array ; } /** * @return the class name of the array */ public String getArrayClassName(){ return array.getClass().getName(); } public int[] getDimensions(){ return dimensions; } public RJavaArrayIterator(){ dimensions = null; index = null ; dimprod = null ; array = null ; } public RJavaArrayIterator(int[] dimensions){ this.dimensions = dimensions ; nd = dimensions.length ; if( nd > 1){ index = new int[ nd-1 ] ; dimprod = new int[ nd-1 ] ; for( int i=0; i<(nd-1); i++){ index[i] = 0 ; dimprod[i] = (i==0) ? dimensions[i] : ( dimensions[i]*dimprod[i-1] ); increment = dimprod[i] ; } } position = 0 ; start = 0; } public RJavaArrayIterator(int d1){ this( new int[]{ d1} ) ; } protected Object next( ){ /* get the next array and the position of the first elemtn in the flat array */ Object o = array ; for( int i=0; i=0; i--){ if( (index[i] + 1) == dimensions[i] ){ index[i] = 0 ; } else{ index[i] = index[i] + 1 ; break; } } position++ ; return o; } protected boolean hasNext( ){ return position < increment ; } } rJava/src/java/RectangularArrayBuilder_Test.java0000644000175100001440000005766115133274032021501 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Test suite for RectangularArrayBuilder */ public class RectangularArrayBuilder_Test { private static int[] dim1d = {10} ; private static int[] dim2d = {5,2} ; private static int[] dim3d = {5,3,2} ; // {{{ main public static void main(String[] args ){ try{ runtests() ; } catch( TestException e){ e.printStackTrace(); System.exit(1); } System.out.println( "\nALL PASSED\n" ) ; System.exit( 0 ); } // }}} // {{{ runtests public static void runtests() throws TestException { // {{{ 1d System.out.println( " >> 1 d" ); System.out.print( "fill int[]" ); fill_int_1(); System.out.println( " : ok" ); System.out.print( "fill boolean[]" ); fill_boolean_1(); System.out.println( " : ok" ); System.out.print( "fill byte[]" ); fill_byte_1(); System.out.println( " : ok" ); System.out.print( "fill long[]" ); fill_long_1(); System.out.println( " : ok" ); System.out.print( "fill short[]" ); fill_short_1(); System.out.println( " : ok" ); System.out.print( "fill double[]" ); fill_double_1(); System.out.println( " : ok" ); System.out.print( "fill char[]" ); fill_char_1(); System.out.println( " : ok" ); System.out.print( "fill float[]" ); fill_float_1(); System.out.println( " : ok" ); System.out.print( "fill String[]" ); fill_String_1(); System.out.println( " : ok" ); System.out.print( "fill Point[]" ); fill_Point_1(); System.out.println( " : ok" ); // }}} // {{{ 2d System.out.println( " >> 2 d" ); System.out.print( "fill int[][]" ); fill_int_2(); System.out.println( " : ok" ); System.out.print( "fill boolean[][]" ); fill_boolean_2(); System.out.println( " : ok" ); System.out.print( "fill byte[][]" ); fill_byte_2(); System.out.println( " : ok" ); System.out.print( "fill long[][]" ); fill_long_2(); System.out.println( " : ok" ); System.out.print( "fill short[][]" ); fill_short_2(); System.out.println( " : ok" ); System.out.print( "fill double[][]" ); fill_double_2(); System.out.println( " : ok" ); System.out.print( "fill char[][]" ); fill_char_2(); System.out.println( " : ok" ); System.out.print( "fill float[][]" ); fill_float_2(); System.out.println( " : ok" ); System.out.print( "fill String[][]" ); fill_String_2(); System.out.println( " : ok" ); System.out.print( "fill Point[][]" ); fill_Point_2(); System.out.println( " : ok" ); // }}} // {{{ 3d System.out.println( " >> 3 d" ); System.out.print( "fill int[][][]" ); fill_int_3(); System.out.println( " : ok" ); System.out.print( "fill boolean[][][]" ); fill_boolean_3(); System.out.println( " : ok" ); System.out.print( "fill byte[][][]" ); fill_byte_3(); System.out.println( " : ok" ); System.out.print( "fill long[][][]" ); fill_long_3(); System.out.println( " : ok" ); System.out.print( "fill short[][][]" ); fill_short_3(); System.out.println( " : ok" ); System.out.print( "fill double[][][]" ); fill_double_3(); System.out.println( " : ok" ); System.out.print( "fill char[][][]" ); fill_char_3(); System.out.println( " : ok" ); System.out.print( "fill float[][][]" ); fill_float_3(); System.out.println( " : ok" ); System.out.print( "fill String[][][]" ); fill_String_3(); System.out.println( " : ok" ); System.out.print( "fill Point[][][]" ); fill_Point_3(); System.out.println( " : ok" ); // }}} } //}}} // {{{ 1d private static void fill_int_1() throws TestException{ RectangularArrayBuilder builder = null; try{ builder = new RectangularArrayBuilder( ints(10), dim1d ); } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } catch( ArrayDimensionException e){ throw new TestException( "array dimensionexception" ) ; } int[] data = (int[])builder.getArray(); int current = 0; for( int i=0; i'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTable hasChanged()Z StackMapTableupdate()V SourceFileRJavaClassLoader.java ! "# $  %&RJavaClassLoader$UnixFileUnixFile InnerClasses java/io/FileRJavaClassLoaderu2w&(Ljava/lang/String;)Ljava/lang/String;(Ljava/lang/String;)V lastModified()J    7*+µ*,¸·* µ±LM NO>*¶@*´”™§¬ UVü@% **¶µ± ]^ rJava/src/java/RectangularArrayBuilder_Test.class0000644000175100001440000003645315133274037021666 0ustar hornikusersÊþº¾2¤ ¤ç £èé ê ëì ëíî ïðñò ïó £ôõö £÷ø £ùú £ûü £ýþ £ÿ £ £ £ £ £  £  £ £ £ £ £ £ £ £ £ £!" £#$ £%& £'( £)* £+, £-. £/0 £12 £3 £4 J567 89: J;¦< Uç= U> U?@ UA £BCD UE £FGH £IJK £LMN £OPQ £RST £UVW £XYZ[  \ £]^_ ¡` ¡ab £cdefghijklmno £pqrstuvwxyz{|}~€‚ƒ„…†‡ ¡ˆ‰Šdim1d[Idim2ddim3d()VCodeLineNumberTablemain([Ljava/lang/String;)V StackMapTableruntests Exceptions fill_int_1fill_boolean_1 fill_byte_1 fill_long_1 fill_short_1 fill_double_1 fill_char_1 fill_float_1 fill_String_1 fill_Point_1 fill_int_2fill_boolean_2 fill_byte_2 fill_long_2 fill_short_2 fill_double_2 fill_char_2 fill_float_2 fill_String_2 fill_Point_2 fill_int_3fill_boolean_3 fill_byte_3 fill_long_3 fill_short_3 fill_double_3 fill_char_3 fill_float_3 fill_String_3 fill_Point_3ints(I)[Ibooleans(I)[Zbytes(I)[Blongs(I)[Jshorts(I)[Sdoubles(I)[Dchars(I)[Cfloats(I)[Fstrings(I)[Ljava/lang/String;points(I)[LDummyPoint; SourceFile!RectangularArrayBuilder_Test.java ©ª °ª TestException ‹ªŒ Ž  ALL PASSED ‘ ’“ >> 1 d fill int[] ”“ ²ª : okfill boolean[] ³ª fill byte[] ´ª fill long[] µª fill short[] ¶ª fill double[] ·ª fill char[] ¸ª fill float[] ¹ª fill String[] ºª fill Point[] »ª >> 2 d fill int[][] ¼ªfill boolean[][] ½ª fill byte[][] ¾ª fill long[][] ¿ªfill short[][] Àªfill double[][] Áª fill char[][] ªfill float[][] êfill String[][] Īfill Point[][] Ū >> 3 dfill int[][][] ƪfill boolean[][][] Ǫfill byte[][][] Ȫfill long[][][] ɪfill short[][][] ʪfill double[][][] ˪fill char[][][] ̪fill float[][][] ͪfill String[][][] Ϊfill Point[][][] ϪRectangularArrayBuilder ÐÑ ¥¦ ©•NotAnArrayExceptionnot an array int[10] ©“ArrayDimensionExceptionarray dimensionexception –—java/lang/StringBuilderdata[ ˜™ ˜š] != ›œ ÒÓnot an array boolean[10][Z ˜ ÔÕnot an array byte[10][B Ö×not an array long[10][J ØÙnot an array short[10][S ÚÛnot an array double[10][D ÜÝnot an array char[10][C Þßnot an array float[10][F àánot an array String[10][Ljava/lang/String; žŸ âãnot an array DummyPoint[10] [LDummyPoint;  ¡ ¢¡].x != §¦[[I][[[Z[[B[[J[[S[[D[[C[[F[[Ljava/lang/String;not an array Point[10][[LDummyPoint; ¨¦not an array int[30][[[I] != not an array boolean[30][[[Znot an array byte[30][[[Bnot an array long[30][[[Jnot an array short[30][[[Snot an array double[30][[[Dnot an array char[30][[[Cnot an array float[30][[[Fnot an array String[30][[[Ljava/lang/String;not an array Point[30][[[LDummyPoint;java/lang/String DummyPoint ©£RectangularArrayBuilder_Testjava/lang/ObjectprintStackTracejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vprint(Ljava/lang/Object;[I)VgetArray()Ljava/lang/Object;append-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;(Z)Ljava/lang/StringBuilder;equals(Ljava/lang/Object;)ZxIy(II)V!£¤ ¥¦ §¦ ¨¦,©ª«*·±¬ ­®«e¸§ L+¶¸²¶¸±¬" ¯F °ª«ïS² ¶² ¶ ¸ ² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶² ¶²!¶ ¸"² ¶²#¶ ¸$² ¶²%¶ ¸&² ¶²'¶ ¸(² ¶²)¶ ¸*² ¶²+¶ ¸,² ¶²-¶ ¸.² ¶²/¶ ¸0² ¶²1¶ ¸2² ¶²3¶ ¸4² ¶²5¶²6¶ ¸7² ¶²8¶ ¸9² ¶²:¶ ¸;² ¶²<¶ ¸=² ¶²>¶ ¸?² ¶²@¶ ¸A² ¶²B¶ ¸C² ¶²D¶ ¸E² ¶²F¶ ¸G² ¶²H¶ ¸I² ¶±¬Š". A!T"g#z$% &³'Æ+Î,á-ô./0-1@2S3f4y5Œ9”:§;º<Í=à>ó?@A,B?CRF± ²ª«÷uK»JY ¸K²L·MK§L»YO·P¿L»YR·P¿*¶SÀTL=>²L.¢7+.Ÿ'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿƱN Q¬:KMRNO P!Q+T3U5V@WGXkVt\¯ ÿJNJQ þ T3ú± ³ª«|K»JY ¸\²L·MK§L»Y]·P¿L»YR·P¿*¶SÀ^L=>²L.¢>+3Ÿ'»Y»UY·VW¶X¶YZ¶X¶_¶[·P¿„š§=§ÿ¿±N Q¬:_afbc d!e+h3i5k@lGmkk{q¯#ÿJNJQ þ ^3 @ú± ´ª«÷uK»JY ¸`²L·MK§L»Ya·P¿L»YR·P¿*¶SÀbL=>²L.¢7+3Ÿ'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿƱN Q¬:tv{wx y!z+}3~5@€Gkt…¯ ÿJNJQ þ b3ú± µª«ùwK»JY ¸c²L·MK§L»Yd·P¿L»YR·P¿*¶SÀeL=>²L.¢9+/…”™'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿıN Q¬:ˆŠ‹Œ !Ž+‘3’5“@”I•m“v™¯ ÿJNJQ þ e5ú± ¶ª«÷uK»JY ¸f²L·MK§L»Yg·P¿L»YR·P¿*¶SÀhL=>²L.¢7+5Ÿ'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿƱN Q¬:œž£Ÿ  ¡!¢+¥3¦5§@¨G©k§t­¯ ÿJNJQ þ h3ú± ·ª«ùwK»JY ¸i²L·MK§L»Yj·P¿L»YR·P¿*¶SÀkL=>²L.¢9+1‡—™'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿıN Q¬:°²·³´ µ!¶+¹3º5»@¼I½m»vÁ¯ ÿJNJQ þ k5ú± ¸ª«÷uK»JY ¸l²L·MK§L»Ym·P¿L»YR·P¿*¶SÀnL=>²L.¢7+4Ÿ'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿƱN Q¬:ÄÆËÇÈ É!Ê+Í3Î5Ï@ÐGÑkÏtÕ¯ ÿJNJQ þ n3ú± ¹ª«ùwK»JY ¸o²L·MK§L»Yp·P¿L»YR·P¿*¶SÀqL=>²L.¢9+0†•™'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿıN Q¬:ØÚßÛÜ Ý!Þ+á3â5ã@äIåmãvé¯ ÿJNJQ þ q5ú± ºª«ŠK»JY ¸r²L·MK§L»Ys·P¿L»YR·P¿*¶SÀtL=>²L.¢L+2»UY·V¶Yu¶X¶[¶vš'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿ±±N Q¬:ìîóïð ñ!ò+õ3ö5÷@ø\ù€÷‰ý¯"ÿJNJQ þ tûHú± »ª«…K»JY ¸w²L·MK§L»Yx·P¿L»YR·P¿*¶SÀyL=>²L.¢G+2:´z  ´{Ÿ'»Y»UY·VW¶X¶Y|¶X¶Y¶[·P¿„„§ÿ¶±N Q¬> !+ 3 5 @ E W{ „¯(ÿJNJQ þ yü¡ú#ú± ¼ª«(•K»JY ¸K²}·MK§L»YO·P¿L»YR·P¿*¶SÀ~L=>²}.¢W6²}.¢D+2.Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¸„§ÿ¦±N Q¬B !+!3"5#@$M%W&…$Ž#”+¯)ÿJNJQ þ ~ü ûAúú± ½ª«2œK»JY ¸\²}·MK§L»Y]·P¿L»YR·P¿*¶SÀ€L=>²}.¢^6²}.¢K+23Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶_¶[·P¿„š§=§ÿ±„§ÿŸ±N Q¬B.0512 3!4+73859@:M;W<…:•9›A¯, ÿJNJQ þ €ü ûA @úú± ¾ª«(•K»JY ¸`²}·MK§L»Ya·P¿L»YR·P¿*¶SÀL=>²}.¢W6²}.¢D+23Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¸„§ÿ¦±N Q¬BDFKGH I!J+M3N5O@PMQWR…PŽO”W¯)ÿJNJQ þ ü ûAúú± ¿ª«*—K»JY ¸c²}·MK§L»Yd·P¿L»YR·P¿*¶SÀ‚L=>²}.¢Y6²}.¢F+2/…”™1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¶„§ÿ¤±N Q¬BZ\a]^ _!`+c3d5e@fMgYh‡fe–m¯)ÿJNJQ þ ‚ü ûCúú± Àª«(•K»JY ¸f²}·MK§L»Yg·P¿L»YR·P¿*¶SÀƒL=>²}.¢W6²}.¢D+25Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¸„§ÿ¦±N Q¬Bprwst u!v+y3z5{@|M}W~…|Ž{”ƒ¯)ÿJNJQ þ ƒü ûAúú± Áª«*—K»JY ¸i²}·MK§L»Yj·P¿L»YR·P¿*¶SÀ„L=>²}.¢Y6²}.¢F+21‡—™1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¶„§ÿ¤±N Q¬B†ˆ‰Š ‹!Œ+35‘@’M“Y”‡’‘–™¯)ÿJNJQ þ „ü ûCúú± ª«(•K»JY ¸l²}·MK§L»Ym·P¿L»YR·P¿*¶SÀ…L=>²}.¢W6²}.¢D+24Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¸„§ÿ¦±N Q¬Bœž£Ÿ  ¡!¢+¥3¦5§@¨M©Wª…¨Ž§”¯¯)ÿJNJQ þ …ü ûAúú± ê«*—K»JY ¸o²}·MK§L»Yp·P¿L»YR·P¿*¶SÀ†L=>²}.¢Y6²}.¢F+20†•™1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¶„§ÿ¤±N Q¬B²´¹µ¶ ·!¸+»3¼5½@¾M¿YÀ‡¾½–ů)ÿJNJQ þ †ü ûCúú± Ī«=ªK»JY ¸r²}·MK§L»Ys·P¿L»YR·P¿*¶SÀ‡L=>²}.¢l6²}.¢Y+22»UY·V¶Yu¶X¶[¶vš1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ£„§ÿ‘±N Q¬BÈÊÏËÌ Í!Î+Ñ3Ò5Ó@ÔMÕlÖšÔ£Ó©Û¯)ÿJNJQ þ ‡ü ûVúú± Ū«B¥K»JY ¸w²}·MK§L»Yˆ·P¿L»YR·P¿*¶SÀ‰L=>²}.¢g6²}.¢T+22:´z  ´{Ÿ1»Y»UY·VW¶X¶Y¶X¶Y|¶X¶Y¶[·P¿„„§ÿ¨„§ÿ–±N Q¬FÞàåáâ ã!ä+ç3è5é@êMëUìgí•êžé¤ò¯/ ÿJNJQ þ ‰ü ü#¡ú-úú± ƪ«WµK»JY¸K²Š·MK§L»Y‹·P¿L»YR·P¿*¶SÀŒL=>²Š.¢w6²Š.¢d6²Š.¢Q+22.Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ«„§ÿ˜„§ÿ†±N Q¬Jøúÿûü ý!þ+35@MZgŸ¨®´ ¯0 ÿJNJQ þ Œü ü ûNúúú± Ǫ«a¼K»JY¸\²Š·MK§L»YŽ·P¿L»YR·P¿*¶SÀL=>²Š.¢~6²Š.¢k6²Š.¢X+223Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶_¶[·P¿„š§=§ÿ¤„§ÿ‘„§ÿ±N Q¬J !+35@MZgŸ¯µ»$¯3 ÿJNJQ þ ü ü ûN @úúú± Ȫ«WµK»JY¸`²Š·MK§L»Y·P¿L»YR·P¿*¶SÀ‘L=>²Š.¢w6²Š.¢d6²Š.¢Q+223Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ«„§ÿ˜„§ÿ†±N Q¬J').*+ ,!-+03152@3M4Z5g6Ÿ4¨3®2´;¯0 ÿJNJQ þ ‘ü ü ûNúúú± ɪ«Y·K»JY¸c²Š·MK§L»Y’·P¿L»YR·P¿*¶SÀ“L=>²Š.¢y6²Š.¢f6²Š.¢S+22/…”™;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ©„§ÿ–„§ÿ„±N Q¬J>@EAB C!D+G3H5I@JMKZLiM¡KªJ°I¶R¯0 ÿJNJQ þ “ü ü ûPúúú± ʪ«WµK»JY¸f²Š·MK§L»Y”·P¿L»YR·P¿*¶SÀ•L=>²Š.¢w6²Š.¢d6²Š.¢Q+225Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ«„§ÿ˜„§ÿ†±N Q¬JUW\XY Z![+^3_5`@aMbZcgdŸb¨a®`´i¯0 ÿJNJQ þ •ü ü ûNúúú± ˪«Y·K»JY¸i²Š·MK§L»Y–·P¿L»YR·P¿*¶SÀ—L=>²Š.¢y6²Š.¢f6²Š.¢S+221‡—™;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ©„§ÿ–„§ÿ„±N Q¬Jlnsop q!r+u3v5w@xMyZzi{¡yªx°w¶€¯0 ÿJNJQ þ —ü ü ûPúúú± ̪«WµK»JY¸l²Š·MK§L»Y˜·P¿L»YR·P¿*¶SÀ™L=>²Š.¢w6²Š.¢d6²Š.¢Q+224Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ«„§ÿ˜„§ÿ†±N Q¬Jƒ…І‡ ˆ!‰+Œ35Ž@MZ‘g’Ÿ¨®Ž´—¯0 ÿJNJQ þ ™ü ü ûNúúú± ͪ«Y·K»JY¸o²Š·MK§L»Yš·P¿L»YR·P¿*¶SÀ›L=>²Š.¢y6²Š.¢f6²Š.¢S+220†•™;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ©„§ÿ–„§ÿ„±N Q¬Jšœ¡ž Ÿ! +£3¤5¥@¦M§Z¨i©¡§ª¦°¥¶®¯0 ÿJNJQ þ ›ü ü ûPúúú± Ϊ«lÊK»JY¸r²Š·MK§L»Yœ·P¿L»YR·P¿*¶SÀL=>²Š.¢Œ6²Š.¢y6²Š.¢f+222»UY·V¶Yu¶X¶[¶vš;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ–„§ÿƒ„§ÿq±N Q¬J±³¸´µ ¶!·+º3»5¼@½M¾Z¿|À´¾½½Ã¼Éů0 ÿJNJQ þ ü ü ûcúúú± Ϫ«qÅK»JY¸w²Š·MK§L»Yž·P¿L»YR·P¿*¶SÀŸL=>²Š.¢‡6²Š.¢t6²Š.¢a+222:´z  ´{Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y|¶X¶Y¶[·P¿„„§ÿ›„§ÿˆ„§ÿv±N Q¬NÈÊÏËÌ Í!Î+Ñ3Ò5Ó@ÔMÕZÖe×wدÕ¸Ô¾ÓÄݯ6 ÿJNJQ þ Ÿü ü ü&¡ú7úúú± ÐÑ«Q¼ L=¢ +O„§ÿô+°¬âã äãæ¯ ýTú ÒÓ«e#¼L=>¢+T„š§=§ÿê+°¬êëì íì!ï¯þ^@ú ÔÕ«R¼L=¢+‘T„§ÿó+°¬óô õô÷¯ ýbú Ö׫R¼ L=¢+…P„§ÿó+°¬ûü ýüÿ¯ ýeú ØÙ«R¼ L=¢+“V„§ÿó+°¬ ¯ ýhú ÚÛ«T¼L=¢+‡cR„§ÿñ+°¬    ¯ ýkú ÜÝ«R¼L=¢+’U„§ÿó+°¬ ¯ ýnú Þß«T¼L=¢+ †bQ„§ÿñ+°¬ ¯ ýqú àá«d*½ L=¢+»UY·Vu¶X¶Y¶[S„§ÿâ+°¬#$ %"$('¯ ýtú âã«Z ½¡L=¢+»¡Y·¢S„§ÿì+°¬+, -,/¯ ýyú䪫L,¼ Y O³L¼ YOYO³}¼ YOYOYO³Š±¬  åærJava/src/java/RJavaTools.java0000644000175100001440000005250415133274032015740 0ustar hornikusers// RJavaTools.java: rJava - low level R to java interface // // Copyright (C) 2009 - 2010 Simon Urbanek and Romain Francois // // This file is part of rJava. // // rJava is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // rJava is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with rJava. If not, see . import java.lang.reflect.Method ; import java.lang.reflect.Field ; import java.lang.reflect.Constructor ; import java.lang.reflect.InvocationTargetException ; import java.lang.reflect.Modifier ; import java.lang.reflect.Member ; import java.util.Vector ; /** * Tools used internally by rJava. * * The method lookup code is heavily based on ReflectionTools * by Romain Francois <francoisromain@free.fr> licensed under GPL v2 or higher. */ public class RJavaTools { /** * Returns an inner class of the class with the given simple name * * @param cl class * @param name simple name of the inner class * @param staticRequired boolean, if true the inner class is required to be static */ public static Class getClass(Class cl, String name, boolean staticRequired){ Class[] clazzes = cl.getClasses(); for( int i=0; iFor fields, it just returns the name of the fields * *

For methods, this returns the name of the method * plus a suffix that depends on the number of arguments of the method. * *

The string "()" is added * if the method has no arguments, and the string "(" is added * if the method has one or more arguments. */ public static String getCompletionName(Member m){ if( m instanceof Field ) return m.getName(); if( m instanceof Method ){ String suffix = ( ((Method)m).getParameterTypes().length == 0 ) ? ")" : "" ; return m.getName() + "(" + suffix ; } return "" ; } /** * Indicates if a member of a Class (field, method ) is static * * @param member class member * @return true if the member is static */ public static boolean isStatic( Member member ){ return (member.getModifiers() & Modifier.STATIC) != 0 ; } /** * Checks if the class of the object has the given field. The * getFields method of Class is used so only public fields are * checked * * @param o object * @param name name of the field * * @return true if the class of o has the field name */ public static boolean hasField(Object o, String name) { return classHasField(o.getClass(), name, false); } /** * Checks if the class of the object has the given inner class. The * getClasses method of Class is used so only public classes are * checked * * @param o object * @param name (simple) name of the inner class * * @return true if the class of o has the class name */ public static boolean hasClass(Object o, String name) { return classHasClass(o.getClass(), name, false); } /** * Checks if the specified class has the given field. The * getFields method of Class is used so only public fields are * checked * * @param cl class object * @param name name of the field * @param staticRequired if true then the field is required to be static * * @return true if the class cl has the field name */ public static boolean classHasField(Class cl, String name, boolean staticRequired) { Field[] fields = cl.getFields(); for (int i = 0; i < fields.length; i++) if(name.equals(fields[i].getName()) && (!staticRequired || ((fields[i].getModifiers() & Modifier.STATIC) != 0))) return true; return false; } /** * Checks if the specified class has the given method. The * getMethods method of Class is used so only public methods are * checked * * @param cl class * @param name name of the method * @param staticRequired if true then the method is required to be static * * @return true if the class cl has the method name */ public static boolean classHasMethod(Class cl, String name, boolean staticRequired) { Method[] methodz = cl.getMethods(); for (int i = 0; i < methodz.length; i++) if (name.equals(methodz[i].getName()) && (!staticRequired || ((methodz[i].getModifiers() & Modifier.STATIC) != 0))) return true; return false; } /** * Checks if the specified class has the given inner class. The * getClasses method of Class is used so only public classes are * checked * * @param cl class * @param name name of the inner class * @param staticRequired if true then the method is required to be static * * @return true if the class cl has the field name */ public static boolean classHasClass(Class cl, String name, boolean staticRequired) { Class[] clazzes = cl.getClasses(); for (int i = 0; i < clazzes.length; i++) if (name.equals( getSimpleName(clazzes[i].getName()) ) && (!staticRequired || isStatic( clazzes[i] ) ) ) return true; return false; } /** * Checks if the class of the object has the given method. The * getMethods method of Class is used so only public methods are * checked * * @param o object * @param name name of the method * * @return true if the class of o has the field name */ public static boolean hasMethod(Object o, String name) { return classHasMethod(o.getClass(), name, false); } /** * Object creator. Find the best constructor based on the parameter classes * and invoke newInstance on the resolved constructor */ public static Object newInstance( Class o_clazz, Object[] args, Class[] clazzes ) throws Throwable { boolean[] is_null = new boolean[args.length]; for( int i=0; iFirst the appropriate method is resolved by getMethod and * then invokes the method */ public static Object invokeMethod( Class o_clazz, Object o, String name, Object[] args, Class[] clazzes) throws Throwable { Method m = getMethod( o_clazz, name, clazzes, arg_is_null(args) ); /* enforcing accessibility (workaround for bug 128) */ boolean access = m.isAccessible(); if (!access) { try { /* since JDK-17 this may fail */ m.setAccessible( true ); } catch (Throwable e) { access = true; /* nothing we can do, fail later with proper error ... */ } } Object out; try{ out = m.invoke( o, args ) ; } catch( InvocationTargetException e){ /* the target exception is much more useful than the reflection wrapper */ throw e.getTargetException() ; } finally{ if (!access) m.setAccessible( access ); } return out ; } /** * Attempts to find the best-matching constructor of the class * o_clazz with the parameter types arg_clazz * * @param o_clazz Class to look for a constructor * @param arg_clazz parameter types * @param arg_is_null indicates if each argument is null * * @return null if no constructor is found, or the constructor * */ public static Constructor getConstructor( Class o_clazz, Class[] arg_clazz, boolean[] arg_is_null) throws SecurityException, NoSuchMethodException { if (o_clazz == null) return null; Constructor cons = null ; /* if there is no argument, try to find a direct match */ if (arg_clazz == null || arg_clazz.length == 0) { cons = o_clazz.getConstructor( (Class[] )null ); return cons ; } /* try to find an exact match */ try { cons = o_clazz.getConstructor(arg_clazz); if (cons != null) return cons ; } catch (NoSuchMethodException e) { /* we catch this one because we want to further search */ } /* ok, no exact match was found - we have to walk through all methods */ cons = null; Constructor[] candidates = o_clazz.getConstructors(); for (int k = 0; k < candidates.length; k++) { Constructor c = candidates[k]; Class[] param_clazz = c.getParameterTypes(); if (arg_clazz.length != param_clazz.length) // number of parameters must match continue; int n = arg_clazz.length; boolean ok = true; for (int i = 0; i < n; i++) { if( arg_is_null[i] ){ /* then the class must not be a primitive type */ if( isPrimitive(arg_clazz[i]) ){ ok = false ; break ; } } else{ if (arg_clazz[i] != null && !param_clazz[i].isAssignableFrom(arg_clazz[i])) { ok = false; break; } } } // it must be the only match so far or more specific than the current match if (ok && (cons == null || isMoreSpecific(c, cons))) cons = c; } if( cons == null ){ throw new NoSuchMethodException( "No constructor matching the given parameters" ) ; } return cons; } static boolean isPrimitive(Class cl){ return cl.equals(Boolean.TYPE) || cl.equals(Integer.TYPE) || cl.equals(Double.TYPE) || cl.equals(Float.TYPE) || cl.equals(Long.TYPE) || cl.equals(Short.TYPE) || cl.equals(Character.TYPE) ; } /** * Attempts to find the best-matching method of the class o_clazz with the method name name and arguments types defined by arg_clazz. * The lookup is performed by finding the most specific methods that matches the supplied arguments (see also {@link #isMoreSpecific}). * * @param o_clazz class in which to look for the method * @param name method name * @param arg_clazz an array of classes defining the types of arguments * @param arg_is_null indicates if each argument is null * * @return null if no matching method could be found or the best matching method. */ public static Method getMethod(Class o_clazz, String name, Class[] arg_clazz, boolean[] arg_is_null) throws SecurityException, NoSuchMethodException { if (o_clazz == null) return null; /* if there is no argument, try to find a direct match */ if (arg_clazz == null || arg_clazz.length == 0) { return o_clazz.getMethod(name, (Class[])null); } /* try to find an exact match */ Method met; try { met = o_clazz.getMethod(name, arg_clazz); if (met != null) return met; } catch (NoSuchMethodException e) { /* we want to search further */ } /* ok, no exact match was found - we have to walk through all methods */ met = null; Method[] ml = o_clazz.getMethods(); for (int k = 0; k < ml.length; k++) { Method m = ml[k]; if (!m.getName().equals(name)) // the name must match continue; Class[] param_clazz = m.getParameterTypes(); if (arg_clazz.length != param_clazz.length) // number of parameters must match continue; int n = arg_clazz.length; boolean ok = true; for (int i = 0; i < n; i++) { if( arg_is_null[i] ){ /* then the class must not be a primitive type */ if( isPrimitive(arg_clazz[i]) ){ ok = false ; break ; } } else{ if (arg_clazz[i] != null && !param_clazz[i].isAssignableFrom(arg_clazz[i])) { ok = false; break; } } } if (ok && (met == null || isMoreSpecific(m, met))) // it must be the only match so far or more specific than the current match met = m; } if( met == null ){ throw new NoSuchMethodException( "No suitable method for the given parameters" ) ; } return met; } /** * Returns true if m1 is more specific than m2. * The measure used is described in the isMoreSpecific( Class[], Class[] ) method * * @param m1 method to compare * @param m2 method to compare * * @return true if m1 is more specific (in arguments) than m2. */ private static boolean isMoreSpecific(Method m1, Method m2) { Class[] m1_param_clazz = m1.getParameterTypes(); Class[] m2_param_clazz = m2.getParameterTypes(); return isMoreSpecific( m1_param_clazz, m2_param_clazz ); } /** * Returns true if cons1 is more specific than cons2. * The measure used is described in the isMoreSpecific( Class[], Class[] ) method * * @param cons1 constructor to compare * @param cons2 constructor to compare * * @return true if cons1 is more specific (in arguments) than cons2. */ private static boolean isMoreSpecific(Constructor cons1, Constructor cons2) { Class[] cons1_param_clazz = cons1.getParameterTypes(); Class[] cons2_param_clazz = cons2.getParameterTypes(); return isMoreSpecific( cons1_param_clazz, cons2_param_clazz ); } /** * Returns true if c1 is more specific than c2. * * The measure used is the sum of more specific arguments minus the sum of less specific arguments * which in total must be positive to qualify as more specific. * (More specific means the argument is a subclass of the other argument). * * Both set of classes must have signatures fully compatible in the arguments * (more precisely incompatible arguments are ignored in the comparison). * * @param c1 set of classes to compare * @param c2 set of classes to compare */ private static boolean isMoreSpecific( Class[] c1, Class[] c2){ int n = c1.length ; int res = 0; for (int i = 0; i < n; i++) if( c1[i] != c2[i]) { if( c1[i].isAssignableFrom(c2[i])) res--; else if( c2[i].isAssignableFrom(c2[i]) ) res++; } return res > 0; } /** * Returns the list of classes of the object * * @param o an Object */ public static Class[] getClasses(Object o){ Vector/*>*/ vec = new Vector(); Class cl = o.getClass(); while( cl != null ){ vec.add( cl ) ; cl = cl.getSuperclass() ; } Class[] res = new Class[ vec.size() ] ; vec.toArray( res) ; return res ; } /** * Returns the list of class names of the object * * @param o an Object */ public static String[] getClassNames(Object o){ Vector/**/ vec = new Vector(); Class cl = o.getClass(); while( cl != null ){ vec.add( cl.getName() ) ; cl = cl.getSuperclass() ; } String[] res = new String[ vec.size() ] ; vec.toArray( res) ; return res ; } /** * Returns the list of simple class names of the object * * @param o an Object */ public static String[] getSimpleClassNames(Object o, boolean addConditionClasses){ boolean hasException = false ; Vector/**/ vec = new Vector(); Class cl = o.getClass(); String name ; while( cl != null ){ name = getSimpleName( cl.getName() ) ; if( "Exception".equals( name) ){ hasException = true ; } vec.add( name ) ; cl = cl.getSuperclass() ; } if( addConditionClasses ){ if( !hasException ){ vec.add( "Exception" ) ; } vec.add( "error" ) ; vec.add( "condition" ) ; } String[] res = new String[ vec.size() ] ; vec.toArray( res) ; return res ; } /* because Class.getSimpleName is java 5 API */ private static String getSimpleClassName( Object o ){ return getSimpleName( o.getClass().getName() ) ; } private static String getSimpleName( String s ){ int lastsquare = s.lastIndexOf( '[' ) ; if( lastsquare >= 0 ){ if( s.charAt( s.lastIndexOf( '[' ) + 1 ) == 'L' ){ s = s.substring( s.lastIndexOf( '[' ) + 2, s.lastIndexOf( ';' ) ) ; } else { char first = s.charAt( 0 ); if( first == 'I' ) { s = "int" ; } else if( first == 'D' ){ s = "double" ; } else if( first == 'Z' ){ s = "boolean" ; } else if( first == 'B' ){ s = "byte" ; } else if( first == 'J' ){ s = "long" ; } else if( first == 'F' ){ s = "float" ; } else if( first == 'S' ){ s = "short" ; } else if( first == 'C' ){ s = "char" ; } } } int lastdollar = s.lastIndexOf( '$' ) ; if( lastdollar >= 0 ){ s = s.substring( lastdollar + 1); } int lastdot = s.lastIndexOf( '.' ) ; if( lastdot >= 0 ){ s = s.substring( lastdot + 1); } if( lastsquare >= 0 ){ StringBuffer buf = new StringBuffer( s ); int i ; for( i=0; i<=lastsquare; i++){ buf.append( "[]" ); } return buf.toString(); } else { return s ; } } /** * @param cl class * @param field name of the field * * @return the class name of the field of the class (or null) * if the class does not have the given field) */ public static String getFieldTypeName( Class cl, String field){ String res = null ; try{ res = cl.getField( field ).getType().getName() ; } catch( NoSuchFieldException e){ /* just return null */ res = null ; } return res ; } } rJava/src/java/NotAnArrayException.java0000644000175100001440000000043615133274032017606 0ustar hornikusers/** * Exception indicating that an object is not a java array */ public class NotAnArrayException extends Exception{ public NotAnArrayException(Class clazz){ super( "not an array : " + clazz.getName() ) ; } public NotAnArrayException(String message){ super( message ) ; } } rJava/src/java/FlatException.java0000644000175100001440000000032215133274032016450 0ustar hornikusers /** * Generated when one attemps to flatten an array that is not rectangular */ public class FlatException extends Exception{ public FlatException(){ super( "Can only flatten rectangular arrays" ); } } rJava/src/java/RJavaTools_Test$TestException.class0000644000175100001440000000047015133274037021706 0ustar hornikusersÊþº¾2   (Ljava/lang/String;)VCodeLineNumberTable SourceFileRJavaTools_Test.java RJavaTools_Test$TestException TestException InnerClassesjava/lang/ExceptionRJavaTools_Test!"*+·±    rJava/src/java/ArrayWrapper.class0000644000175100001440000001320215133274036016513 0ustar hornikusersÊþº¾2Ú wx By Az w{ A| w} A~ A A€ A A‚ Bƒ„… † ‡ˆ ‡‰I @Š‹Œ † ƒŽ A A A‘ A’D“”•–—˜™š›œžŸ ¡¢£¤¥¦ A§¨ 4†© 9ª r«¬ r­® ‡¯ r°±²³´µisRectZtypeNameLjava/lang/String; primitivelengthI(Ljava/lang/Object;)VCodeLineNumberTable StackMapTable Exceptions(I)V(Z)V(B)V(J)V(S)V(D)V(C)V(F)V isRectangular()ZisRectangular_(Ljava/lang/Object;I)ZgetObjectTypeName()Ljava/lang/String; isPrimitiveflat_int()[I flat_boolean()[Z flat_byte()[B flat_long()[J flat_short()[S flat_double()[D flat_char()[C flat_float()[F flat_Object()[Ljava/lang/Object;¶· flat_String()[Ljava/lang/String; SourceFileArrayWrapper.java¸ ¹º J» ¼½ \¾ EF ¿À GD ÁŽ CD Z[ HI JÂNotAnArrayExceptionprimitive type JÃÄ ÅÆ ÇÈ ÉÊPrimitiveArrayExceptionint FlatException[I ËY ÌÍ ÎI ÏIboolean[ZBbyte[BJlong[JSshort[SDdouble[DCchar[CFfloat[F ^YObjectArrayException[Ljava/lang/Object; ÐÑ ÒÓjava/lang/Object ÔÕ java/lang/ClassNotFoundException Ö× ØÙjava.lang.String[Ljava/lang/String;java/lang/String ArrayWrapperRJavaArrayIteratorjava/lang/ClassLoaderjava/lang/ClassRJavaArrayTools getDimensions(Ljava/lang/Object;)[I([I)VarrayLjava/lang/Object;&(Ljava/lang/Object;)Ljava/lang/String;isPrimitiveTypeName(Ljava/lang/String;)Z dimensions()V(Ljava/lang/String;)Vjava/lang/reflect/Array getLength(Ljava/lang/Object;)Iget'(Ljava/lang/Object;I)Ljava/lang/Object;equals(Ljava/lang/Object;)ZhasNextnext()Ljava/lang/Object;start incrementgetClass()Ljava/lang/Class;getClassLoader()Ljava/lang/ClassLoader;forName=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;cast&(Ljava/lang/Object;)Ljava/lang/Object;!ABCDEFGDHIJKLãu*+¸·*+µ*+¸µ**´¸µ*´¾  *µ § **+· µ *´ š*µ*µ §(*µ =*´¾¢*Y´ *´.hµ „§ÿå±M>"# $% &)'1);,B-G.O0T1_2n1t5Nÿ1A9 üúO JPL&*· » Y·¿M8O JQL&*· » Y·¿M9O JRL&*· » Y·¿M:O JSL&*· » Y·¿M;O JTL&*· » Y·¿M<O JUL&*· » Y·¿M=O JVL&*· » Y·¿M>O JWL&*· » Y·¿M?O XYL*´ ¬MFZ[Lˆ?*´¾ ¬+¸>*´.Ÿ¬6¢*+¸`· 𬄧ÿå¬M"M NOP%Q5R7P=UN üüú\]L*´°M\^YL*´¬Mc_`LÛt*´¶š »Y·¿*´ š »Y·¿*´¾  *´À°*´ ¼ L*¶™1*¶ÀN*´=6-¾¢+-.O„*´`=§ÿè§ÿÎ+°M6 no%p.q6s=vDwLxQy[zbyo|r}NüþùúOabLÛt*´¶š »Y·¿*´ š »Y·¿*´¾  *´À °*´ ¼L*¶™1*¶À N*´=6-¾¢+-3T„*´`=§ÿè§ÿÎ+°M6 ‰Š%‹.Œ6Ž=‘D’L“Q”[•b”o—r˜Nü þ ùúOcdLÛt!*´¶š »Y"·¿*´ š »Y·¿*´¾  *´À#°*´ ¼L*¶™1*¶À#N*´=6-¾¢+-3T„*´`=§ÿè§ÿÎ+°M6 ¤¥%¦.§6©=«D¬L­Q®[¯b®o±r²Nü#þ#ùúOefLÛt$*´¶š »Y%·¿*´ š »Y·¿*´¾  *´À&°*´ ¼ L*¶™1*¶À&N*´=6-¾¢+-/P„*´`=§ÿè§ÿÎ+°M6 ¿À%Á.Â6Ä=ÆDÇLÈQÉ[ÊbÉoÌrÍNü&þ&ùúOghLÛt'*´¶š »Y(·¿*´ š »Y·¿*´¾  *´À)°*´ ¼ L*¶™1*¶À)N*´=6-¾¢+-5V„*´`=§ÿè§ÿÎ+°M6 ÚÛ%Ü.Ý6ß=áDâLãQä[åbäoçrèNü)þ)ùúOijLÛt**´¶š »Y+·¿*´ š »Y·¿*´¾  *´À,°*´ ¼L*¶™1*¶À,N*´=6-¾¢+-1R„*´`=§ÿè§ÿÎ+°M6 ôõ%ö.÷6ù=ûDüLýQþ[ÿbþorNü,þ,ùúOklLÛt-*´¶š »Y.·¿*´ š »Y·¿*´¾  *´À/°*´ ¼L*¶™1*¶À/N*´=6-¾¢+-4U„*´`=§ÿè§ÿÎ+°M6 %.6=DLQ[borNü/þ/ùúOmnLÛt0*´¶š »Y1·¿*´ š »Y·¿*´¾  *´À2°*´ ¼L*¶™1*¶À2N*´=6-¾¢+-0Q„*´`=§ÿè§ÿÎ+°M6 *+%,.-6/=1D2L3Q4[5b4o7r8Nü2þ2ùúOopL9¦*¶3™»4Y*´·5¿*´ š »Y·¿*´¾  *´À6°*´¶7¶8L9M*´*´¶7¶8¸:M§N,*´ ¸<À6N*¶™<*¶À6:*´66¾¢-,2¶=S„*´`6§ÿß§ÿÃ-°ATW;MF@A"B+C3E>FAHTIXKdMkNtOzP…Q’P¡S¤TN- ÿ#Aqr;ü 6þ6ù#úO4stLÜu>*´¶š »Y>·¿*´ š »Y·¿*´¾  *´À?°*´ ½@L*¶™1*¶À?N*´=6-¾¢+-2S„*´`=§ÿè§ÿÎ+°M6 bc%d.e6g>iEjMkRl\mclpospNü?þ?ùúOuvrJava/src/java/RJavaClassLoader.class0000644000175100001440000002776515133274037017240 0ustar hornikusersÊþº¾2? ® ® ç Ì ®  › › ®    ! "# $ è%&'()  ®*+  ®,-. "/ 0 ®1 ®234 (/ (567 89:;<=>?@A BC BDE F GH éI éJKL MNO P êQR êST ›UVWX ¥Y ÌZ[\]^_`abc ®de Wfghij (kl (mn bop ïqr s t ïuvwx ïyz{| ®}~€ v‚ƒ v„… ̆‡ˆ‰ WŠ‹Œ ( ®Ž (‘’ ›“” W/•– (—˜ ™š›œ ž Ÿ  ¡ ®¢ £¤ ¥¦§¨ ®Z ®©ª« ¢¬­ ®¯ Ÿ°±² ³´ Ÿµ¶X ®· ®¸¹º»¼½ µ¸ µ¾ µ¿ ®ÀÁ QÂà ½Ä ¿Å ¿Æ ¿y ½ÇÈ ÄÉÊ ÆË ÆÌ Æy ®Í ®ÎÏRJavaObjectInputStream InnerClasses UnixDirectory UnixJarFileUnixFile rJavaPathLjava/lang/String; rJavaLibPathlibMapLjava/util/HashMap; classPathLjava/util/Vector; primaryLoaderLRJavaClassLoader;verboseZ useSystemgetPrimaryLoader()LRJavaClassLoader;CodeLineNumberTable'(Ljava/lang/String;Ljava/lang/String;)V9(Ljava/lang/String;Ljava/lang/String;LRJavaClassLoader;)V StackMapTableÐÑÒÓÔclassNameToFile&(Ljava/lang/String;)Ljava/lang/String; findClass%(Ljava/lang/String;)Ljava/lang/Class;ÕÖ Exceptions findResource"(Ljava/lang/String;)Ljava/net/URL; addRLibrary addClassPath(Ljava/lang/String;)V([Ljava/lang/String;)V getClassPath()[Ljava/lang/String; findLibrary bootClass:(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)VרÙsetDebug(I)Vu2wmaintoByte(Ljava/lang/Object;)[BtoObject([B)Ljava/lang/Object; toObjectPL()V SourceFileRJavaClassLoader.java ÙÚ âä java/net/URL ÚÛ âÜ ÝÜ rJava.debugÝ Þì ßà0 áâ ÛÜ ãäjava/lang/StringBuilder â RJavaClassLoader(" åæ", "",  no parent åç) èé êö - primary loader - NOT primrary (this= , primary=java/util/HashMap ÕÖjava/util/Vector רRJavaClassLoader$UnixDirectory/java âë ìâ ÒÓ ÔÓRJavaClassLoader$UnixFile /rJava.so íî /rJava.dllrJava ïð/jri/libjri.sor.arch/jri /libjri.so/jri.dll/jri/libjri.jnilib /jri/jri.dlljri - registered JRI: ñ òó ôõ4RJavaClassLoader initialized. Registered libraries: ö÷ø ùú ûî üý : ' þÿ' Registered class paths:  î ' ý! -- end of class loader report --  .findClass(RJavaClassLoader  íîRJavaClassLoader: found class  using URL loaderjava/lang/Exception - URL loader did not find it: RJavaClassLoader.findClass("") - trying class path ""RJavaClassLoader$UnixJarFile ëì.class   JAR file, can get ''? NOYES  é/  îjava/io/FileInputStream â  Directory, can get '  " loading class file, initial n = å    next n =  (rp=, al=  RJavaClassLoader: loaded class ,  bytes  defineClass(' ') returned  java/lang/ClassNotFoundExceptionFClass not found - candidate class binary found but could not be loaded â >> ClassNotFoundException  RJavaClassLoader: findResource('') òó$RJavaClassLoader: found resource in  using URL loader.9 - resource not found with URL loader, trying alternative ó - found in a JAR file, URL  - find as a file:  RJavaClassLoader: added '' to the URL class path loader é.jar .JAR,RJavaClassLoader: adding Java archive file '' to the internal class path î*RJavaClassLoader: adding class directory '  äWARNING: the path 'Z' is neither a directory nor a .jar file, it will NOT be added to the internal class path!B' does NOT exist, it will NOT be added to the internal class path! !âjava.class.path" #Ó $% õö &àjava/lang/String '(RJavaClassLoader.findLibrary(" - mapping to  )*java/lang/Class[Ljava/lang/String; +,java/lang/Object- ./ 01 rjava.pathERROR: rjava.path is not set 2 rjava.lib 3Ólibs ì âã main.class2WARNING: main.class not specified, assuming 'Main'Mainrjava.class.pathjava/util/StringTokenizer 4î 5é ûü"ERROR: while running main method: 6 java/io/ByteArrayOutputStreamjava/io/ObjectOutputStream â7 89 :;java/io/ByteArrayInputStream â<'RJavaClassLoader$RJavaObjectInputStream â= >ý Þß java/net/URLClassLoader[Ljava/net/URL;java/lang/ClassLoaderjava/io/PrintStreamjava/util/Iteratorjava/util/Enumerationjava/io/InputStream[B java/lang/IllegalAccessException+java/lang/reflect/InvocationTargetExceptionjava/lang/NoSuchMethodExceptiongetSystemClassLoader()Ljava/lang/ClassLoader;)([Ljava/net/URL;Ljava/lang/ClassLoader;)Vjava/lang/System getPropertylength()Iequals(Ljava/lang/Object;)ZoutLjava/io/PrintStream;append-(Ljava/lang/String;)Ljava/lang/StringBuilder;-(Ljava/lang/Object;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;println'(LRJavaClassLoader;Ljava/lang/String;)Vaddexists()Zput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/lang/Thread currentThread()Ljava/lang/Thread;setContextClassLoader(Ljava/lang/ClassLoader;)VkeySet()Ljava/util/Set; java/util/Setiterator()Ljava/util/Iterator;hasNextnext()Ljava/lang/Object;get&(Ljava/lang/Object;)Ljava/lang/Object;elements()Ljava/util/Enumeration;hasMoreElements nextElementreplace(CC)Ljava/lang/String;getClass()Ljava/lang/Class;getResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream;getPathisFile(Ljava/io/File;)Vread([B)I(I)Ljava/lang/StringBuilder; arraycopy*(Ljava/lang/Object;ILjava/lang/Object;II)V([BII)Iclose defineClass)(Ljava/lang/String;[BII)Ljava/lang/Class;*(Ljava/lang/String;Ljava/lang/Throwable;)V getResourcetoURL()Ljava/net/URL;addURL(Ljava/net/URL;)VgetNameendsWith(Ljava/lang/String;)Z isDirectoryerrcontains java/io/File pathSeparator setProperty8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;size elementAt(I)Ljava/lang/Object; resolveClass(Ljava/lang/Class;)V getMethod@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;java/lang/reflect/Methodinvoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; separatorCharCexit separator hasMoreTokens nextTokenprintStackTrace(Ljava/io/OutputStream;)V writeObject(Ljava/lang/Object;)V toByteArray()[B([B)V*(LRJavaClassLoader;Ljava/io/InputStream;)V readObject!®ÌÒÓÔÓÕÖר ÙÚ ÛÜÝÜ ÞßರáÄâãà$*+,·±á ÑÒâäà» 5*½-Ç ¸§-·*µ¸:ƶ ž ¶ š³ ² ™<² »Y·¶+¶¶,¶¶-ǧ-¶¶¶¶²Ç*³² ™=² ¶§2² ™,² »Y·¶*¶¶²¶¶¶¶*»Y·µ*»Y· µ!*´!»"Y*»Y·+¶#¶¶·$¶%W*+µ&*,µ'»(Y*»Y·*´'¶)¶¶·*:¶+š#»(Y*»Y·*´'¶,¶¶·*:¶+™*´-¶.W»(Y*»Y·+¶/¶¶·*:0¸:Æt¶ žl»(Y*»Y·+¶1¶¶2¶¶·*:¶+™ :§6»(Y*»Y·+¶1¶¶3¶¶·*:¶+™:¶+š »(Y*»Y·+¶4¶¶·*:¶+š »(Y*»Y·+¶5¶¶·*:¶+™/*´6¶.W² ™² »Y·7¶¶¶¶²*¦ ¸8*¶9² ™©² :¶*´¶;¹<:¹=™?¹>: ² »Y·?¶ ¶@¶*´ ¶A¶B¶¶¶§ÿ½² C¶*´!¶D:¹E™*² »Y·F¶¹G¶B¶¶¶§ÿÒ² H¶±á¾/Ý:àá:âyãäƒå”çÃêÎìÙíüïðó&ô.õNöV÷búû†ü“ýºþÂÿÉðøü!) F N Z zˆŽ–®çêò,4å°ÿ››®æÿ››®æçÿ)®››®›ÿ/®››®›èÿ®››®›è¥ .üŠ(þf(›(ú2$$3 üéúEüêú0ëìà! +./¶I°á&íîਠVM² ™*² »Y·J¶*¶K¶+¶¶¶¶L+¶ ™*¶M°*´™V*+·NM,Æ)² ™!² »Y·O¶+¶P¶¶¶,°§#N² ™² »Y·R¶-¶¶¶² ™!² »Y·S¶+¶T¶¶¶N:*´!¶D:¹E™Y¹GÀ(:² ™"² »Y·U¶¶V¶¶¶NÁW™\ÀW»Y·*+¶X¶Y¶¶¶ZN² ™±² »Y·[¶*+¶X¶\¶-Ç]§^¶¶¶§~Á"™v»(Y*»Y·¶_¶`¶*+¶X¶Y¶¶·*:¶a™ »bY·cN² ™0² »Y·d¶¶\¶-Ç]§^¶¶¶-Æ>e6¼:-¶f6  6 ² ™² »Y·g¶ ¶h¶¶ žŒ  -h6  i¢i6  ¼:  ¸j : 6- ¾ d¶k6 ² ™6² »Y·l¶ ¶hm¶ ¶hn¶¶h¶¶¶ žÿ  `6 §ÿu-¶o 6 ² ™+² »Y·p¶+¶q¶ ¶hr¶¶¶*+ ¶sM§ :  :§5² ™%² »Y·t¶+¶u¶,¶¶¶,°§:§ý£Æ»vYw·x¿,Dz ™ ² y¶»vY·z¿,°DswQàëîQô$Q÷ $Qáþ?,-/.=1D3J4N5r6t:w8x9—<»@½AÀBÉCÓDßFHJK.LgMoNO¥P¯Râ_æ`êaðbøcüde!f(g.h9i?jJkNlRnbo›pªr®s²tàvë{îwðyôz÷|~!‚$€&ƒ)†.‡:Š>‹LŒTŽå ü/¢ 4BQ#þ ïQêü:(ÿT®›¢ïQê(èÿ®›¢ïQê(è› üG(ÿ'®›¢ïQê((èÿ®›¢ïQê((è›úÿ9 ®›¢ïQê(ðüúûH5MQ'ÿ®›¢ïQê(BQúñvòóà÷'² ™!² »Y·{¶+¶|¶¶¶*´™7*+·}M,Æ)² ™!² »Y·~¶,¶¶¶¶,°§M² ™ ² €¶*´!¶DM,¹E™ª,¹GÀ(N-ÁW™8-ÀW+¶:Æ&² ™² »Y·‚¶¶¶¶°§\-Á"™U»(Y*»Y·-¶_¶`¶+¶¶·*:¶a™)² ™² »Y·ƒ¶¶¶¶¶„°§:§ÿS°+Z^QˆÀ QÁ Qáj”$—+™1š5›Yœ[Ÿ^ž_¤m¥u¦~§ˆ«¬™­ž®¾¯Á±Ë²ï³÷´µ¹ ¸"º%¼å6$ü4úBQ üêýH(úüR(úBQúôãà/*´+»(Y*,·*¶.W±á ÃÄõöàO»(Y*+·*M*´™3*,¶„¶…² ™!² »Y·†¶+¶‡¶¶¶§NN,¶a™L,¶ˆ‰¶Šš,¶ˆ‹¶Š™4»WY*+·ŒN² ™¢² »Y·¶+¶޶¶¶§,¶™4»"Y*+·$N² ™j² »Y·¶+¶޶¶¶§I² ™C²‘,¶+™»Y·’¶+¶“¶¶§»Y·’¶+¶”¶¶¶-Æ<*´!-¶•š1*´!-¶%W–»Y·–¸¶²—¶-¶_¶¶¸˜W±=@QábÌ ÏÑÒ=Õ@ÔAØCÙbÚlÛ“ÜšݤÞËßÑàÛáöâàä æ)è4éJèNëå4 ü=(BQü (07jèÿ®›((è›<õ÷àC=+¾¢*+„2¶™§ÿð±áñòóåüøùàn-*´!¶š<½›M>¢,*´!¶œÀ(¶_S„§ÿç,°áûü ýþÿ%+å þ£úìààl² ™!² »Y·¶+¶T¶¶¶*´+¶AÀ(MN,Æ,¶+™,¶_N² ™%² »Y·ž¶-ÇŸ§-¶¶¶-°á$ 0 2BjåB$ý(›ÿ®›(›èÿ®›(›è›ûüàV.*+¶ :*¶¡,½¢Y£S¶¤:½¥Y-S¶¦W±á  !-"ñ ýþÿv à4 ž§³ ±á - .å@ ìà;²§/Ÿ*/²§¶I§*°á8å@› ÷à}Ψ¸L+Dz‘©¶¸ª«¸M,Ç»Y·+¶²¬¶­¶¶M»®Y+¸¯,¸¯·°N±¸:Æ ¶ ¢²‘²¶³:´¸:Æ,»µY²—·¶:¶·™¶¸¸¯:-¶™§ÿè-¹*¶º§$:²‘»Y·»¶¶¶¶¶¼± ©¬QáfNO PQST U:WJXQY_Zg[k]r^w_…`a—bc f©j¬g®hÈiÍkå)ü›ü#›ý$®› ý›µúKQ àG»½Y·¾L»¿Y+·ÀM,*¶Á,¶Â+¶Ã°á„…†‡ˆñQàH »ÄY+·ÅM»ÆY*,·ÇN-¶È:-¶É°á• –—˜™ñQ à ¸Ê*¶Ë°á¢ñQ  à% ³³ ±á /4  Î"Æ®Í"®ÏW®Ð(®ÑrJava/src/java/RJavaArrayTools.java0000644000175100001440000007067015133274032016743 0ustar hornikusers// RJavaTools.java: rJava - low level R to java interface // // :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: // // Copyright (C) 2009 - 2010 Simon Urbanek and Romain Francois // // This file is part of rJava. // // rJava is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // rJava is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with rJava. If not, see . import java.lang.reflect.Array ; import java.util.Map; import java.util.HashMap; import java.util.Vector ; import java.util.Arrays ; import java.util.Iterator; import java.lang.reflect.Method ; import java.lang.reflect.InvocationTargetException ; public class RJavaArrayTools { // TODO: maybe factor this out of this class private static Map primitiveClasses = initPrimitiveClasses() ; private static Map initPrimitiveClasses(){ Map primitives = new HashMap(); primitives.put( "I", Integer.TYPE ); primitives.put( "Z", Boolean.TYPE ); primitives.put( "B", Byte.TYPE ); primitives.put( "J", Long.TYPE ); primitives.put( "S", Short.TYPE ); primitives.put( "D", Double.TYPE ); primitives.put( "C", Character.TYPE ); primitives.put( "F", Float.TYPE ); return primitives; } // {{{ getObjectTypeName /** * Get the object type name of an multi dimensional array. * * @param o object * @throws NotAnArrayException if the object is not an array */ public static String getObjectTypeName(Object o) throws NotAnArrayException { Class o_clazz = o.getClass(); if( !o_clazz.isArray() ) throw new NotAnArrayException( o_clazz ); String cl = o_clazz.getName(); return cl.replaceFirst("\\[+L?", "").replace(";", "") ; } public static int getObjectTypeName(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getObjectTypeName(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getObjectTypeName(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getObjectTypeName(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getObjectTypeName(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getObjectTypeName(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getObjectTypeName(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getObjectTypeName(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ makeArraySignature // TODO: test public static String makeArraySignature( String typeName, int depth ){ StringBuffer buffer = new StringBuffer() ; for( int i=0; i 1 ) return false; if( name.equals("I") ) return true ; if( name.equals("Z") ) return true ; if( name.equals("B") ) return true ; if( name.equals("J") ) return true ; if( name.equals("S") ) return true ; if( name.equals("D") ) return true ; if( name.equals("C") ) return true ; if( name.equals("F") ) return true ; return false; } // }}} // {{{ isRectangularArray /** * Indicates if o is a rectangular array * * @param o an array * @deprecated use new ArrayWrapper(o).isRectangular() instead */ public static boolean isRectangularArray(Object o) { if( !isArray(o) ) return false; boolean res = false; try{ if( getDimensionLength( o ) == 1 ) return true ; res = ( new ArrayWrapper(o) ).isRectangular() ; } catch( NotAnArrayException e){ res = false; } return res ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static boolean isRectangularArray(int x) { return false ; } public static boolean isRectangularArray(boolean x) { return false ; } public static boolean isRectangularArray(byte x) { return false ; } public static boolean isRectangularArray(long x) { return false ; } public static boolean isRectangularArray(short x) { return false ; } public static boolean isRectangularArray(double x) { return false ; } public static boolean isRectangularArray(char x) { return false ; } public static boolean isRectangularArray(float x) { return false ; } // }}} // {{{ getDimensionLength /** * Returns the number of dimensions of an array * * @param o an array * @throws NotAnArrayException if this is not an array */ public static int getDimensionLength( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; int n = 0; while( clazz.isArray() ){ n++ ; clazz = clazz.getComponentType() ; } return n ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int getDimensionLength(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getDimensionLength(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getDimensionLength(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getDimensionLength(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getDimensionLength(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getDimensionLength(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getDimensionLength(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getDimensionLength(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ getDimensions /** * Returns the dimensions of an array * * @param o an array * @throws NotAnArrayException if this is not an array * @return the dimensions of the array or null if the object is null */ public static int[] getDimensions( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; Object a = o ; int n = getDimensionLength( o ) ; int[] dims = new int[n] ; int i=0; int current ; while( clazz.isArray() ){ current = Array.getLength( a ) ; dims[i] = current ; i++; if( current == 0 ){ break ; // the while loop } else { a = Array.get( a, 0 ) ; clazz = clazz.getComponentType() ; } } /* in case of premature stop, we fill the rest of the array with 0 */ // this might not be true: // Object[][] = new Object[0][10] will return c(0,0) while( i < dims.length){ dims[i] = 0 ; i++ ; } return dims ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int[] getDimensions(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int[] getDimensions(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int[] getDimensions(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int[] getDimensions(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int[] getDimensions(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int[] getDimensions(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int[] getDimensions(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int[] getDimensions(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ getTrueLength /** * Returns the true length of an array (the product of its dimensions) * * @param o an array * @throws NotAnArrayException if this is not an array * @return the number of objects in the array (the product of its dimensions). */ public static int getTrueLength( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; Object a = o ; int len = 1 ; int i = 0; while( clazz.isArray() ){ len = len * Array.getLength( a ) ; if( len == 0 ) return 0 ; /* no need to go further */ i++; a = Array.get( a, 0 ) ; clazz = clazz.getComponentType() ; } return len ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int getTrueLength(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getTrueLength(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getTrueLength(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getTrueLength(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getTrueLength(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getTrueLength(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getTrueLength(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getTrueLength(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ isArray /** * Indicates if a java object is an array * * @param o object * @return true if the object is an array * @deprecated use RJavaArrayTools#isArray */ public static boolean isArray(Object o){ if( o == null) return false ; return o.getClass().isArray() ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static boolean isArray(int x){ return false ; } public static boolean isArray(boolean x){ return false ; } public static boolean isArray(byte x){ return false ; } public static boolean isArray(long x){ return false ; } public static boolean isArray(short x){ return false ; } public static boolean isArray(double x){ return false ; } public static boolean isArray(char x){ return false ; } public static boolean isArray(float x){ return false ; } // }}} // {{{ ArrayDimensionMismatchException public static class ArrayDimensionMismatchException extends Exception { public ArrayDimensionMismatchException( int index_dim, int actual_dim ){ super( "dimension of indexer (" + index_dim + ") too large for array (depth ="+ actual_dim+ ")") ; } } // }}} // {{{ get /** * Gets a single object from a multi dimensional array * * @param array java array * @param position */ public static Object get( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.get( getArray( array, position ), position[ position.length -1] ); } public static int getInt( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getInt( getArray( array, position ), position[ position.length -1] ); } public static boolean getBoolean( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getBoolean( getArray( array, position ), position[ position.length -1] ); } public static byte getByte( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getByte( getArray( array, position ), position[ position.length -1] ); } public static long getLong( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getLong( getArray( array, position ), position[ position.length -1] ); } public static short getShort( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getShort( getArray( array, position ), position[ position.length -1] ); } public static double getDouble( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getDouble( getArray( array, position ), position[ position.length -1] ); } public static char getChar( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getChar( getArray( array, position ), position[ position.length -1] ); } public static float getFloat( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getFloat( getArray( array, position ), position[ position.length -1] ); } public static Object get( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return get( array, new int[]{position} ) ; } public static int getInt( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getInt( array, new int[]{position} ) ; } public static boolean getBoolean( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getBoolean( array, new int[]{position} ) ; } public static byte getByte( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getByte( array, new int[]{position} ) ; } public static long getLong( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getLong( array, new int[]{position} ) ; } public static short getShort( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getShort( array, new int[]{position} ) ; } public static double getDouble( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getDouble( array, new int[]{position} ) ; } public static char getChar( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getChar( array, new int[]{position} ) ; } public static float getFloat( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getFloat( array, new int[]{position} ) ; } private static void checkDimensions(Object array, int[] position) throws NotAnArrayException, ArrayDimensionMismatchException { int poslength = position.length ; int actuallength = getDimensionLength(array); if( poslength > actuallength ){ throw new ArrayDimensionMismatchException( poslength, actuallength ) ; } } // }}} // {{{ set /** * Replaces a single value of the array * * @param array array * @param position index * @param value the new value * * @throws NotAnArrayException if array is not an array * @throws ArrayDimensionMismatchException if the length of position is too big */ public static void set( Object array, int[] position, Object value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.set( getArray( array, position ), position[ position.length - 1], value ) ; } /* primitive versions */ public static void set( Object array, int[] position, int value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setInt( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, boolean value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setBoolean( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, byte value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setByte( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, long value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setLong( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, short value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setShort( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, double value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setDouble( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, char value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setChar( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, float value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setFloat( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int position, Object value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, int value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, boolean value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, byte value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, long value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, short value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, double value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, char value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, float value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } private static Object getArray( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException{ checkDimensions( array, position ) ; int poslength = position.length ; Object o = array ; int i=0 ; if( poslength > 1 ){ while( i< (poslength-1) ){ o = Array.get( o, position[i] ) ; i++ ; } } return o ; } // TODO: also have primitive types in value // }}} // {{{ unique // TODO: cannot use LinkedHashSet because it first was introduced in 1.4 // and code in this area needs to work on 1.2 jvm public static Object[] unique( Object[] array ){ int n = array.length ; boolean[] unique = new boolean[ array.length ]; for( int i=0; i ?@ ABC DE F G H IJ KL M HNOP QRUzfileLjava/util/zip/ZipFile; urlPrefixLjava/lang/String;this$0LRJavaClassLoader;'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTableupdate()V StackMapTablegetResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream; getResource"(Ljava/lang/String;)Ljava/net/URL;W SourceFileRJavaClassLoader.java $% &' ! X+java/util/zip/ZipFile &Yjava/lang/Exception *+ Z[ \] ^_` abc dejava/lang/StringBuilder &+)RJavaClassLoader$UnixJarFile: exception: fg hi jik lm "#jar: no!java/net/MalformedURLException java/net/URL &mRJavaClassLoader$UnixJarFile UnixJarFile InnerClassesRJavaClassLoader$UnixFileUnixFilejava/lang/Stringclose(Ljava/io/File;)V hasChanged()ZgetEntry,(Ljava/lang/String;)Ljava/util/zip/ZipEntry;getInputStream/(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;RJavaClassLoaderverboseZjava/lang/SystemerrLjava/io/PrintStream;append-(Ljava/lang/String;)Ljava/lang/StringBuilder; getMessage()Ljava/lang/String;toStringjava/io/PrintStreamprintln(Ljava/lang/String;)VtoURL()Ljava/net/URL;  !"#$%&'(, *+µ*+,·±)rs t*+(e#*´Æ *´¶*»Y*·µ§L*·±)yz|}€",N-.(¶Y*´Æ *¶ ™*¶ *´Ç°*´+¶ M,Æ *´,¶ °§&M² ™²»Y·¶,¶¶¶¶°404)* ‹Œ$‘(’1•4“5”W–, B"/0(Ùf*´Æ*´+¶ ǰM*´Ç)*»Y·¶*¶¶¶¶¶µ§N»Y»Y·*´¶+¶¶·M§N,°?BC`c). ›œŸ ¢?¤B£C¨`«c©d¬,ÿ-1_23T?S?VrJava/src/java/ArrayWrapper_Test.class0000644000175100001440000006755415133274036017535 0ustar hornikusersÊþº¾2= @‡ ?ˆ‰ Š ‹Œ ‹Ž ‘ ?’“” ?•– ?—˜ ?™š ?›œ ?ž ?Ÿ  ?¡¢ ?£¤ ?¥¦ ?§¨ ?©ª ?«¬ ?­® ?¯° ?±² ?³´ ?µ¶ ?·¸ ?¹º ?»¼ ?½¾ ?¿À ?Á ?ÃÄ ?ÅÆ ?ÇÈ ?ÉÊ ?ËÌ ?ÍÎ ÏÐ HÑÒÓ ÔÕÖ HרÙÚ HÛÜ  ÝÞßà Háââãäå ^‡æ ^ç ^èéê ^ëì íîïðñòó íôõö÷øùúûüýþÿ H ^ í í      H í í !"#$%&'()* H+, ^- í./0123 í456789:;<=>?@ HAB íCDEFGH íIJKLMNOPQRSTU HVW ^X íYZ[\]^ í_`abcdefghijk Hlm ^n íopqrst íuvwxyz{|}~€ H‚ƒ ^„ í…†‡ˆ‰Š í‹ŒŽ‘’“”•–—˜™š H›œ 힟 ¡¢ í£¤¥¦§¨© "ª«¬­©®¯° H±²³³´ "µ "¶· í¸¹º»¼½ í¾¿ÀÁÂÃÄÅ()VCodeLineNumberTablemain([Ljava/lang/String;)V StackMapTableruntests Exceptions flatten_int_1Æ flatten_int_2Ç flatten_int_3Èflatten_boolean_1Éflatten_boolean_2Êflatten_boolean_3Ëflatten_byte_1Ìflatten_byte_2Íflatten_byte_3Îflatten_long_1Ïflatten_long_2Ðflatten_long_3Ñflatten_short_1Òflatten_short_2Óflatten_short_3Ôflatten_double_1Õflatten_double_2Öflatten_double_3×flatten_char_1Øflatten_char_2Ùflatten_char_3Úflatten_float_1Ûflatten_float_2Üflatten_float_3Ýflatten_String_1Þflatten_String_2ßflatten_String_3àflatten_Point_1flatten_Point_2áflatten_Point_3â SourceFileArrayWrapper_Test.java AB HB TestException ãBä åæ çè ALL PASSED é êë flatten int[] JBPASSEDflatten int[][] LBflatten int[][][] NBflatten boolean[] PBflatten boolean[][] RBflatten boolean[][][] TBflatten byte[] VBflatten byte[][] XBflatten byte[][][] ZBflatten long[] \Bflatten long[][] ^Bflatten long[][][] `Bflatten short[] bBflatten short[][] dBflatten short[][][] fBflatten double[] hBflatten double[][] jBflatten double[][][] lBflatten char[] nBflatten char[][] pBflatten char[][][] rBflatten float[] tBflatten float[][] vBflatten float[][][] xBflatten String[] zBflatten String[][] |Bflatten String[][][] ~Bflatten Point[] €Bflatten Point[][] Bflatten Point[][][] ƒB >> new ArrayWrapper( int[] ) ìë ArrayWrapper AíNotAnArrayException/new ArrayWrapper(int[]) >> NotAnArrayException Aëok >> isPrimitive() îï!ArrayWrapper(int[]) not primitive true : ok >> getObjectTypeName() ðñI òó.ArrayWrapper(int[]).getObjectTypeName() != 'I' I : ok >> flat_int() ôõPrimitiveArrayException FlatException(new ArrayWrapper(int[]) >> FlatExceptionjava/lang/StringBuilderflat[ ö÷ öø] = != ùñ okú ûü! >> new ArrayWrapper( int[][] ) 1new ArrayWrapper(int[][]) >> NotAnArrayException #ArrayWrapper(int[][]) not primitive0ArrayWrapper(int[][]).getObjectTypeName() != 'I'*new ArrayWrapper(int[][]) >> FlatException ýþ# >> new ArrayWrapper( int[][][] ) 3new ArrayWrapper(int[][][]) >> NotAnArrayException %ArrayWrapper(int[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'I',new ArrayWrapper(int[][][]) >> FlatException# >> new ArrayWrapper( boolean[] ) 3new ArrayWrapper(boolean[]) >> NotAnArrayException %ArrayWrapper(boolean[]) not primitiveZ2ArrayWrapper(boolean[]).getObjectTypeName() != 'Z' Z : ok >> flat_boolean() ÿ ö % >> new ArrayWrapper( boolean[][] ) 5new ArrayWrapper(boolean[][]) >> NotAnArrayException 'ArrayWrapper(boolean[][]) not primitive4ArrayWrapper(boolean[][]).getObjectTypeName() != 'Z'.new ArrayWrapper(boolean[][]) >> FlatException ' >> new ArrayWrapper( boolean[][][] ) 7new ArrayWrapper(boolean[][][]) >> NotAnArrayException )ArrayWrapper(boolean[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'Z'0new ArrayWrapper(boolean[][][]) >> FlatException >> new ArrayWrapper( byte[] ) 0new ArrayWrapper(byte[]) >> NotAnArrayException "ArrayWrapper(byte[]) not primitiveB/ArrayWrapper(byte[]).getObjectTypeName() != 'I' B : ok >> flat_byte() )new ArrayWrapper(byte[]) >> FlatException  " >> new ArrayWrapper( byte[][] ) 2new ArrayWrapper(byte[][]) >> NotAnArrayException $ArrayWrapper(byte[][]) not primitive1ArrayWrapper(byte[][]).getObjectTypeName() != 'B'+new ArrayWrapper(byte[][]) >> FlatException   $ >> new ArrayWrapper( byte[][][] ) 4new ArrayWrapper(byte[][][]) >> NotAnArrayException &ArrayWrapper(byte[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'B'-new ArrayWrapper(byte[][][]) >> FlatException >> new ArrayWrapper( long[] ) 0new ArrayWrapper(long[]) >> NotAnArrayException "ArrayWrapper(long[]) not primitiveJ/ArrayWrapper(long[]).getObjectTypeName() != 'J' J : ok >> flat_long()   )new ArrayWrapper(long[]) >> FlatException ö " >> new ArrayWrapper( long[][] ) 2new ArrayWrapper(long[][]) >> NotAnArrayException $ArrayWrapper(long[][]) not primitive1ArrayWrapper(long[][]).getObjectTypeName() != 'J'+new ArrayWrapper(long[][]) >> FlatException $ >> new ArrayWrapper( long[][][] ) 4new ArrayWrapper(long[][][]) >> NotAnArrayException &ArrayWrapper(long[][][]) not primitive3ArrayWrapper(long[][][]).getObjectTypeName() != 'J'-new ArrayWrapper(long[][][]) >> FlatException! >> new ArrayWrapper( short[] ) 1new ArrayWrapper(short[]) >> NotAnArrayException #ArrayWrapper(short[]) not primitiveS/ArrayWrapper(long[]).getObjectTypeName() != 'S' S : ok >> flat_short() *new ArrayWrapper(short[]) >> FlatException # >> new ArrayWrapper( short[][] ) 3new ArrayWrapper(short[][]) >> NotAnArrayException %ArrayWrapper(short[][]) not primitive2ArrayWrapper(short[][]).getObjectTypeName() != 'S',new ArrayWrapper(short[][]) >> FlatException % >> new ArrayWrapper( short[][][] ) 5new ArrayWrapper(short[][][]) >> NotAnArrayException 'ArrayWrapper(short[][][]) not primitive4ArrayWrapper(short[][][]).getObjectTypeName() != 'S'.new ArrayWrapper(short[][][]) >> FlatException" >> new ArrayWrapper( double[] ) 2new ArrayWrapper(double[]) >> NotAnArrayException $ArrayWrapper(double[]) not primitiveD1ArrayWrapper(double[]).getObjectTypeName() != 'D' D : ok >> flat_double() +new ArrayWrapper(double[]) >> FlatException ö $ >> new ArrayWrapper( double[][] ) 4new ArrayWrapper(double[][]) >> NotAnArrayException &ArrayWrapper(double[][]) not primitive3ArrayWrapper(double[][]).getObjectTypeName() != 'D'-new ArrayWrapper(double[][]) >> FlatException & >> new ArrayWrapper( double[][][] ) 6new ArrayWrapper(double[][][]) >> NotAnArrayException (ArrayWrapper(double[][][]) not primitive5ArrayWrapper(double[][][]).getObjectTypeName() != 'D'/new ArrayWrapper(double[][][]) >> FlatException >> new ArrayWrapper( char[] ) 0new ArrayWrapper(char[]) >> NotAnArrayException "ArrayWrapper(char[]) not primitiveC/ArrayWrapper(char[]).getObjectTypeName() != 'C' C : ok >> flat_char()  !)new ArrayWrapper(char[]) >> FlatException ö" #$" >> new ArrayWrapper( char[][] ) 2new ArrayWrapper(char[][]) >> NotAnArrayException $ArrayWrapper(char[][]) not primitive1ArrayWrapper(char[][]).getObjectTypeName() != 'C'+new ArrayWrapper(char[][]) >> FlatException %&$ >> new ArrayWrapper( char[][][] ) 4new ArrayWrapper(char[][][]) >> NotAnArrayException &ArrayWrapper(char[][][]) not primitive3ArrayWrapper(char[][][]).getObjectTypeName() != 'C'-new ArrayWrapper(char[][][]) >> FlatException! >> new ArrayWrapper( float[] ) 1new ArrayWrapper(float[]) >> NotAnArrayException #ArrayWrapper(float[]) not primitiveF0ArrayWrapper(float[]).getObjectTypeName() != 'F' F : ok >> flat_float() '(*new ArrayWrapper(float[]) >> FlatException ö) *+# >> new ArrayWrapper( float[][] ) 3new ArrayWrapper(float[][]) >> NotAnArrayException %ArrayWrapper(float[][]) not primitive2ArrayWrapper(float[][]).getObjectTypeName() != 'F',new ArrayWrapper(float[][]) >> FlatException ,-% >> new ArrayWrapper( float[][][] ) 5new ArrayWrapper(float[][][]) >> NotAnArrayException 'ArrayWrapper(float[][][]) not primitive4ArrayWrapper(float[][][]).getObjectTypeName() != 'F'.new ArrayWrapper(float[][][]) >> FlatExceptionjava/lang/String" >> new ArrayWrapper( String[] ) 2new ArrayWrapper(String[]) >> NotAnArrayException #ArrayWrapper(String[]) is primitive false : okjava.lang.String?ArrayWrapper(float[]).getObjectTypeName() != 'java.lang.String' java.lang.String : ok >> flat_String() ./+new ArrayWrapper(String[]) >> FlatException 01$ >> new ArrayWrapper( String[][] ) 4new ArrayWrapper(String[][]) >> NotAnArrayException %ArrayWrapper(String[][]) is primitiveAArrayWrapper(float[][]).getObjectTypeName() != 'java.lang.String'-new ArrayWrapper(String[][]) >> FlatException 23& >> new ArrayWrapper( String[][][] ) 6new ArrayWrapper(String[][][]) >> NotAnArrayException 'ArrayWrapper(String[][][]) is primitiveDArrayWrapper(String[][][]).getObjectTypeName() != 'java.lang.String'/new ArrayWrapper(String[][][]) >> FlatException DummyPoint A4& >> new ArrayWrapper( DummyPoint[] ) 6new ArrayWrapper(DummyPoint[]) >> NotAnArrayException 'ArrayWrapper(DummyPoint[]) is primitive>ArrayWrapper(DummyPoint[]).getObjectTypeName() != 'DummyPoint' DummyPoint : ok >> flat_Object() 56 [LDummyPoint;ObjectArrayException/new ArrayWrapper(DummyPoint[]) >> FlatException 7Ü 8Ü].x = 9:( >> new ArrayWrapper( DummyPoint[][] ) 8new ArrayWrapper(DummyPoint[][]) >> NotAnArrayException )ArrayWrapper(DummyPoint[][]) is primitive@ArrayWrapper(DummyPoint[][]).getObjectTypeName() != 'DummyPoint'1new ArrayWrapper(DummyPoint[][]) >> FlatException ;<* >> new ArrayWrapper( DummyPoint[][][] ) :new ArrayWrapper(DummyPoint[][][]) >> NotAnArrayException +ArrayWrapper(DummyPoint[][][]) is primitiveBArrayWrapper(DummyPoint[][][]).getObjectTypeName() != 'DummyPoint'/new ArrayWrapper(Object[][][]) >> FlatExceptionArrayWrapper_Testjava/lang/Object[I[[I[[[I[Z[[Z[[[Z[B[[B[[[B[J[[J[[[J[S[[S[[[S[D[[D[[[D[C[[C[[[C[F[[F[[[F[Ljava/lang/String;[[Ljava/lang/String;[[[Ljava/lang/String;[[LDummyPoint;[[[LDummyPoint;printStackTracejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vprint(Ljava/lang/Object;)V isPrimitive()ZgetObjectTypeName()Ljava/lang/String;equals(Ljava/lang/Object;)Zflat_int()[Iappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toStringRectangularArrayExamples#getIntDoubleRectangularArrayExample()[[I#getIntTripleRectangularArrayExample()[[[I flat_boolean()[Z(Z)Ljava/lang/StringBuilder;'getBooleanDoubleRectangularArrayExample()[[Z'getBooleanTripleRectangularArrayExample()[[[Z flat_byte()[B$getByteDoubleRectangularArrayExample()[[B$getByteTripleRectangularArrayExample()[[[B flat_long()[J(J)Ljava/lang/StringBuilder;$getLongDoubleRectangularArrayExample()[[J$getLongTripleRectangularArrayExample()[[[J flat_short()[S%getShortDoubleRectangularArrayExample()[[S%getShortTripleRectangularArrayExample()[[[S flat_double()[D(D)Ljava/lang/StringBuilder;&getDoubleDoubleRectangularArrayExample()[[D&getDoubleTripleRectangularArrayExample()[[[D flat_char()[C(C)Ljava/lang/StringBuilder;$getCharDoubleRectangularArrayExample()[[C$getCharTripleRectangularArrayExample()[[[C flat_float()[F(F)Ljava/lang/StringBuilder;%getFloatDoubleRectangularArrayExample()[[F%getFloatTripleRectangularArrayExample()[[[F flat_String()[Ljava/lang/String;&getStringDoubleRectangularArrayExample()[[Ljava/lang/String;&getStringTripleRectangularArrayExample()[[[Ljava/lang/String;(II)V flat_Object()[Ljava/lang/Object;xy*getDummyPointDoubleRectangularArrayExample()[[LDummyPoint;*getDummyPointTripleRectangularArrayExample()[[[LDummyPoint;!?@!ABC*·±D EFCe¸§ L+¶¸²¶¸±D"   GF HBC»;² ¶¸ ² ¶² ¶¸ ² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶² ¶¸!² ¶²"¶¸#² ¶²$¶¸%² ¶²&¶¸'² ¶²(¶¸)² ¶²*¶¸+² ¶²,¶¸-² ¶².¶¸/² ¶²0¶¸1² ¶²2¶¸3² ¶²4¶¸5² ¶²6¶¸7² ¶²8¶¸9² ¶²:¶¸;² ¶²<¶¸=² ¶²>¶¸?² ¶²@¶¸A² ¶²B¶¸C² ¶²D¶¸E² ¶±Dn[  !&#.$1%9)A*D+L-T.W/_1g2j3r7z8}9…;<=˜? @£A«E³F¶G¾IÆJÉKÑMÙNÜOäSìTïU÷WÿXY [\]a%b(c0e8f;gCiKjNkVo^paqisqttu|w„x‡y}—~š¢ª‚­ƒµ…½†À‡ÈÐŽÓÛ‘ã’æ“î•ö–ù—› œ Ÿ ¡'£/¤2¥:©I JBCÒ÷¼ K<¢ *O„§ÿôL²F¶G»HY*·IL§M»YK·L¿²M¶²N¶G+¶Oš »YP·L¿²Q¶²R¶G+¶ST¶Uš »YV·L¿²W¶²X¶G+¶YM§N»Y[·L¿N»Y]·L¿>¢?,.Ÿ2»Y»^Y·_`¶a¶bc¶a,.¶bd¶a¶b¶e·L¿„§ÿ²f¶±(+J’•Z’ \Dv±²´µ·(º+¸,¹6»>½F¾M¿WÁ_ÃgÄsÅ}Ç…É̒ѕ͖ΠϡЫӲÔèÓîÖöØG5 ýKúÿKHJ %WZJ\ü Kü:úI LBC´ç¸gKL²h¶G»HY*·IL§M»Yi·L¿²M¶²N¶G+¶Oš »Yj·L¿²Q¶²R¶G+¶ST¶Uš »Yk·L¿²W¶²X¶G+¶YM§N»Y[·L¿N»Yl·L¿> ¢?,.Ÿ2»Y»^Y·_`¶a¶bc¶a,.¶bd¶a¶b¶e·L¿„§ÿÁ²f¶±J|„Z|\DrÞàáãæäå%ç-é5ê<ëFíNïVðbñlótõ|øý„ù…úûüš¢ØÞæG+ ÿMHJ %WZJ\ü Kü;úI NBC´ç¸mKL²n¶G»HY*·IL§M»Yo·L¿²M¶²N¶G+¶Oš »Yp·L¿²Q¶²R¶G+¶ST¶Uš »Yq·L¿²W¶²X¶G+¶YM§N»Y[·L¿N»Yr·L¿>¢?,.Ÿ2»Y»^Y·_`¶a¶bc¶a,.¶bd¶a¶b¶e·L¿„§ÿÁ²f¶±J|„Z|\Dr  %-5<FNVbl t"|%*„&…'()š,¢-Ø,Þ/æ1G+ ÿOHJ %WZJ\ü Kü;úI PBC ¼K<=¢*Tš§<„§ÿêM²s¶G»HY*·IM§N»Yt·L¿²M¶²N¶G,¶Oš »Yu·L¿²Q¶²R¶G,¶Sv¶Uš »Yw·L¿²x¶²y¶G,¶zN§:»Y[·L¿:»Y]·L¿<6¢C-3Ÿ+»Y»^Y·_`¶a¶bc¶a-3¶{¶e·L¿š§<„§ÿ½²f¶±+47J™ž¡Z™ž­\DŽ#:;< =><!A#B+D4G7E8FBHJJRKYLcNkPsQR‰T‘V™Yž^¡Z£[­\¯]¹`»aÄbôcþae gG=þQ@úÿQHJ %WZK\ü Qü5@úI RBCÈï¸|KL²}¶G»HY*·IL§M»Y~·L¿²M¶²N¶G+¶Oš »Y·L¿²Q¶²R¶G+¶Sv¶Uš »Y€·L¿²x¶²y¶G+¶zM§N»Y[·L¿N»Y·L¿>6 ¢C,3Ÿ+»Y»^Y·_`¶a¶bc¶a,3¶{¶e·L¿š§>„§ÿ¼²f¶±J|„Z|\Dzmoprust%v-x5y<zF|N~Vb€l‚t„|‡Œ„ˆ…‰Š‹šŽœ¦Ö‘àæ“î•G/ ÿSHJ %WZJ\ü Qý6@úI TBCÈ︂KL²ƒ¶G»HY*·IL§M»Y„·L¿²M¶²N¶G+¶Oš »Y…·L¿²Q¶²R¶G+¶Sv¶Uš »Y†·L¿²x¶²y¶G+¶zM§N»Y[·L¿N»Y‡·L¿>6¢C,3Ÿ+»Y»^Y·_`¶a¶bc¶a,3¶{¶e·L¿š§>„§ÿ¼²f¶±J|„Z|\Dz›ž £¡¢%¤-¦5§<¨FªN¬V­b®l°t²|µº„¶…·¸¹š¼œ½¦¾Ö¿à½æÁîÃG/ ÿUHJ %WZJ\ü Qý6@úI VBCÔù¼K<¢*‘T„§ÿóL²ˆ¶G»HY*·IL§M»Y‰·L¿²M¶²N¶G+¶Oš »YŠ·L¿²Q¶²R¶G+¶S‹¶Uš »YŒ·L¿²¶²޶G+¶M§N»Y[·L¿N»Y·L¿>¢@,3‘Ÿ2»Y»^Y·_`¶a¶bc¶a,3¶bd¶a¶b¶e·L¿„§ÿÁ²f¶± ),JŽ“–ZŽ“¡\DvÌÍÏÐ Ò)Õ,Ó-Ô7Ö?ØGÙNÚXÜ`Þhßtà~â†äŽç“ì–è—é¡ê¢ë¬î³ïêîðñøóG5 ýWúÿWHJ %WZJ\ü Wü;úI XBCµ踑KL²’¶G»HY*·IL§M»Y“·L¿²M¶²N¶G+¶Oš »Y”·L¿²Q¶²R¶G+¶S‹¶Uš »Y•·L¿²¶²޶G+¶M§N»Y[·L¿N»Y–·L¿> ¢@,3‘Ÿ2»Y»^Y·_`¶a¶bc¶a,3¶bd¶a¶b¶e·L¿„§ÿÀ²f¶±J|„Z|\Drùüýÿ%-5<F N V b lt|„…š¢Ùßç!G+ ÿYHJ %WZJ\ü Wü<úI ZBCµ踗KL²˜¶G»HY*·IL§M»Y™·L¿²M¶²N¶G+¶Oš »Yš·L¿²Q¶²R¶G+¶S‹¶Uš »Y›·L¿²¶²޶G+¶M§N»Y[·L¿N»Yœ·L¿>¢@,3‘Ÿ2»Y»^Y·_`¶a¶bc¶a,3¶bd¶a¶b¶e·L¿„§ÿÀ²f¶±J|„Z|\Dr')*,/-.%0-253<4F6N8V9b:l<t>|AF„B…CDEšI¢JÙIßLçNG+ ÿ[HJ %WZJ\ü Wü<úI \BCÕú¼ K<¢*…P„§ÿóL²¶G»HY*·IL§M»Yž·L¿²M¶²N¶G+¶Oš »YŸ·L¿²Q¶²R¶G+¶S ¶Uš »Y¡·L¿²¢¶²£¶G+¶¤M§N»Y[·L¿N»Y¥·L¿>¢A,/…”™2»Y»^Y·_`¶a¶bc¶a,/¶¦d¶a¶b¶e·L¿„§ÿÀ²f¶± ),JŽ“–ZŽ“¡\DvUVXY [)^,\-]7_?aGbNcXe`ghhti~k†mŽp“u–q—r¡s¢t¬w³xëwñzù|G5 ý]úÿ]HJ %WZJ\ü ]ü<úI ^BC¶鸧KL²¨¶G»HY*·IL§M»Y©·L¿²M¶²N¶G+¶Oš »Yª·L¿²Q¶²R¶G+¶S ¶Uš »Y«·L¿²¢¶²£¶G+¶¤M§N»Y[·L¿N»Y¬·L¿> ¢A,/…”™2»Y»^Y·_`¶a¶bc¶a,/¶¦d¶a¶b¶e·L¿„§ÿ¿²f¶±J|„Z|\Dr‚…†ˆ‹‰Š%Œ-Ž5<F’N”V•b–l˜tš|¢„ž…Ÿ ¡š¥¢¦Ú¥à¨èªG+ ÿ_HJ %WZJ\ü ]ü=úI `BC¶鸭KL²®¶G»HY*·IL§M»Y¯·L¿²M¶²N¶G+¶Oš »Y°·L¿²Q¶²R¶G+¶S ¶Uš »Y±·L¿²¢¶²£¶G+¶¤M§N»Y[·L¿N»Y²·L¿>¢A,/…”™2»Y»^Y·_`¶a¶bc¶a,/¶¦d¶a¶b¶e·L¿„§ÿ¿²f¶±J|„Z|\Dr°²³µ¸¶·%¹-»5¼<½F¿NÁVÂbÃlÅtÇ|Êτ˅ÌÍΚÒ¢ÓÚÒàÕè×G+ ÿaHJ %WZJ\ü ]ü=úI bBCÖû¼ K<¢*“V„§ÿóL²³¶G»HY*·IL§M»Y´·L¿²M¶²N¶G+¶Oš »Yµ·L¿²Q¶²R¶G+¶S¶¶Uš »Y··L¿²¸¶²¹¶G+¶ºM§N»Y[·L¿N»Y»·L¿>¢B,5‡‡—™2»Y»^Y·_`¶a¶bc¶a,5¶bd¶a¶b¶e·L¿„§ÿ¿²f¶± ),JŽ“–ZŽ“¡\Dvßàâã å)è,æ-ç7é?ëGìNíXï`ñhòtó~õ†÷Žú“ÿ–û—ü¡ý¢þ¬³ìòúG5 ýcúÿcHJ %WZJ\ü cü=úI dBC·긼KL²½¶G»HY*·IL§M»Y¾·L¿²M¶²N¶G+¶Oš »Y¿·L¿²Q¶²R¶G+¶S¶¶Uš »YÀ·L¿²¸¶²¹¶G+¶ºM§N»Y[·L¿N»YÁ·L¿> ¢B,5‡‡—™2»Y»^Y·_`¶a¶bc¶a,5¶bd¶a¶b¶e·L¿„§ÿ¾²f¶±J|„Z|\Dr %-5<FNVb l"t$|',„(…)*+š/¢0Û/á2é4G+ ÿeHJ %WZJ\ü cü>úI fBC·ê¸ÂKL²öG»HY*·IL§M»YÄ·L¿²M¶²N¶G+¶Oš »YÅ·L¿²Q¶²R¶G+¶S¶¶Uš »YÆ·L¿²¸¶²¹¶G+¶ºM§N»Y[·L¿N»YÇ·L¿>¢B,5‡‡—™2»Y»^Y·_`¶a¶bc¶a,5¶bd¶a¶b¶e·L¿„§ÿ¾²f¶±J|„Z|\Dr:<=?B@A%C-E5F<GFINKVLbMlOtQ|TY„U…VWXš\¢]Û\á_éaG+ ÿgHJ %WZJ\ü cü>úI hBCÙþ¼K<¢*‡cR„§ÿñL²ȶG»HY*·IL§M»YÉ·L¿²M¶²N¶G+¶Oš »YÊ·L¿²Q¶²R¶G+¶S˶Uš »YÌ·L¿²Ͷ²ζG+¶ÏM§N»Y[·L¿N»YзL¿>¢C,1‡c—™2»Y»^Y·_`¶a¶bc¶a,1¶Ñd¶a¶b¶e·L¿„§ÿ¾²f¶±"+.J•˜Z•£\Dvijlm"o+r.p/q9sAuIvPwZyb{j|v}€ˆ„•‰˜…™†£‡¤ˆ®‹µŒï‹õŽýG5 ýiúÿiHJ %WZJ\ü iü>úI jBC¸ë¸ÒKL²Ó¶G»HY*·IL§M»YÔ·L¿²M¶²N¶G+¶Oš »YÕ·L¿²Q¶²R¶G+¶S˶Uš »YÖ·L¿²Ͷ²ζG+¶ÏM§N»Y[·L¿N»Y×·L¿> ¢C,1‡c—™2»Y»^Y·_`¶a¶bc¶a,1¶Ñd¶a¶b¶e·L¿„§ÿ½²f¶±J|„Z|\Dr–˜™›žœ%Ÿ-¡5¢<£F¥N§V¨b©l«t­|°µ„±…²³´š¸¢¹Ü¸â»ê½G+ ÿkHJ %WZJ\ü iü?úI lBC¸ë¸ØKL²Ù¶G»HY*·IL§M»YÚ·L¿²M¶²N¶G+¶Oš »YÛ·L¿²Q¶²R¶G+¶S˶Uš »YÜ·L¿²Ͷ²ζG+¶ÏM§N»Y[·L¿N»YÝ·L¿>¢C,1‡c—™2»Y»^Y·_`¶a¶bc¶a,1¶Ñd¶a¶b¶e·L¿„§ÿ½²f¶±J|„Z|\DrÃÅÆÈËÉÊ%Ì-Î5Ï<ÐFÒNÔVÕbÖlØtÚ|Ýâ„Þ…ßàášå¢æÜåâèêêG+ ÿmHJ %WZJ\ü iü?úI nBCÔù¼K<¢*’U„§ÿóL²Þ¶G»HY*·IL§M»Yß·L¿²M¶²N¶G+¶Oš »Yà·L¿²Q¶²R¶G+¶Sá¶Uš »Yâ·L¿²ã¶²ä¶G+¶åM§N»Y[·L¿N»Yæ·L¿>¢@,4’Ÿ2»Y»^Y·_`¶a¶bc¶a,4¶çd¶a¶b¶e·L¿„§ÿÁ²f¶± ),JŽ“–ZŽ“¡\Dvñòôõ ÷)ú,ø-ù7û?ýGþNÿX`ht~† Ž “– —¡¢¬³êðøG5 ýoúÿoHJ %WZJ\ü oü;úI pBC»ì¸èKL²é¶G»HY*·IL§M»Yê·L¿²M¶²N¶G+¶Oš »Yë·L¿²Q¶²R¶G+¶Sá¶Uš »Yì·L¿²ã¶²ä¶G+¶åM§N»Y[·L¿N»Yí·L¿> ¢D,4‡‡c—™2»Y»^Y·_`¶a¶bc¶a,4¶çd¶a¶b¶e·L¿„§ÿ¼²f¶±J|„Z|\Dr!"$'%&%(-*5+<,F.N0V1b2l4t6|9>„:…;<=šA¢BÝAãDëFG- ÿqHJ %WZJ\ü oüû@úI rBCµè¸îKL²ï¶G»HY*·IL§M»Yð·L¿²M¶²N¶G+¶Oš »Yñ·L¿²Q¶²R¶G+¶Sá¶Uš »Yò·L¿²ã¶²ä¶G+¶åM§N»Y[·L¿N»Yó·L¿>¢@,4’Ÿ2»Y»^Y·_`¶a¶bc¶a,4¶çd¶a¶b¶e·L¿„§ÿÀ²f¶±J|„Z|\DrLNOQTRS%U-W5X<YF[N]V^b_latc|fk„g…hijšn¢oÙnßqçsG+ ÿsHJ %WZJ\ü oü<úI tBCÛ¼K<¢*‡cQ„§ÿðL²ô¶G»HY*·IL§M»Yõ·L¿²M¶²N¶G+¶Oš »Yö·L¿²Q¶²R¶G+¶S÷¶Uš »Yø·L¿²ù¶²ú¶G+¶ûM§N»Y[·L¿N»Yü·L¿>¢D,0‡c—™2»Y»^Y·_`¶a¶bc¶a,0¶ýd¶a¶b¶e·L¿„§ÿ½²f¶±#,/J‘–™Z‘–¤\Dv{|~#,„/‚0ƒ:…B‡JˆQ‰[‹ckŽw‘‰“‘––›™—š˜¤™¥š¯¶žñ÷ ÿ¢G5 ýuúÿuHJ %WZJ\ü uü?úI vBC¿ð¸þKL²ÿ¶G»HY*·IL§M»Y·L¿²M¶²N¶G+¶Oš»Y·L¿²Q¶²R¶G+¶S÷¶Uš»Y·L¿²ù¶²ú¶G+¶ûM§N»Y[·L¿N»Y·L¿> ¢D,0‡c—™2»Y»^Y·_`¶a¶bc¶a,0¶ýd¶a¶b¶e·L¿„§ÿ¼²f¶±J„‡Z„’\Dr¨ª«­°®¯&±.³6´=µH·P¹Xºd»o½w¿„LJÈĒœƞʦËáÊçÍïÏG- ÿwHJ !&WZJ\ü uüû@úI xBCÀñ¸KL²¶G»HY*·IL§M»Y·L¿²M¶²N¶G+¶Oš»Y·L¿²Q¶²R¶G+¶S÷¶Uš»Y·L¿²ù¶²ú¶G+¶ûM§N»Y[·L¿N»Y ·L¿>¢D,0‡c•™2»Y»^Y·_`¶a¶bc¶a,0¶ýd¶a¶b¶e·L¿„§ÿ¼²f¶±J€…ˆZ€…“\DrÕרÚÝÛÜ'Þ/à7á>âIäQæYçeèpêxì€ï…ôˆð‰ñ“ò”óŸ÷§øâ÷èúðüG- ÿyHJ !&WZJ\ü uüû@úI zBC*½ K<¢ *»^Y·_ ¶a¶b¶eS„§ÿáL² ¶G»HY*·IL§M»Y ·L¿²M¶²N¶G+¶O™»Y·L¿²¶²R¶G+¶S¶Uš»Y·L¿²¶²¶G+¶M§N»Y[·L¿N»Y·L¿>¢U,2»^Y·_ ¶a¶b¶e¶Uš2»Y»^Y·_`¶a¶bc¶a,2¶ad¶a¶b¶e·L¿„§ÿ¬²f¶±4=@J©®±Z©®¼\Dv) + 4 =@ ALT\cnwŒ— ©!®&±"²#¼$½%È(Ï)(!+)-G7 ý{ú!ÿ{HJ !(YZJ\ü {üûPúI |BCÔ¸KL²¶G»HY*·IL§M»Y·L¿²M¶²N¶G+¶O™»Y·L¿²Q¶²R¶G+¶S¶Uš»Y·L¿²¶²¶G+¶M§N»Y[·L¿N»Y·L¿> ¢U,2»^Y·_ ¶a¶b¶e¶Uš2»Y»^Y·_`¶a¶bc¶a,2¶ad¶a¶b¶e·L¿„§ÿ«²f¶±Jƒˆ‹Zƒˆ–\Dr3568;9:'</>7?>@IBQDYEfFqHzJƒMˆR‹NŒO–P—Q¢UªVöUüXZG- ÿ}HJ !'YZJ\ü {üûQúI ~BCÔ¸KL²¶G»HY*·IL§M»Y·L¿²M¶²N¶G+¶O™»Y·L¿²Q¶²R¶G+¶S¶Uš»Y ·L¿²¶²¶G+¶M§N»Y[·L¿N»Y!·L¿>¢U,2»^Y·_ ¶a¶b¶e¶Uš2»Y»^Y·_`¶a¶bc¶a,2¶ad¶a¶b¶e·L¿„§ÿ«²f¶±Jƒˆ‹Zƒˆ–\Dr`bcehfg'i/k7l>mIoQqYrfsquzwƒzˆ‹{Œ|–}—~¢‚ªƒö‚ü…‡G- ÿHJ !'YZJ\ü {üûQúI €BC#½"K<¢*»"Y·#S„§ÿìL²$¶G»HY*·IL§M»Y%·L¿²M¶²N¶G+¶O™»Y&·L¿²¶²R¶G+¶S'¶Uš»Y(·L¿²)¶²*¶G+¶+À,M§N»Y.·L¿N»Y/·L¿6¢S,2N-´0  -´1Ÿ6»Y»^Y·_`¶a¶b2¶a-´0¶bd¶a¶b¶e·L¿„§ÿ­²f¶±)25Jž¦©-ž¦µ\Dz’ “)•2˜5–6—A™I›QœXcŸl¡t¢£Œ¥•§žª¦¯©«ª¬µ­¶®Á²Ê³Ï´²¶"¸GJ ý,úÿ,HJ !(\-K\ü ,ýÿ,H,"2ùI BCð ¸3KL²4¶G»HY*·IL§M»Y5·L¿²M¶²N¶G+¶O™»Y6·L¿²¶²R¶G+¶S'¶Uš»Y7·L¿²)¶²*¶G+¶+À,M§N»Y.·L¿N»Y8·L¿6 ¢S,2N-´0  -´1Ÿ6»Y»^Y·_`¶a¶b2¶a-´0¶bd¶a¶b¶e·L¿„§ÿ¬²f¶±J„Œ-„Œ›\Dv¾ÀÁÃÆÄÅ'Ç/É7Ê>ËIÍRÏZÐgÑrÓ{Õ„ØŒÝÙÚ›Ûœܧà±á¶âûàä æG@ ÿ‚HJ !(\-K\ü ,ýÿ‚H,"2ùI ƒBCð ¸9KL²:¶G»HY*·IL§M»Y;·L¿²M¶²N¶G+¶O™»Y<·L¿²¶²R¶G+¶S'¶Uš»Y=·L¿²)¶²*¶G+¶+À,M§N»Y.·L¿N»Y>·L¿6¢S,2N-´0  -´1Ÿ6»Y»^Y·_`¶a¶b2¶a-´0¶bd¶a¶b¶e·L¿„§ÿ¬²f¶±J„Œ-„Œ›\Dvìîïñôòó'õ/÷7ø>ùIûRýZþgÿr{„Œ › œ §±¶û G@ ÿ„HJ !(\-K\ü ,ýÿ„H,"2ùI…†rJava/src/callback.h0000644000175100001440000000065015133274032014030 0ustar hornikusers#ifndef __CALLBACK_H__ #define __CALLBACK_H__ #ifdef ENABLE_JRICB extern int RJava_has_control; #endif #define RJavaActivity 16 /* all IPC messages are long-alligned */ #define IPCC_LOCK_REQUEST 1 #define IPCC_LOCK_GRANTED 2 /* reponse on IPCC_LOCK_REQUEST */ #define IPCC_CLEAR_LOCK 3 #define IPCC_CALL_REQUEST 4 /* pars: */ #define IPCC_CONTROL_ADDR 5 /* ipc: request, res: */ #endif rJava/src/rJava.h0000644000175100001440000002126415133274032013343 0ustar hornikusers#ifndef __RJAVA_H__ #define __RJAVA_H__ #define RJAVA_VER 0x01000e /* rJava v1.0-14 */ /* important changes between versions: 3.0 - adds compiler 2.0 1.0 - custom package class loaders 0.9 - rectangular arrays, flattening, import (really introduced in later 0.8 versions but they broke the API compatibility so 0.9 attempts to fix that) 0.8 - new exception handling using Exception condition 0.7 - new reflection code, new REngine API (JRI) 0.6 - adds serialization, (auto-)deserialization and cache 0.5 - integrates JRI, adds callbacks and class-loader 0.4 - includes JRI 0.3 - uses EXTPTR in jobj slot, adds finalizers 0.2 - uses S4 classes 0.1 - first public release */ #include #include #include #include #include #include #if (R_VERSION >= R_Version(4,6,0)) #include #else #include #endif /* R API compatibility re-mapping */ #if (R_VERSION >= R_Version(2,0,0)) /* EXTPTR */ #ifdef EXTPTR_PTR #undef EXTPTR_PTR #endif #define EXTPTR_PTR(X) R_ExternalPtrAddr(X) #ifdef EXTPTR_PROT #undef EXTPTR_PROT #endif #define EXTPTR_PROT(X) R_ExternalPtrProtected(X) #ifdef EXTPTR_TAG #undef EXTPTR_TAG #endif #define EXTPTR_TAG(X) R_ExternalPtrTag(X) #endif /* flags used in function declarations: HIDE - hidden (used internally in rJava only) REP - R Entry Point - .C convention REPE - R Entry Point - .External convention REPC - R Entry Point - .Call convention - inline and/or hide functions that are not externally visible - automatically generate symbol registration table */ #ifdef ONEFILE #ifdef HAVE_STATIC_INLINE #define HIDE static inline #else #define HIDE static #endif #else #define HIDE #endif #define REP #define REPE #define REPC #if defined WIN32 && ! defined Win32 #define Win32 #endif #if defined Win32 && ! defined WIN32 #define WIN32 #endif #include "config.h" /* R 4.0.1 broke EXTPTR_PTR ABI so re-map it to safety at the small expense of speed */ #ifdef EXTPTR_PTR #undef EXTPTR_PTR #endif #define EXTPTR_PTR(X) R_ExternalPtrAddr(X) /* PROT/TAG are safe so far, but just to make sure ... */ #ifdef EXTPTR_PROT #undef EXTPTR_PROT #endif #define EXTPTR_PROT(X) R_ExternalPtrProtected(X) #ifdef EXTPTR_TAG #undef EXTPTR_TAG #endif #define EXTPTR_TAG(X) R_ExternalPtrTag(X) #ifdef MEMPROF #include #include extern FILE* memprof_f; #define _mp(X) X #define MEM_PROF_OUT(X ...) { if (memprof_f) { long t = time(0); fprintf(memprof_f, "<%08x> %x:%02d ", (int) env, t/60, t%60); fprintf(memprof_f, X); }; } #else #define _mp(X) #endif /* debugging output (enable with -DRJ_DEBUG) */ #ifdef RJ_DEBUG void rjprintf(char *fmt, ...); /* in Rglue.c */ /* we can't assume ISO C99 (variadic macros), so we have to use one more level of wrappers */ #define _dbg(X) X #else #define _dbg(X) #endif /* profiling */ #ifdef RJ_PROFILE #define profStart() profilerTime=time_ms() #define _prof(X) X long time_ms(void); /* those are acutally in Rglue.c */ void profReport(char *fmt, ...); #else #define profStart() #define _prof(X) #endif #ifdef ENABLE_JRICB #define BEGIN_RJAVA_CALL { int save_in_RJava = RJava_has_control; RJava_has_control=1; { #define END_RJAVA_CALL }; RJava_has_control = save_in_RJava; } #else #define BEGIN_RJAVA_CALL { #define END_RJAVA_CALL }; #endif /* define mkCharUTF8 in a compatible fashion NOTE: those should NOT be used anymore since native Java strings use UTF-16 so use only in cases where UTF8 is required */ #if R_VERSION < R_Version(2,7,0) #define mkCharUTF8(X) mkChar(X) #define CHAR_UTF8(X) CHAR(X) #else #define mkCharUTF8(X) rj_mkCharUTF8(X) #define CHAR_UTF8(X) rj_char_utf8(X) extern SEXP rj_mkCharUTF8(const char *); /* rjstring.c */ extern const char *rj_char_utf8(SEXP); /* Rglue.c */ #endif /* signatures are stored in a local buffer if they fit. Only if they don't fit a heap buffer is allocated and used. */ typedef struct sig_buffer { char *sig; /* if sig doesn't point to sigbuf then it's allocated from heap */ int maxsig, len; char sigbuf[256]; /* default size of the local buffer (on the stack) */ } sig_buffer_t; /* in callbacks.c */ extern int RJava_has_control; /* in rJava.c */ extern JNIEnv *eenv; /* should NOT be used since not thread-safe; use getJNIEnv instead */ HIDE JNIEnv* getJNIEnv(void); HIDE void ckx(JNIEnv *env); HIDE void clx(JNIEnv *env); HIDE SEXP getStringArrayCont(jarray) ; HIDE jarray getSimpleClassNames( jobject, jboolean ) ; HIDE SEXP getSimpleClassNames_asSEXP( jobject, jboolean ) ; REPC SEXP RgetSimpleClassNames( SEXP, SEXP ); /* in init.c */ extern JavaVM *jvm; extern int rJava_initialized; #define JVM_STATE_NONE 0 /* no JVM */ #define JVM_STATE_CREATED 1 /* JVM was created by us */ #define JVM_STATE_ATTACHED 2 /* we attached to another JVM */ #define JVM_STATE_DEAD 4 /* set when Java exit handler was called */ #define JVM_STATE_DESTROYED 8 /* JVM was destroyed */ extern int rJava_JVM_state; extern int java_is_dead; extern jclass javaStringClass; extern jclass javaObjectClass; extern jclass javaClassClass; extern jclass javaFieldClass; extern jclass rj_RJavaTools_Class ; extern jmethodID mid_forName; extern jmethodID mid_getName; extern jmethodID mid_getSuperclass; extern jmethodID mid_getType; extern jmethodID mid_getField; extern jmethodID mid_rj_getSimpleClassNames; extern jmethodID mid_RJavaTools_getFieldTypeName; /* RJavaImport */ extern jclass rj_RJavaImport_Class ; extern jmethodID mid_RJavaImport_getKnownClasses ; extern jmethodID mid_RJavaImport_lookup ; extern jmethodID mid_RJavaImport_exists ; HIDE void init_rJava(void); /* in otables.c */ // turn this for debugging in otables.c // #define LOOKUP_DEBUG REPC SEXP newRJavaLookupTable(SEXP) ; HIDE SEXP R_getUnboundValue(void) ; HIDE SEXP rJavaLookupTable_objects(R_ObjectTable *) ; HIDE SEXP rJavaLookupTable_assign(const char * const, SEXP, R_ObjectTable * ) ; HIDE Rboolean rJavaLookupTable_canCache(const char * const, R_ObjectTable *) ; HIDE int rJavaLookupTable_remove(const char * const, R_ObjectTable *) ; HIDE SEXP rJavaLookupTable_get(const char * const, Rboolean *, R_ObjectTable *) ; HIDE Rboolean rJavaLookupTable_exists(const char * const, Rboolean *, R_ObjectTable *) ; HIDE jobject getImporterReference(R_ObjectTable *) ; HIDE SEXP getKnownClasses( R_ObjectTable * ); HIDE SEXP classNameLookup( R_ObjectTable *, const char * const ) ; HIDE Rboolean classNameLookupExists(R_ObjectTable *, const char * const ) ; /* in loader.c */ extern jclass clClassLoader; extern jobject oClassLoader; /* in Rglue */ HIDE SEXP j2SEXP(JNIEnv *env, jobject o, int releaseLocal); HIDE SEXP new_jobjRef(JNIEnv *env, jobject o, const char *klass); HIDE jvalue R1par2jvalue(JNIEnv *env, SEXP par, sig_buffer_t *sig, jobject *otr); HIDE void init_sigbuf(sig_buffer_t *sb); HIDE void done_sigbuf(sig_buffer_t *sb); HIDE SEXP getName( JNIEnv *, jobject/*Class*/ ); HIDE SEXP new_jclassName(JNIEnv *, jobject/*Class*/ ) ; /* in tools.c */ HIDE jstring callToString(JNIEnv *env, jobject o); /* in callJNI */ HIDE jobject createObject(JNIEnv *env, const char *class, const char *sig, jvalue *par, int silent, jobject loader); HIDE jclass findClass(JNIEnv *env, const char *class, jobject loader); HIDE jclass objectClass(JNIEnv *env, jobject o); HIDE jdoubleArray newDoubleArray(JNIEnv *env, double *cont, int len); HIDE jintArray newIntArray(JNIEnv *env, int *cont, int len); HIDE jbooleanArray newBooleanArrayI(JNIEnv *env, int *cont, int len); HIDE jstring newString(JNIEnv *env, const char *cont); HIDE jstring newString16(JNIEnv *env, const jchar *cont, jsize len); HIDE jcharArray newCharArrayI(JNIEnv *env, int *cont, int len); HIDE jshortArray newShortArrayI(JNIEnv *env, int *cont, int len); HIDE jfloatArray newFloatArrayD(JNIEnv *env, double *cont, int len); HIDE jlongArray newLongArrayD(JNIEnv *env, double *cont, int len); HIDE jintArray newByteArray(JNIEnv *env, void *cont, int len); HIDE jbyteArray newByteArrayI(JNIEnv *env, int *cont, int len); HIDE jobject makeGlobal(JNIEnv *env, jobject o); HIDE void releaseObject(JNIEnv *env, jobject o); HIDE void releaseGlobal(JNIEnv *env, jobject o); HIDE void printObject(JNIEnv *env, jobject o); HIDE int checkExceptionsX(JNIEnv *env, int silent); HIDE int initClassLoader(JNIEnv *env, jobject cl); HIDE void deserializeSEXP(SEXP o); /* this is a hook for de-serialization */ #define jverify(X) if (X && TYPEOF(X) == EXTPTRSXP && EXTPTR_PROT(X) != R_NilValue) deserializeSEXP(X) #define IS_JOBJREF(obj) ( inherits(obj, "jobjRef") || inherits(obj, "jarrayRef") || inherits(obj,"jrectRef") ) #define IS_JARRAYREF(obj) ( inherits(obj, "jobjRef") || inherits(obj, "jarrayRef") || inherits(obj, "jrectRef") ) #define IS_JRECTREF(obj) ( inherits(obj,"jrectRef") ) #endif rJava/src/registration.c0000644000175100001440000000110415133274032014774 0ustar hornikusers#include #include /* only to avoid NOTEs from broken checks, never called */ int dummy__(void) { return R_registerRoutines(0, 0, 0, 0, 0); } static DllInfo *dll; /* registration is done in R code, so it has to have a way to disable dynamic symbols when done */ SEXP useDynamicSymbols(SEXP sDo) { if (dll) { R_useDynamicSymbols(dll, asInteger(sDo)); return ScalarLogical(1); } return ScalarLogical(0); } /* record our dll so we can call useDynamicSymbols() later */ void R_init_rJava(DllInfo *dll_) { dll = dll_; } rJava/src/rJava.c0000644000175100001440000001327615133274032013342 0ustar hornikusers#include #include #include #include "rJava.h" #include #include /* determine whether eenv cache should be used (has no effect if JNI_CACHE is not set) */ int use_eenv = 1; /* cached environment. Do NOT use directly! Always use getJNIEnv()! */ JNIEnv *eenv; static SEXP getCurrentCall(void) { SEXP cexp, sys_calls = PROTECT(install("sys.calls")); cexp = PROTECT(lang1(sys_calls)); SEXP cl = eval(cexp, R_GetCurrentEnv()); UNPROTECT(2); /* find the last call */ if (TYPEOF(cl) != LISTSXP) return R_NilValue; while (cl != R_NilValue) { if (CDR(cl) == R_NilValue && CAR(cl) != R_NilValue) return CAR(cl); cl = CDR(cl); } return R_NilValue; /* (LENGTH(cl) > 0) ? VECTOR_ELT(cl, 0) : R_NilValue; */ } /** throw an exception using R condition code. * @param msg - message string * @param jobj - jobjRef object of the exception * @param clazzes - simple name of all the classes in the inheritance tree of the exception plus "error" and "condition" */ HIDE void throwR(SEXP msg, SEXP jobj, SEXP clazzes) { SEXP cond = PROTECT(allocVector(VECSXP, 3)); SEXP names = PROTECT(allocVector(STRSXP, 3)); SET_VECTOR_ELT(cond, 0, msg); SET_VECTOR_ELT(cond, 1, getCurrentCall()); SET_VECTOR_ELT(cond, 2, jobj); SET_STRING_ELT(names, 0, mkChar("message")); SET_STRING_ELT(names, 1, mkChar("call")); SET_STRING_ELT(names, 2, mkChar("jobj")); setAttrib(cond, R_NamesSymbol, names); setAttrib(cond, R_ClassSymbol, clazzes); UNPROTECT(1); /* names */ eval(PROTECT(LCONS(install("stop"), PROTECT(CONS(cond, R_NilValue)))), R_GlobalEnv); UNPROTECT(3); /* cond + eval-pars */ } /* check for exceptions and throw them to R level */ HIDE void ckx(JNIEnv *env) { SEXP xr, xobj, msg = 0, xclass = 0; /* note: we don't bother counting protections because we never return */ jthrowable x = 0; if (env && !(x = (*env)->ExceptionOccurred(env))) return; if (!env) { env = getJNIEnv(); if (!env) error("Unable to retrieve JVM environment."); ckx(env); return; } /* env is valid and an exception occurred */ /* we create the jobj first, because the exception may in theory disappear after being cleared, yet this can be (also in theory) risky as it uses further JNI calls ... */ xobj = PROTECT(j2SEXP(env, x, 0)); if (!rj_RJavaTools_Class) { REprintf("ERROR: Java exception occurred during rJava bootstrap - see stderr for Java stack trace.\n"); (*env)->ExceptionDescribe(env); } (*env)->ExceptionClear(env); /* grab the list of class names (without package path) */ SEXP clazzes = PROTECT( rj_RJavaTools_Class ? getSimpleClassNames_asSEXP( (jobject)x, (jboolean)1 ) : R_NilValue ); /* ok, now this is a critical part that we do manually to avoid recursion */ { jclass cls = (*env)->GetObjectClass(env, x); if (cls) { jstring cname; jmethodID mid = (*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); if (mid) { jstring s = (jstring)(*env)->CallObjectMethod(env, x, mid); if (s) { const char *c = (*env)->GetStringUTFChars(env, s, 0); if (c) { msg = PROTECT(mkString(c)); (*env)->ReleaseStringUTFChars(env, s, c); } } } /* beside toString() we also need to call getName() on cls to get the subclass */ cname = (jstring) (*env)->CallObjectMethod(env, cls, mid_getName); if (cname) { const char *c = (*env)->GetStringUTFChars(env, cname, 0); if (c) { /* convert full class name to JNI notation */ char *cn = strdup(c), *d = cn; while (*d) { if (*d == '.') *d = '/'; d++; } xclass = PROTECT(mkString(cn)); free(cn); (*env)->ReleaseStringUTFChars(env, cname, c); } (*env)->DeleteLocalRef(env, cname); } if ((*env)->ExceptionOccurred(env)) (*env)->ExceptionClear(env); (*env)->DeleteLocalRef(env, cls); } else (*env)->ExceptionClear(env); if (!msg) msg = PROTECT(mkString("Java Exception ")); } /* delete the local reference to the exception (jobjRef has a global copy) */ (*env)->DeleteLocalRef(env, x); /* construct the jobjRef */ xr = PROTECT(NEW_OBJECT(PROTECT(MAKE_CLASS("jobjRef")))); if (!xclass) xclass = PROTECT(mkString("java/lang/Throwable")); if (inherits(xr, "jobjRef")) { SET_SLOT(xr, install("jclass"), xclass); SET_SLOT(xr, install("jobj"), xobj); } /* and off to R .. (we're keeping xr and clazzes protected) */ throwR(msg, xr, clazzes); /* should not return, but just in case ... */ /* protect stack: xobj, clz, msg, xcl, xr + mk_class */ /* (it may confuse the UP checker since the order does vary by path, but the count is the same) */ UNPROTECT(6); } /* clear any pending exceptions */ HIDE void clx(JNIEnv *env) { if (env && (*env)->ExceptionOccurred(env)) (*env)->ExceptionClear(env); } #ifdef JNI_CACHE HIDE JNIEnv *getJNIEnvSafe(void); HIDE JNIEnv *getJNIEnv(void) { return (use_eenv)?eenv:getJNIEnvSafe(); } HIDE JNIEnv *getJNIEnvSafe(void) #else HIDE JNIEnv *getJNIEnv(void) #endif { JNIEnv *env; jsize l; jint res; if (!jvm) { /* we're hoping that the JVM pointer won't change :P we fetch it just once */ res = JNI_GetCreatedJavaVMs(&jvm, 1, &l); if (res != 0) { error("JNI_GetCreatedJavaVMs failed! (result:%d)",(int)res); return 0; } if (l < 1) error("No running JVM detected. Maybe .jinit() would help."); if (!rJava_initialized) error("rJava was called from a running JVM without .jinit()."); } res = (*jvm)->AttachCurrentThread(jvm, (void**) &env, 0); if (res!=0) { error("AttachCurrentThread failed! (result:%d)", (int)res); return 0; } if (env && !eenv) eenv=env; return env; } REP void RuseJNICache(int *flag) { if (flag) use_eenv=*flag; } rJava/src/init.c0000644000175100001440000006604415133274032013243 0ustar hornikusers#include "rJava.h" #include #include #include /* global variables */ JavaVM *jvm; /* this will be set when Java tries to exit() but we carry on */ int java_is_dead = 0; /* current JVM state */ int rJava_JVM_state = JVM_STATE_NONE; /* cached, global objects */ jclass javaStringClass; jclass javaObjectClass; jclass javaClassClass; jclass javaFieldClass; /* cached, global method IDs */ jmethodID mid_forName; jmethodID mid_getName; jmethodID mid_getSuperclass; jmethodID mid_getType; jmethodID mid_getField; /* internal classes and methods */ jclass rj_RJavaTools_Class = (jclass)0; jmethodID mid_rj_getSimpleClassNames = (jmethodID)0 ; jmethodID mid_RJavaTools_getFieldTypeName = (jmethodID)0 ; jclass rj_RJavaImport_Class = (jclass)0; jmethodID mid_RJavaImport_getKnownClasses = (jmethodID)0 ; jmethodID mid_RJavaImport_lookup = (jmethodID)0 ; jmethodID mid_RJavaImport_exists = (jmethodID)0 ; int rJava_initialized = 0; static int jvm_opts=0; static char **jvm_optv=0; #ifdef JNI_VERSION_1_2 static JavaVMOption *vm_options; static JavaVMInitArgs vm_args; #else #error "Java/JNI 1.2 or higher is required!" #endif #define H_OUT 1 #define H_EXIT 2 #ifdef Win32 /* the hooks are reportedly causing problems on Windows, so disable them by default */ static int default_hooks = 0; #else static int default_hooks = H_OUT|H_EXIT; #endif static int JNICALL vfprintf_hook(FILE *f, const char *fmt, va_list ap) { #ifdef Win32 /* on Windows f doesn't refer to neither stderr nor stdout, so we have no way of finding out the target, so we assume stderr */ REvprintf(fmt, ap); return 0; #else if (f==stderr) { REvprintf(fmt, ap); return 0; } else if (f==stdout) { Rvprintf(fmt, ap); return 0; } return vfprintf(f, fmt, ap); #endif } static void JNICALL exit_hook(int status) { /* REprintf("\nJava requested System.exit(%d), trying to raise R error - this may crash if Java is in a bad state.\n", status); */ java_is_dead = 1; rJava_JVM_state = JVM_STATE_DEAD; Rf_error("Java called System.exit(%d) requesting R to quit - trying to recover", status); /* FIXME: we could do something smart here such as running a call-back into R ... jump into R event loop ... at any rate we cannot return, but we don't want to kill R ... */ exit(status); } int existingJVMs(void) { jsize vms = 0; JavaVM *jvms[32]; return (JNI_GetCreatedJavaVMs(jvms, 32, &vms) >= 0) ? vms : 0; } /* in reality WIN64 implies WIN32 but to make sure ... */ #if defined(_WIN64) || defined(_WIN32) #include #include #endif /* disableGuardPages - nonzero when the VM should be initialized with experimental option to disable primordial thread guard pages. If the VM fails to initialize for any reason, including because it does not support this option, -2 is returned; this feature is relevant to Oracle JVM version 10 and above on Linux; only used with JVM_STACK_WORKAROUND */ static int initJVM(const char *user_classpath, int opts, char **optv, int hooks, int disableGuardPages) { int total_num_properties, propNum = 0, add_Xss = 1; jint res; char *classpath; if(!user_classpath) /* use the CLASSPATH environment variable as default */ user_classpath = getenv("CLASSPATH"); if(!user_classpath) user_classpath = ""; vm_args.version = JNI_VERSION_1_2; if(JNI_GetDefaultJavaVMInitArgs(&vm_args) != JNI_OK) { error("JNI 1.2 or higher is required"); return -1; } vm_args.version = JNI_VERSION_1_2; /* should we do that or keep the default? */ /* quick pre-check whether there is a chance that primordial thread guard pages may be disabled */ #ifndef JNI_VERSION_10 /* the binary can be compiled against older JVM includes, but run with a new JDK, so we cannot assume absence of the define to mean anything. Hence we define it according to the current specs. */ #define JNI_VERSION_10 0x000a0000 #endif if (disableGuardPages) { vm_args.version = JNI_VERSION_10; if(JNI_GetDefaultJavaVMInitArgs(&vm_args) != JNI_OK) return -2; vm_args.version = JNI_VERSION_10; /* probably not needed */ } /* leave room for class.path, and optional jni args */ total_num_properties = 8 + opts; vm_options = (JavaVMOption *) calloc(total_num_properties, sizeof(JavaVMOption)); vm_args.options = vm_options; vm_args.ignoreUnrecognized = disableGuardPages ? JNI_FALSE : JNI_TRUE; classpath = (char*) calloc(24 + strlen(user_classpath), sizeof(char)); if (!classpath) error("Cannot allocate memory for classpath"); snprintf(classpath, (24 + strlen(user_classpath)) * sizeof(char), "-Djava.class.path=%s", user_classpath); vm_options[propNum++].optionString = classpath; /* print JNI-related messages */ /* vm_options[propNum++].optionString = "-verbose:class,jni"; */ if (optv) { int i = 0; while (i < opts) { if (optv[i]) { vm_options[propNum++].optionString = optv[i]; /* we look for -Xss since we want to raise it to avoid overflows, but not if the user already supplied it */ if (!strncmp(optv[i], "-Xss", 4)) add_Xss = 0; } i++; } } if (hooks&H_OUT) { vm_options[propNum].optionString = "vfprintf"; vm_options[propNum++].extraInfo = vfprintf_hook; } if (hooks&H_EXIT) { vm_options[propNum].optionString = "exit"; vm_options[propNum++].extraInfo = exit_hook; } if (disableGuardPages) { vm_options[propNum++].optionString = "-XX:+UnlockExperimentalVMOptions"; vm_options[propNum++].optionString = "-XX:+DisablePrimordialThreadGuardPages"; } if (add_Xss) vm_options[propNum++].optionString = "-Xss2m"; vm_args.nOptions = propNum; /* Create the Java VM */ res = JNI_CreateJavaVM(&jvm,(void **)&eenv, &vm_args); if (disableGuardPages && (res != 0 || !eenv)) return -2; /* perhaps this VM does not allow disabling guard pages */ if (res != 0) error("Cannot create Java virtual machine (JNI_CreateJavaVM returned %ld)", (long int) res); if (!eenv) error("Cannot obtain JVM environment"); rJava_JVM_state = JVM_STATE_CREATED; #if defined(_WIN64) || defined(_WIN32) _setmode(0, _O_TEXT); #endif return 0; } #ifdef THREADS #include #ifdef XXDARWIN #include #include #include #endif pthread_t initJVMpt; pthread_mutex_t initMutex = PTHREAD_MUTEX_INITIALIZER; int thInitResult = 0; int initAWT = 0; static void *initJVMthread(void *classpath) { int ws; jclass c; JNIEnv *lenv; thInitResult=initJVM((char*)classpath, jvm_opts, jvm_optv, default_hooks, 0); if (thInitResult) return 0; rJava_JVM_state = JVM_STATE_CREATED; init_rJava(); lenv = eenv; /* we make a local copy before unlocking just in case someone messes with it before we can use it */ _dbg(rjprintf("initJVMthread: unlocking\n")); pthread_mutex_unlock(&initMutex); if (initAWT) { _dbg(rjprintf("initJVMthread: get AWT class\n")); /* we are still on the same thread, so we can safely use eenv */ c = (*lenv)->FindClass(lenv, "java/awt/Frame"); } _dbg(rjprintf("initJVMthread: returning from the init thread.\n")); return 0; } #endif /* initialize internal structures/variables of rJava. The JVM initialization was performed before (but may have failed) */ HIDE void init_rJava(void) { jclass c; JNIEnv *env = getJNIEnv(); if (!env) return; /* initJVMfailed, so we cannot proceed */ /* get global classes. we make the references explicitly global (although unloading of String/Object is more than unlikely) */ c=(*env)->FindClass(env, "java/lang/String"); if (!c) error("unable to find the basic String class"); javaStringClass=(*env)->NewGlobalRef(env, c); if (!javaStringClass) error("unable to create a global reference to the basic String class"); (*env)->DeleteLocalRef(env, c); c=(*env)->FindClass(env, "java/lang/Object"); if (!c) error("unable to find the basic Object class"); javaObjectClass=(*env)->NewGlobalRef(env, c); if (!javaObjectClass) error("unable to create a global reference to the basic Object class"); (*env)->DeleteLocalRef(env, c); c = (*env)->FindClass(env, "java/lang/Class"); if (!c) error("unable to find the basic Class class"); javaClassClass=(*env)->NewGlobalRef(env, c); if (!javaClassClass) error("unable to create a global reference to the basic Class class"); (*env)->DeleteLocalRef(env, c); c = (*env)->FindClass(env, "java/lang/reflect/Field"); if (!c) error("unable to find the basic Field class"); javaFieldClass=(*env)->NewGlobalRef(env, c); if (!javaFieldClass) error("unable to create a global reference to the basic Class class"); (*env)->DeleteLocalRef(env, c); mid_forName = (*env)->GetStaticMethodID(env, javaClassClass, "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"); if (!mid_forName) error("cannot obtain Class.forName method ID"); mid_getName = (*env)->GetMethodID(env, javaClassClass, "getName", "()Ljava/lang/String;"); if (!mid_getName) error("cannot obtain Class.getName method ID"); mid_getSuperclass =(*env)->GetMethodID(env, javaClassClass, "getSuperclass", "()Ljava/lang/Class;"); if (!mid_getSuperclass) error("cannot obtain Class.getSuperclass method ID"); mid_getField = (*env)->GetMethodID(env, javaClassClass, "getField", "(Ljava/lang/String;)Ljava/lang/reflect/Field;"); if (!mid_getField) error("cannot obtain Class.getField method ID"); mid_getType = (*env)->GetMethodID(env, javaFieldClass, "getType", "()Ljava/lang/Class;"); if (!mid_getType) error("cannot obtain Field.getType method ID"); rJava_initialized = 1; } /* disableGuardPages - attempt to disable primordial thread guard pages, see initJVM(); if the VM fails to initialize for any reason including that disabling is not supported, NULL (C level) is returned; disableGuardPages is ignored with THREADS. */ static SEXP RinitJVM_real(SEXP par, int disableGuardPages) { const char *c=0; SEXP e=CADR(par); int r=0; JavaVM *jvms[32]; jsize vms=0; jvm_opts=0; jvm_optv=0; if (TYPEOF(e)==STRSXP && LENGTH(e)>0) c=CHAR(STRING_ELT(e,0)); e = CADDR(par); if (TYPEOF(e)==STRSXP && LENGTH(e)>0) { int len = LENGTH(e), add_xrs = 1, joi = 0; jvm_optv = (char**)malloc(sizeof(char*) * (len + 3)); if (!jvm_optv) Rf_error("Cannot allocate options buffer - out of memory"); #ifdef USE_HEADLESS_INIT /* prepend headless so the user can still override it */ jvm_optv[jvm_opts++] = "-Djava.awt.headless=true"; #endif while (joi < len) { jvm_optv[jvm_opts] = strdup(CHAR(STRING_ELT(e, joi++))); #ifdef HAVE_XRS /* check if Xrs is already used */ if (!strcmp(jvm_optv[jvm_opts], "-Xrs")) add_xrs = 0; #endif jvm_opts++; } #ifdef HAVE_XRS if (add_xrs) jvm_optv[jvm_opts++] = "-Xrs"; #endif } else { #ifdef USE_HEADLESS_INIT jvm_optv = (char**)malloc(sizeof(char*) * 3); if (!jvm_optv) Rf_error("Cannot allocate options buffer - out of memory"); jvm_optv[jvm_opts++] = "-Djava.awt.headless=true"; #endif #ifdef HAVE_XRS if (!jvm_optv) jvm_optv = (char**)malloc(sizeof(char*) * 2); if (!jvm_optv) Rf_error("Cannot allocate options buffer - out of memory"); jvm_optv[jvm_opts++] = "-Xrs"; #endif } if (jvm_opts) jvm_optv[jvm_opts] = 0; r=JNI_GetCreatedJavaVMs(jvms, 32, &vms); if (r) { Rf_error("JNI_GetCreatedJavaVMs returned %d\n", r); } else { if (vms>0) { int i=0; _dbg(rjprintf("RinitJVM: Total %d JVMs found. Trying to attach the current thread.\n", (int)vms)); while (iAttachCurrentThread(jvms[i], (void**)&eenv, NULL)) { /* attaching our own created JVM doesn't change it to attached */ if (rJava_JVM_state != JVM_STATE_CREATED) rJava_JVM_state = JVM_STATE_ATTACHED; _dbg(rjprintf("RinitJVM: Attached to existing JVM #%d.\n", i+1)); break; } } i++; } if (i==vms) Rf_error("Failed to attach to any existing JVM."); else { jvm = jvms[i]; init_rJava(); } PROTECT(e=allocVector(INTSXP,1)); INTEGER(e)[0]=(i==vms)?-2:1; UNPROTECT(1); return e; } } #ifdef THREADS if (getenv("R_GUI_APP_VERSION") || getenv("RJAVA_INIT_AWT")) initAWT=1; _dbg(rjprintf("RinitJVM(threads): launching thread\n")); pthread_mutex_lock(&initMutex); pthread_create(&initJVMpt, 0, initJVMthread, c); _dbg(rjprintf("RinitJVM(threads): waiting for mutex\n")); pthread_mutex_lock(&initMutex); pthread_mutex_unlock(&initMutex); /* pthread_join(initJVMpt, 0); */ _dbg(rjprintf("RinitJVM(threads): attach\n")); /* since JVM was initialized by another thread, we need to attach ourselves */ (*jvm)->AttachCurrentThread(jvm, (void**)&eenv, NULL); if (rJava_JVM_state != JVM_STATE_CREATED) rJava_JVM_state = JVM_STATE_ATTACHED; _dbg(rjprintf("RinitJVM(threads): done.\n")); r = thInitResult; #else profStart(); r=initJVM(c, jvm_opts, jvm_optv, default_hooks, disableGuardPages); if (disableGuardPages && r==-2) { _dbg(rjprintf("RinitJVM(non-threaded): cannot disable guard pages\n")); if (jvm_optv) free(jvm_optv); jvm_opts=0; return NULL; } init_rJava(); _prof(profReport("init_rJava:")); _dbg(rjprintf("RinitJVM(non-threaded): initJVM returned %d\n", r)); #endif if (jvm_optv) free(jvm_optv); jvm_opts=0; PROTECT(e=allocVector(INTSXP,1)); INTEGER(e)[0]=r; UNPROTECT(1); return e; } /* This is a workaround for another workaround in Oracle JVM. On Linux, the JVM would insert protected guard pages into the C stack of the R process that initializes the JVM, thus effectively reducing the stack size. Worse yet, R does not find out about this and fails to detect infinite recursion. Without the workaround, this code crashes R after .jinit() is called x <- 1; f <- function() { x <<- x + 1 ; print(x) ; f() } ; tryCatch(f(), error=function(e) x) and various packages fail/segfault unpredictably as they reach the stack limit. This workaround in rJava can detect the reduction of the R stack and can adjust R_CStack* variables so that the detection of infinite recursion still works. Moreover, the workaround in rJava can prevent significant shrinking of the stack by allocating at least 2M from the C stack before initializing the JVM. This makes the JVM think that the current thread is actually not the initial thread (os::Linux::is_initial_thread() returns false), because is_initial_thread will run outside what the JVM assumes is the stack for the initial thread (the JVM caps the stack to 2M). Consequently, the JVM will not install guard pages. The stack size limit is implemented in os::Linux::capture_initial_stack (the limit 4M on Itanium which is ignored here by rJava and 2M on other Linux systems) and is claimed to be a workaround for issues in RH7.2. The problem is still present in JVM 9. Moreover, on Linux the JVM inserts guard pages also based on the setting of -Xss. As of Java 10, Oracle JVM allows to disable these guard pages via an experimental VM option -XX:+DisablePrimordialThreadGuardPages. This is by default tried first, and only if it fails, the machinery of filling up slightly the C stack is attempted as described above. */ #undef JVM_STACK_WORKAROUND #if defined(linux) || defined(__linux__) || defined(__linux) #define JVM_STACK_WORKAROUND #endif #ifdef JVM_STACK_WORKAROUND #include /* unfortunately this needs (write!) access to R internals */ extern uintptr_t R_CStackLimit; extern uintptr_t R_CStackStart; extern int R_CStackDir; #include #include #include #include #include #include #include /* Find a new limit for the C stack, within the existing limit. Looks for the first address in the stack area that is not accessible to the current process. This code could easily be made to work on different Unix systems, not just on Linux, but it does not seem necessary at the moment. from is the first address to access limit is the first address not to access bound is the new first address not to access dir is 1 (stack grows up) or -1 (stack grows down, the usual) so, incrementing by dir one traverses from stack start, from the oldest things on the stack; note that in R_CStackDir, 1 means stack grows down returns NULL in case of error, limit when no new limit is found, a new limit when found returns NULL when from == limit */ volatile int globald = 0; static char* findBound(char *from, char *limit, int dir) { int pipefd[2]; pid_t cpid; /* any positive size could be used, using page size is a heuristic */ int psize = (int) sysconf(_SC_PAGESIZE); char buf[psize]; if ((dir==-1 && from<=limit) || (dir == 1 && from>=limit)) return NULL; if (pipe(pipefd) == -1) return NULL; /* error */ cpid = fork(); if (cpid == -1) return NULL; /* error */ if (cpid == 0) { /* child process, reads from the pipe */ close(pipefd[1]); while (read(pipefd[0], &buf, psize) > 0); _exit(0); } else { /* Parent process, writes data to the pipe looking for EFAULT error which indicates an inaccessible page. For performance, the reading is first done using a buffer (of the size of a page), but once EFAULT is reached, it is re-tried byte-by-byte for the last buffer not read successfully. */ close(pipefd[0]); intmax_t diff = imaxabs(from-limit); int step = (diff < psize) ? diff : psize; int failed = 0; int reached_fault = 0; char *origfrom = from; /* start search at bigger granularity for performance */ for(; (dir == -1) ? (from-step+1 >= limit) : (from+step-1 <= limit) ; from += dir * step) if (write(pipefd[1], (dir == -1) ? (from-step+1) : from, step) == -1) { if (errno == EFAULT) reached_fault = 1; else failed = 1; break; } /* finetune with step 1 */ if (reached_fault && step > 1 && origfrom != from) for(from -= dir * step; from != limit ; from += dir) if (write(pipefd[1], from, 1) == -1) { if (errno != EFAULT) failed = 1; break; } close(pipefd[1]); wait(NULL); return failed ? NULL : from; } } /* Add certain amount of padding to the C stack before invoking RinitJVM. The recursion turned out more reliable in face of compiler optimizations than allocating large arrays on the C stack, both via definition and alloca. */ static SEXP RinitJVM_with_padding(SEXP par, intptr_t padding, char *last) { volatile char dummy[1]; /* reduce the risk that dummy will be optimized out */ dummy[0] = (char) (uintptr_t) &dummy; padding -= (last - dummy) * R_CStackDir; if (padding <= 0) return RinitJVM_real(par, 0); else return RinitJVM_with_padding(par, padding, (char*) dummy); } /* Run RinitJVM with the Java stack workaround */ static SEXP RinitJVM_jsw(SEXP par) { /* One can disable the workaround using environment variable RJAVA_JVM_STACK_WORKAROUND this support exists for diagnostics and as a way to disable the workaround without re-compiling rJava. In normal cases it only makes sense to use the default value of 3. */ #define JSW_DISABLED 0 #define JSW_DETECT 1 #define JSW_ADJUST 2 #define JSW_PREVENT 3 #define JSW_JAVA10 4 #define JSW_PADDING 2*1024*1024 #define JSW_CHECK_BOUND 16*1024*1024 /* 0 - disabled 1 - detect guard pages 2 - detect guard pages and adjust R stack size 3 - prevent guard page creation, detect, and adjust 4 - try to use JAVA10 feature to disable guard pages, (3) if it fails */ int val = JSW_JAVA10; char *vval = getenv("RJAVA_JVM_STACK_WORKAROUND"); if (vval != NULL) val = atoi(vval); if (val < 0 || val > 4) error("Invalid value for RJAVA_JVM_STACK_WORKAROUND"); _dbg(rjprintf("JSW workaround: (level %d)\n", val)); /* before we get anywhere, check whether we're inside a running JVM already */ { JavaVM *jvms[32]; jsize vms = 0; int r = JNI_GetCreatedJavaVMs(jvms, 32, &vms); if (r == 0 && vms > 0) { _dbg(rjprintf("JSW workaround: detected running VMs, disabling work-around.")); return RinitJVM_real(par, 0); } } if (val == JSW_JAVA10) { /* try to use Java 10 experimental option to disable guard pages */ SEXP res = RinitJVM_real(par, 1); if (res != NULL) { _dbg(rjprintf("JSW workaround: disabled guard pages\n", val)); return res; } val = JSW_PREVENT; } if (val == JSW_DISABLED) return RinitJVM_real(par, 0); /* Figure out the original stack limit */ uintptr_t rlimsize = 0; struct rlimit rlim; if (getrlimit(RLIMIT_STACK, &rlim) == 0) { rlim_t lim = rlim.rlim_cur; if (lim != RLIM_INFINITY) { rlimsize = (uintptr_t)lim; _dbg(rjprintf(" RLIMIT_STACK (rlimsize) %lu\n", (unsigned long) rlimsize)); } else { _dbg(rjprintf(" RLIMIT_STACK unlimited\n")); } } if (rlimsize == 0 && R_CStackLimit != -1) { /* getrlimit should work on linux, so this should only happen when stack size is unlimited */ rlimsize = (uintptr_t) (R_CStackLimit / 0.95); _dbg(rjprintf(" expanded R_CStackLimit (rlimsize) %lu\n", (unsigned long) rlimsize)); } if (rlimsize == 0 || rlimsize > JSW_CHECK_BOUND) { /* use a reasonable limit when looking for guard pages when stack size is unlimited or very large */ rlimsize = JSW_CHECK_BOUND; _dbg(rjprintf(" hardcoded rlimsize %lu\n", (unsigned long) rlimsize)); } _dbg(rjprintf(" R_CStackStart %p\n", R_CStackStart)); _dbg(rjprintf(" R_CStackLimit %lu\n", (unsigned long)R_CStackLimit)); char *maxBound = (char *)((intptr_t)R_CStackStart - (intptr_t)R_CStackDir*rlimsize); char *oldBound = findBound((char*)R_CStackStart - R_CStackDir, maxBound, -R_CStackDir); _dbg(rjprintf(" maxBound %p\n", maxBound)); _dbg(rjprintf(" oldBound %p\n", oldBound)); /* it is expected that newBound < maxBound, because not all of the "rlim" stack may be accessible even before JVM initialization, which can be e.g. because of an imprecise detection of the stack start */ intptr_t padding = 0; if (val >= JSW_PREVENT) { int dummy; intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy); usage += JSW_PADDING + 512; /* 512 is a buffer for C recursive calls */ if(R_CStackLimit == -1 || usage < ((intptr_t) R_CStackLimit)) padding = JSW_PADDING; } char dummy[1]; /* reduce the risk that dummy will be optimized out */ dummy[0] = (char) (uintptr_t) &dummy; SEXP ans = PROTECT(RinitJVM_with_padding(par, padding, dummy)); _dbg(rjprintf("JSW workaround (ctd): (level %d)\n", val)); if (val >= JSW_DETECT) { char *newBound = findBound((char*)R_CStackStart - R_CStackDir, oldBound, -R_CStackDir); _dbg(rjprintf(" newBound %p\n", newBound)); if (oldBound == newBound) { /* No guard pages inserted, keep the original stack size. This includes the case when the original stack size was unlimited. */ UNPROTECT(1); /* ans */ return ans; } intptr_t newb = (intptr_t)newBound; intptr_t lim = ((intptr_t)R_CStackStart - newb) * R_CStackDir; uintptr_t newlim = (uintptr_t) (lim * 0.95); uintptr_t oldlim = R_CStackLimit; if (val >= JSW_ADJUST) { R_CStackLimit = newlim; _dbg(rjprintf(" new R_CStackLimit %lu\n", (unsigned long)R_CStackLimit)); } /* Only report when the loss is big. There may be some bytes lost because even with the original setting of R_CStackLimit before initializing the JVM, one may not be able to access all bytes of stack (e.g. because of imprecise detection of the stack start). */ int bigloss = 0; if (oldlim == -1) { /* the message may be confusing when R_CStackLimit was set to -1 because the original stack size was too large */ REprintf("Rjava.init.warning: stack size reduced from unlimited to" " %lu bytes after JVM initialization.\n", (unsigned long) newlim); bigloss = 1; } else { unsigned lost = (unsigned) (oldlim - newlim); if (lost > oldlim * 0.01) { REprintf("Rjava.init.warning: lost %u bytes of stack after JVM" " initialization.\n", lost); bigloss = 1; } } if (bigloss) { if (val >= JSW_PREVENT && padding == 0) REprintf("Rjava.init.warning: re-try with increased" " stack size via ulimit -s to allow for a work-around.\n"); if (val < JSW_ADJUST) REprintf("Rjava.init.warning: R may crash in recursive calls.\n"); } } UNPROTECT(1); /* ans */ return ans; } #endif /* JVM_STACK_WORKAROUND */ /** RinitJVM(classpath) initializes JVM with the specified class path */ REP SEXP RinitJVM(SEXP par) { #ifndef JVM_STACK_WORKAROUND return RinitJVM_real(par, 0); #else return RinitJVM_jsw(par); #endif } REP void doneJVM(void) { (*jvm)->DestroyJavaVM(jvm); jvm = 0; eenv = 0; rJava_JVM_state = JVM_STATE_DESTROYED; } /** * Initializes the cached values of classes and methods used internally * These classes and methods are the ones that are in rJava (RJavaTools, ...) * not java standard classes (Object, Class) */ REPC SEXP initRJavaTools(void){ JNIEnv *env=getJNIEnv(); jclass c; /* classes */ /* RJavaTools class */ c = findClass(env, "RJavaTools", oClassLoader); if (!c) error("unable to find the RJavaTools class"); rj_RJavaTools_Class=(*env)->NewGlobalRef(env, c); if (!rj_RJavaTools_Class) error("unable to create a global reference to the RJavaTools class"); (*env)->DeleteLocalRef(env, c); /* RJavaImport */ c = findClass(env, "RJavaImport", oClassLoader); if (!c) error("unable to find the RJavaImport class"); rj_RJavaImport_Class=(*env)->NewGlobalRef(env, c); if (!rj_RJavaImport_Class) error("unable to create a global reference to the RJavaImport class"); (*env)->DeleteLocalRef(env, c); /* methods */ mid_RJavaTools_getFieldTypeName = (*env)->GetStaticMethodID(env, rj_RJavaTools_Class, "getFieldTypeName", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String;"); if (!mid_RJavaTools_getFieldTypeName) error("cannot obtain RJavaTools.getFieldTypeName method ID"); mid_rj_getSimpleClassNames = (*env)->GetStaticMethodID(env, rj_RJavaTools_Class, "getSimpleClassNames", "(Ljava/lang/Object;Z)[Ljava/lang/String;"); if (!mid_rj_getSimpleClassNames) error("cannot obtain RJavaTools.getDimpleClassNames method ID"); mid_RJavaImport_getKnownClasses = (*env)->GetMethodID(env, rj_RJavaImport_Class, "getKnownClasses", "()[Ljava/lang/String;"); if (!mid_RJavaImport_getKnownClasses) error("cannot obtain RJavaImport.getKnownClasses method ID"); mid_RJavaImport_lookup = (*env)->GetMethodID(env, rj_RJavaImport_Class, "lookup", "(Ljava/lang/String;)Ljava/lang/Class;"); if( !mid_RJavaImport_lookup) error("cannot obtain RJavaImport.lookup method ID"); mid_RJavaImport_exists = (*env)->GetMethodID(env, rj_RJavaImport_Class, "exists", "(Ljava/lang/String;)Z"); if( ! mid_RJavaImport_exists ) error("cannot obtain RJavaImport.exists method ID"); // maybe add RJavaArrayTools, ... return R_NilValue; } rJava/src/jvm-w32/0000755000175100001440000000000015133274032013327 5ustar hornikusersrJava/src/jvm-w32/jvm64.def0000644000175100001440000000015515133274032014756 0ustar hornikusersLIBRARY JVM.DLL EXPORTS JNI_CreateJavaVM JNI_GetCreatedJavaVMs JNI_GetDefaultJavaVMInitArgs rJava/src/jvm-w32/Makefile0000644000175100001440000000151215133274037014773 0ustar hornikusers# helper tools and libs for building and running rJava for Windows # Author: Simon Urbanek # with contributions from Brian Ripley include $(R_HOME)/etc$(R_ARCH)/Makeconf TARGETS=libjvm.dll.a findjava.exe # libjvm.dll.a - wrapper lib for jvm.dll from Java # findjava.exe - helper tool to find the current JDK from the registry all: $(TARGETS) # detect 64-bit Windows ifeq ($(strip $(shell $(R_HOME)/bin/R --slave -e 'cat(.Machine$$sizeof.pointer)')),8) JVM64DEF=64 endif libjvm.dll.a: jvm$(JVM64DEF).def $(DLLTOOL) --input-def $^ --kill-at --dllname jvm.dll --output-lib $@ # compile findjava.exe from source - no magic here, no special libs necessary findjava.o: findjava.c $(CC) -O2 -c -o $@ $^ findjava.exe: findjava.o $(CC) -s -o $@ $^ # just cleanup everything clean: rm -f *.o *~ $(TARGETS) .PHONY: all clean rJava/src/jvm-w32/jvm.def0000644000175100001440000000016515133274032014605 0ustar hornikusersLIBRARY JVM.DLL EXPORTS JNI_CreateJavaVM@12 JNI_GetCreatedJavaVMs@12 JNI_GetDefaultJavaVMInitArgs@4 rJava/src/jvm-w32/WinRegistry.c0000644000175100001440000000143315133274032015762 0ustar hornikusers#include #ifdef WIN32 #include #include char RegStrBuf[32768]; SEXP RegGetStrValue(SEXP par) { SEXP res=R_NilValue; DWORD t,s=32767; HKEY k; char *key=CHAR(STRING_ELT(par, 0)); char *val=CHAR(STRING_ELT(par, 1)); RegStrBuf[32767]=*RegStrBuf=0; /* printf("RegGetStrValue(\"%s\",\"%s\")\n",key,val); */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,key,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,val,0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) return res; PROTECT(res = allocVector(STRSXP, 1)); SET_STRING_ELT(res, 0, mkChar(RegStrBuf)); UNPROTECT(1); return res; }; #else /* all functions return NULL since they are not supported on non-Win32 platforms */ SEXP RegGetStrValue(SEXP par) { return R_NilValue; }; #endif rJava/src/jvm-w32/findjava.c0000644000175100001440000000711415133274032015260 0ustar hornikusers#include #include #include static char RegStrBuf[32768], dbuf[32768]; int main(int argc, char **argv) { int i=0, doit=0; DWORD t,s=32767; HKEY k; HKEY root=HKEY_LOCAL_MACHINE; char *javakey="Software\\JavaSoft\\Java Runtime Environment"; if (argc>1 && argv[1][0]=='-' && argv[1][1]=='R') { if (getenv("R_HOME")) { strcpy(RegStrBuf,getenv("R_HOME")); } else { javakey="Software\\R-core\\R"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"InstallPath",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { if (RegOpenKeyEx(HKEY_CURRENT_USER,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"InstallPath",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "ERROR*> R - can't open registry keys.\n"); return -1; } } } } else /* JAVA_HOME can override our detection - but we still post-process it */ if (getenv("JAVA_HOME")) { strcpy(RegStrBuf,getenv("JAVA_HOME")); } else { #ifdef FINDJRE if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { javakey="Software\\JavaSoft\\JRE"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { #endif javakey="Software\\JavaSoft\\Java Development Kit"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { javakey="Software\\JavaSoft\\JDK"; s=32767; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"CurrentVersion",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "ERROR*> JavaSoft\\{JRE|JDK} can't open registry keys.\n"); /* MessageBox(wh, "Can't find Sun's Java runtime.\nPlease install Sun's J2SE JRE or JDK 1.4.2 or later (see http://java.sun.com/).","Can't find Sun's Java",MB_OK|MB_ICONERROR); */ return -1; } } #ifdef FINDJRE } } #endif RegCloseKey(k); s=32767; strcpy(dbuf,javakey); strcat(dbuf,"\\"); strcat(dbuf,RegStrBuf); javakey=(char*) malloc(strlen(dbuf)+1); strcpy(javakey, dbuf); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,javakey,0,KEY_QUERY_VALUE,&k)!=ERROR_SUCCESS || RegQueryValueEx(k,"JavaHome",0,&t,RegStrBuf,&s)!=ERROR_SUCCESS) { fprintf(stderr, "There's no JavaHome value in the JDK/JRE registry key.\n"); /* MessageBox(wh, "Can't find Java home path. Maybe your JRE is too old.\nPlease install Sun's J2SE JRE or SDK 1.4.2 (see http://java.sun.com/).","Can't find Sun's Java",MB_OK|MB_ICONERROR); */ return -1; } RegCloseKey(k); } /*--- post-processing according to supplied flags --*/ /* -a = automagic, i.e. use short name only if the name contains spaces */ i=1; while (i /* for jchar */ #include /* for SEXP */ /* --- API --- */ /* Returns static content for short strings so don't re-use. For dynamic strings uses R_alloc */ int rj_char_utf16(const char *c, int len, jchar **buf, const char *ifrom, int can_error); /* wrappers for above to use with CHARSXP to detect proper ifrom */ int rj_rchar_utf16(SEXP s, jchar **buf); int rj_rchar_utf16_noerr(SEXP s, jchar **buf); /* return jstring, but do NOT check exceptions */ jstring rj_newJavaString(JNIEnv *env, SEXP sChar); jstring rj_newNativeJavaString(JNIEnv *env, const char *str, int len); /* takes modified UTF-8 from Java, creates CHARSXP with valid UTF8 */ SEXP rj_mkCharUTF8(const char *src); SEXP rj_mkCharUTF8_noerr(const char *src); #endif rJava/src/Makevars.in0000644000175100001440000000076215133274032014230 0ustar hornikusers# we need to add JNI specific stuff here PKG_CPPFLAGS=-I. @JAVA_CPPFLAGS@ @USE_DYNLOAD_FALSE@PKG_LIBS=@JAVA_LIBS@ JAVA_HOME=@JAVA_HOME@ # make SHLIB believe that we know better what the objects are #OBJECTS=Rglue.o callJNI.o initJNI.o rJava.o jri.o jri_glue.o all: $(SHLIB) @WANT_JRI_TRUE@ jri .PHONY: all # this is a hack to force SHLIB to run our sub-make jri: (cd ../jri && $(MAKE)) -@mkdir -p ../inst/jri @(cp -r ../jri/src/JRI.jar ../jri/*jri.* ../jri/run ../jri/examples ../inst/jri/) rJava/src/jri_glue.c0000644000175100001440000000540115133274032014066 0ustar hornikusers#include #include #include "rJava.h" /* creates a reference to an R object on the Java side 1) lock down the object in R 2) call new Rengine(eng,robj) {or any other class such as REXPReference for REngine API} */ REPC SEXP PushToREXP(SEXP clname, SEXP eng, SEXP engCl, SEXP robj, SEXP doConv) { char sig[128]; jvalue jpar[4]; jobject o; int convert = (doConv == R_NilValue) ? -1 : asInteger(doConv); JNIEnv *env=getJNIEnv(); const char *cName; if (!isString(clname) || LENGTH(clname)!=1) error("invalid class name"); if (!isString(engCl) || LENGTH(engCl)!=1) error("invalid engine class name"); if (TYPEOF(eng)!=EXTPTRSXP) error("invalid engine object"); R_PreserveObject(robj); sig[127]=0; cName = CHAR(STRING_ELT(clname,0)); jpar[0].l = (jobject)EXTPTR_PTR(eng); jpar[1].j = (jlong) (size_t) robj; if (convert == -1) snprintf(sig,127,"(L%s;J)V",CHAR(STRING_ELT(engCl,0))); else { snprintf(sig,127,"(L%s;JZ)V",CHAR(STRING_ELT(engCl,0))); jpar[2].z = (jboolean) convert; } o = createObject(env, cName, sig, jpar, 1, 0); if (!o) error("Unable to create Java object"); return j2SEXP(env, o, 1); /* ok, some thoughts on mem mgmt - j2SEXP registers a finalizer. But I believe that is ok, because the pushed reference is useless until it is passed as an argument to some Java method. And then, it will have another reference which will prevent the Java side from being collected. The R-side reference may be gone, but that's ok, because it's the Java finalizer that needs to clean up the pushed R object and for that it doesn't need the proxy object at all. This is the reason why RReleaseREXP uses EXTPTR - all the Java finalizer has to do is to call RReleaseREXP(self). For that it can create a fresh proxy object containing the REXP. But here comes he crux - this proxy cannot again create a reference - it must be plain pass-through, so this part needs to be verified. Note: as of REngine API the references assume protected objects and use rniRelease to clean up, so RReleaseREXP won't be called and is not needed. That is good, because RReleaseREXP assumes JRI objects whereas REngine will create REXPReference (no xp there). However, if we ever change that REXPReference assumption we will be in trouble. */ } /* this is pretty much hard-coded for now - it's picking "xp" attribute */ REPC SEXP RReleaseREXP(SEXP ptr) { jobject o; if (TYPEOF(ptr)==EXTPTRSXP) error("invalid object"); o = (jobject)EXTPTR_PTR(ptr); { JNIEnv *env = getJNIEnv(); jclass cls = (*env)->GetObjectClass(env, o); if (cls) { jfieldID fid=(*env)->GetFieldID(env,cls,"xp","J"); if (fid) { jlong r = (*env)->GetLongField(env, o, fid); SEXP x = (SEXP) r; if (x) R_ReleaseObject(x); } } } return R_NilValue; } rJava/src/Rglue.c0000644000175100001440000010335115133274032013347 0ustar hornikusers#define USE_RINTERNALS 1 #include "rJava.h" #include #include #include #include #include #include #include "rjstring.h" #include /* max supported # of parameters to Java methods */ #ifndef maxJavaPars #define maxJavaPars 32 #endif /* pre-2.4 have no S4SXP but used VECSXP instead */ #ifndef S4SXP #define S4SXP VECSXP #endif /** returns TRUE if JRI has callback support compiled in or FALSE otherwise */ REPC SEXP RJava_has_jri_cb(void) { SEXP r = allocVector(LGLSXP, 1); #ifdef ENABLE_JRICB LOGICAL(r)[0] = 1; #else LOGICAL(r)[0] = 0; #endif return r; } /* debugging output (enable with -DRJ_DEBUG) */ #ifdef RJ_DEBUG HIDE void rjprintf(char *fmt, ...) { va_list v; va_start(v,fmt); Rvprintf(fmt,v); va_end(v); } /* we can't assume ISO C99 (variadic macros), so we have to use one more level of wrappers */ #define _dbg(X) X #else #define _dbg(X) #endif /* profiling code (enable with -DRJ_PROFILE) */ #ifdef RJ_PROFILE #include HIDE long time_ms(void) { #ifdef Win32 return 0; /* in Win32 we have no gettimeofday :( */ #else struct timeval tv; gettimeofday(&tv,0); return (tv.tv_usec/1000)+(tv.tv_sec*1000); #endif } static long profilerTime; #define profStart() profilerTime=time_ms() HIDE void profReport(char *fmt, ...) { long npt=time_ms(); va_list v; va_start(v,fmt); Rvprintf(fmt,v); va_end(v); Rprintf(" %ld ms\n",npt-profilerTime); profilerTime=npt; } #define _prof(X) X #else #define profStart() #define _prof(X) #endif static void JRefObjectFinalizer(SEXP ref) { if (java_is_dead) return; if (TYPEOF(ref)==EXTPTRSXP) { JNIEnv *env=getJNIEnv(); jobject o = R_ExternalPtrAddr(ref); #ifdef RJ_DEBUG { jstring s=callToString(env, o); const char *c="???"; if (s) c=(*env)->GetStringUTFChars(env, s, 0); _dbg(rjprintf("Finalizer releases Java object [%s] reference %lx (SEXP@%lx)\n", c, (long)o, (long)ref)); if (s) { (*env)->ReleaseStringUTFChars(env, s, c); releaseObject(env, s); } } #endif if (env && o) { /* _dbg(rjprintf(" finalizer releases global reference %lx\n", (long)o);) */ _mp(MEM_PROF_OUT("R %08x FIN\n", (int)o)) releaseGlobal(env, o); } } } /* jobject to SEXP encoding - 0.2 and earlier use INTSXP */ SEXP j2SEXP(JNIEnv *env, jobject o, int releaseLocal) { if (!env) error("Invalid Java environment in j2SEXP"); if (o) { jobject go = makeGlobal(env, o); _mp(MEM_PROF_OUT("R %08x RNEW %08x\n", (int) go, (int) o)) if (!go) error("Failed to create a global reference in Java."); _dbg(rjprintf(" j2SEXP: %lx -> %lx (release=%d)\n", (long)o, (long)go, releaseLocal)); if (releaseLocal) releaseObject(env, o); o=go; } { SEXP xp = R_MakeExternalPtr(o, R_NilValue, R_NilValue); #ifdef RJ_DEBUG { JNIEnv *env=getJNIEnv(); jstring s=callToString(env, o); const char *c="???"; if (s) c=(*env)->GetStringUTFChars(env, s, 0); _dbg(rjprintf("New Java object [%s] reference %lx (SEXP@%lx)\n", c, (long)o, (long)xp)); if (s) { (*env)->ReleaseStringUTFChars(env, s, c); releaseObject(env, s); } } #endif R_RegisterCFinalizerEx(xp, JRefObjectFinalizer, TRUE); return xp; } } /* returns string from a CHARSXP making sure that the result is in UTF-8 NOTE: this should NOT be used to create Java strings as they require UTF-16 natively For Java strings use rj_*_utf16 function from rjstring.h */ const char *rj_char_utf8(SEXP s) { #ifdef DEBUG_ENCODING fprintf(stderr, "rJava.rj_char_utf8, CE=%d: \"%s\"\n", (int)Rf_getCharCE(s), CHAR(s)); // { const char *c0 = CHAR(s); while (*c0) fprintf(stderr, " %02x", (int)((unsigned char)*(c0++))); } // fprintf(stderr, "\n"); #endif return (Rf_getCharCE(s) == CE_UTF8) ? CHAR(s) : Rf_reEnc(CHAR(s), getCharCE(s), CE_UTF8, 0); /* subst. invalid chars: 1=hex, 2=., 3=?, other=skip */ } static jstring newJavaString(JNIEnv *env, SEXP sChar) { jchar *s; size_t len = rj_rchar_utf16(sChar, &s); return newString16(env, s, (len + 1) >> 1); } HIDE void deserializeSEXP(SEXP o) { _dbg(rjprintf("attempt to deserialize %p (clCl=%p, oCL=%p)\n", o, clClassLoader, oClassLoader)); SEXP s = EXTPTR_PROT(o); if (TYPEOF(s) == RAWSXP && EXTPTR_PTR(o) == NULL) { JNIEnv *env = getJNIEnv(); if (env && clClassLoader && oClassLoader) { jbyteArray ser = newByteArray(env, RAW(s), LENGTH(s)); if (ser) { jmethodID mid = (*env)->GetMethodID(env, clClassLoader, "toObject", "([B)Ljava/lang/Object;"); if (mid) { jobject res = (*env)->CallObjectMethod(env, oClassLoader, mid, ser); if (res) { jobject go = makeGlobal(env, res); _mp(MEM_PROF_OUT("R %08x RNEW %08x\n", (int) go, (int) res)) if (go) { _dbg(rjprintf(" - succeeded: %p\n", go)); /* set the deserialized object */ R_SetExternalPtrAddr(o, go); /* Note: currently we don't remove the serialized content, because it was created explicitly using .jcache to allow repeated saving. Once this is handled by a hook, we shall remove it. However, to assure compatibility TAG is always NULL for now, so we do clear the cache if TAG is non-null for future use. */ if (EXTPTR_TAG(o) != R_NilValue) { /* remove the serialized raw vector */ R_SetExternalPtrTag(o, R_NilValue); } } } } releaseObject(env, ser); } } } } #define addtmpo(T, X) { jobject _o = X; if (_o) { _dbg(rjprintf(" parameter to release later: %lx\n", (unsigned long) _o)); *T=_o; T++;} } #define fintmpo(T) { *T = 0; } /* concatenate a string to a signature buffer increasing it as necessary */ static void strcats(sig_buffer_t *sig, const char *add) { int l = strlen(add); int al = sig->len; if (al + l >= sig->maxsig - 1) { sig->maxsig += 8192; if (sig->sig == sig->sigbuf) { /* first-time allocation */ char *ns = (char*) malloc(sig->maxsig); memcpy(ns, sig->sig, al + 1); sig->sig = ns; } else /* re-allocation */ sig->sig = (char*) realloc(sig->sig, sig->maxsig); } strcpy(sig->sig + al, add); sig->len += l; } /* call strcats() but also convert class names to JNI notation */ static void strcats_conv(sig_buffer_t *sig, const char *add) { int ol = sig->len, nl; strcats(sig, add); nl = sig->len; while (ol < nl) { if (sig->sig[ol] == '.') sig->sig[ol] = '/'; ol++; } } /* initialize a signature buffer */ HIDE void init_sigbuf(sig_buffer_t *sb) { sb->len = 0; sb->maxsig = sizeof(sb->sigbuf); sb->sig = sb->sigbuf; } /* free the content of a signature buffer (if necessary) */ HIDE void done_sigbuf(sig_buffer_t *sb) { if (sb->sig != sb->sigbuf) free(sb->sig); } /** converts parameters in SEXP list to jpar and sig. since 0.4-4 we ignore named arguments in par */ static int Rpar2jvalue(JNIEnv *env, SEXP par, jvalue *jpar, sig_buffer_t *sig, int maxpars, jobject *tmpo) { SEXP p=par; SEXP e; int jvpos=0; #ifdef RJ_DEBUG int i = 0; #endif while (p && TYPEOF(p)==LISTSXP && (e=CAR(p))) { /* skip all named arguments */ if (TAG(p) && TAG(p)!=R_NilValue) { p=CDR(p); continue; }; if (jvpos >= maxpars) { if (maxpars == maxJavaPars) Rf_error("Too many arguments in Java call. maxJavaPars is %d, recompile rJava with higher number if needed.", maxJavaPars); break; } _dbg(rjprintf("Rpar2jvalue: par %d type %d\n",i,TYPEOF(e))); if (TYPEOF(e)==STRSXP) { _dbg(rjprintf(" string vector of length %d\n",LENGTH(e))); if (LENGTH(e)==1) { SEXP sv = STRING_ELT(e, 0); strcats(sig,"Ljava/lang/String;"); if (sv == R_NaString) { addtmpo(tmpo, jpar[jvpos++].l = 0); } else { addtmpo(tmpo, jpar[jvpos++].l = newJavaString(env, sv)); } } else { int j = 0; jobjectArray sa = (*env)->NewObjectArray(env, LENGTH(e), javaStringClass, 0); _mp(MEM_PROF_OUT(" %08x LNEW string[%d]\n", (int) sa, LENGTH(e))) if (!sa) { fintmpo(tmpo); error("unable to create string array."); return -1; } addtmpo(tmpo, sa); while (j < LENGTH(e)) { SEXP sv = STRING_ELT(e,j); if (sv == R_NaString) { } else { jobject s = newJavaString(env, sv); _dbg(rjprintf (" [%d] \"%s\"\n",j,CHAR_UTF8(sv))); (*env)->SetObjectArrayElement(env, sa, j, s); if (s) releaseObject(env, s); } j++; } jpar[jvpos++].l = sa; strcats(sig,"[Ljava/lang/String;"); } } else if (TYPEOF(e)==RAWSXP) { _dbg(rjprintf(" raw vector of length %d\n", LENGTH(e))); strcats(sig,"[B"); addtmpo(tmpo, jpar[jvpos++].l=newByteArray(env, RAW(e), LENGTH(e))); } else if (TYPEOF(e)==INTSXP) { _dbg(rjprintf(" integer vector of length %d\n",LENGTH(e))); if (LENGTH(e)==1) { if (inherits(e, "jbyte")) { _dbg(rjprintf(" (actually a single byte 0x%x)\n", INTEGER(e)[0])); jpar[jvpos++].b=(jbyte)(INTEGER(e)[0]); strcats(sig,"B"); } else if (inherits(e, "jchar")) { _dbg(rjprintf(" (actually a single character 0x%x)\n", INTEGER(e)[0])); jpar[jvpos++].c=(jchar)(INTEGER(e)[0]); strcats(sig,"C"); } else if (inherits(e, "jshort")) { _dbg(rjprintf(" (actually a single short 0x%x)\n", INTEGER(e)[0])); jpar[jvpos++].s=(jshort)(INTEGER(e)[0]); strcats(sig,"S"); } else { strcats(sig,"I"); jpar[jvpos++].i=(jint)(INTEGER(e)[0]); _dbg(rjprintf(" single int orig=%d, jarg=%d [jvpos=%d]\n", (INTEGER(e)[0]), jpar[jvpos-1], jvpos)); } } else { if (inherits(e, "jbyte")) { strcats(sig,"[B"); addtmpo(tmpo, jpar[jvpos++].l=newByteArrayI(env, INTEGER(e), LENGTH(e))); } else if (inherits(e, "jchar")) { strcats(sig,"[C"); addtmpo(tmpo, jpar[jvpos++].l=newCharArrayI(env, INTEGER(e), LENGTH(e))); } else if (inherits(e, "jshort")) { strcats(sig,"[S"); addtmpo(tmpo, jpar[jvpos++].l=newShortArrayI(env, INTEGER(e), LENGTH(e))); } else { strcats(sig,"[I"); addtmpo(tmpo, jpar[jvpos++].l=newIntArray(env, INTEGER(e), LENGTH(e))); } } } else if (TYPEOF(e)==REALSXP) { if (inherits(e, "jfloat")) { _dbg(rjprintf(" jfloat vector of length %d\n", LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"F"); jpar[jvpos++].f=(jfloat)(REAL(e)[0]); } else { strcats(sig,"[F"); addtmpo(tmpo, jpar[jvpos++].l=newFloatArrayD(env, REAL(e),LENGTH(e))); } } else if (inherits(e, "jlong")) { _dbg(rjprintf(" jlong vector of length %d\n", LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"J"); jpar[jvpos++].j=(jlong)(REAL(e)[0]); } else { strcats(sig,"[J"); addtmpo(tmpo, jpar[jvpos++].l=newLongArrayD(env, REAL(e),LENGTH(e))); } } else { _dbg(rjprintf(" real vector of length %d\n",LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"D"); jpar[jvpos++].d=(jdouble)(REAL(e)[0]); } else { strcats(sig,"[D"); addtmpo(tmpo, jpar[jvpos++].l=newDoubleArray(env, REAL(e),LENGTH(e))); } } } else if (TYPEOF(e)==LGLSXP) { _dbg(rjprintf(" logical vector of length %d\n",LENGTH(e))); if (LENGTH(e)==1) { strcats(sig,"Z"); jpar[jvpos++].z=(jboolean)(LOGICAL(e)[0]); } else { strcats(sig,"[Z"); addtmpo(tmpo, jpar[jvpos++].l=newBooleanArrayI(env, LOGICAL(e),LENGTH(e))); } } else if (TYPEOF(e)==VECSXP || TYPEOF(e)==S4SXP) { if (TYPEOF(e) == VECSXP) _dbg(rjprintf(" generic vector of length %d\n", LENGTH(e))); if (inherits(e, "jclassName")) { _dbg(rjprintf(" jclassName, replacing with embedded class jobjRef")); e = GET_SLOT(e, install("jobj")); } if (IS_JOBJREF(e)) { jobject o=(jobject)0; const char *jc=0; SEXP n=getAttrib(e, R_NamesSymbol); if (TYPEOF(n)!=STRSXP) n=0; _dbg(rjprintf(" which is in fact a Java object reference\n")); if (TYPEOF(e)==VECSXP && LENGTH(e)>1) { /* old objects were lists */ fintmpo(tmpo); error("Old, unsupported S3 Java object encountered."); } else { /* new objects are S4 objects */ SEXP sref, sclass; sref=GET_SLOT(e, install("jobj")); if (sref && TYPEOF(sref)==EXTPTRSXP) { jverify(sref); o = (jobject)EXTPTR_PTR(sref); } else /* if jobj is anything else, assume NULL ptr */ o=(jobject)0; sclass=GET_SLOT(e, install("jclass")); if (sclass && TYPEOF(sclass)==STRSXP && LENGTH(sclass)==1) jc=CHAR_UTF8(STRING_ELT(sclass,0)); if (IS_JARRAYREF(e) && jc && !*jc) { /* if it's jarrayRef with jclass "" then it's an uncast array - use sig instead */ sclass=GET_SLOT(e, install("jsig")); if (sclass && TYPEOF(sclass)==STRSXP && LENGTH(sclass)==1) jc=CHAR_UTF8(STRING_ELT(sclass,0)); } } if (jc) { if (*jc!='[') { /* not an array, we assume it's an object of that class */ strcats(sig,"L"); strcats_conv(sig,jc); strcats(sig,";"); } else /* array signature is passed as-is */ strcats_conv(sig,jc); } else strcats(sig,"Ljava/lang/Object;"); jpar[jvpos++].l=o; } else { _dbg(rjprintf(" (ignoring)\n")); } } #ifdef RJ_DEBUG i++; #endif p=CDR(p); } fintmpo(tmpo); return jvpos; } /** free parameters that were temporarily allocated */ static void Rfreejpars(JNIEnv *env, jobject *tmpo) { if (!tmpo) return; while (*tmpo) { _dbg(rjprintf("Rfreepars: releasing %lx\n", (unsigned long) *tmpo)); releaseObject(env, *tmpo); tmpo++; } } /** map one parameter into jvalue and determine its signature (unused in fields.c) */ HIDE jvalue R1par2jvalue(JNIEnv *env, SEXP par, sig_buffer_t *sig, jobject *otr) { jobject tmpo[4] = {0, 0}; jvalue v[4]; int p = Rpar2jvalue(env, PROTECT(CONS(par, R_NilValue)), v, sig, 2, tmpo); UNPROTECT(1); /* this should never happen, but just in case - we can only assume responsibility for one value ... */ if (p != 1 || (tmpo[0] && tmpo[1])) { Rfreejpars(env, tmpo); error("invalid parameter"); } *otr = *tmpo; return *v; } /** call specified non-static method on an object object (int), return signature (string), method name (string) [, ..parameters ...] arrays and objects are returned as IDs (hence not evaluated) */ REPE SEXP RcallMethod(SEXP par) { SEXP p = par, e; sig_buffer_t sig; jvalue jpar[maxJavaPars]; jobject tmpo[maxJavaPars+1]; jobject o = 0; const char *retsig, *mnam, *clnam = 0; jmethodID mid = 0; jclass cls; JNIEnv *env = getJNIEnv(); profStart(); p=CDR(p); e=CAR(p); p=CDR(p); if (e==R_NilValue) error_return("RcallMethod: call on a NULL object"); if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else if (TYPEOF(e)==STRSXP && LENGTH(e)==1) clnam = CHAR_UTF8(STRING_ELT(e, 0)); else error_return("RcallMethod: invalid object parameter"); if (!o && !clnam) error_return("RcallMethod: attempt to call a method of a NULL object."); #ifdef RJ_DEBUG { SEXP de=CAR(CDR(p)); rjprintf("RcallMethod (env=%x):\n",env); if (TYPEOF(de)==STRSXP && LENGTH(de)>0) rjprintf(" method to call: %s on object 0x%x or class %s\n",CHAR_UTF8(STRING_ELT(de,0)),o,clnam); } #endif if (clnam) cls = findClass(env, clnam, oClassLoader); else cls = objectClass(env,o); if (!cls) error_return("RcallMethod: cannot determine object class"); #ifdef RJ_DEBUG rjprintf(" class: "); printObject(env, cls); #endif e=CAR(p); p=CDR(p); if (TYPEOF(e)==STRSXP && LENGTH(e)==1) { /* signature */ retsig=CHAR_UTF8(STRING_ELT(e,0)); /* } else if (inherits(e, "jobjRef")) { method object SEXP mexp = GET_SLOT(e, install("jobj")); jobject mobj = (jobject)(INTEGER(mexp)[0]); _dbg(rjprintf(" signature is Java object %x - using reflection\n", mobj); mid = (*env)->FromReflectedMethod(*env, jobject mobj); retsig = getReturnSigFromMethodObject(mobj); */ } else error_return("RcallMethod: invalid return signature parameter"); e=CAR(p); p=CDR(p); if (TYPEOF(e)!=STRSXP || LENGTH(e)!=1) error_return("RcallMethod: invalid method name"); mnam = CHAR_UTF8(STRING_ELT(e,0)); init_sigbuf(&sig); strcats(&sig, "("); Rpar2jvalue(env, p, jpar, &sig, maxJavaPars, tmpo); strcats(&sig, ")"); strcats(&sig, retsig); _dbg(rjprintf(" method \"%s\" signature is %s\n", mnam, sig.sig)); mid=o? (*env)->GetMethodID(env, cls, mnam, sig.sig): (*env)->GetStaticMethodID(env, cls, mnam, sig.sig); if (!mid && o) { /* try static method as a fall-back */ checkExceptionsX(env, 1); o = 0; mid = (*env)->GetStaticMethodID(env, cls, mnam, sig.sig); } if (!mid) { checkExceptionsX(env, 1); Rfreejpars(env, tmpo); releaseObject(env, cls); done_sigbuf(&sig); error("method %s with signature %s not found", mnam, sig.sigbuf); } #if (RJ_PROFILE>1) profReport("Found CID/MID for %s %s:",mnam,sig.sig); #endif switch (*retsig) { case 'V': { BEGIN_RJAVA_CALL o? (*env)->CallVoidMethodA(env, o, mid, jpar): (*env)->CallStaticVoidMethodA(env, cls, mid, jpar); END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return R_NilValue; } case 'I': { BEGIN_RJAVA_CALL int r=o? (*env)->CallIntMethodA(env, o, mid, jpar): (*env)->CallStaticIntMethodA(env, cls, mid, jpar); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'B': { BEGIN_RJAVA_CALL int r=(int) (o? (*env)->CallByteMethodA(env, o, mid, jpar): (*env)->CallStaticByteMethodA(env, cls, mid, jpar)); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'C': { BEGIN_RJAVA_CALL int r=(int) (o? (*env)->CallCharMethodA(env, o, mid, jpar): (*env)->CallStaticCharMethodA(env, cls, mid, jpar)); e = allocVector(INTSXP, 1); INTEGER(e)[0] = r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'J': { BEGIN_RJAVA_CALL jlong r=o? (*env)->CallLongMethodA(env, o, mid, jpar): (*env)->CallStaticLongMethodA(env, cls, mid, jpar); e = allocVector(REALSXP, 1); REAL(e)[0]=(double)r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'S': { BEGIN_RJAVA_CALL jshort r=o? (*env)->CallShortMethodA(env, o, mid, jpar): (*env)->CallStaticShortMethodA(env, cls, mid, jpar); e = allocVector(INTSXP, 1); INTEGER(e)[0]=(int)r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'Z': { BEGIN_RJAVA_CALL jboolean r=o? (*env)->CallBooleanMethodA(env, o, mid, jpar): (*env)->CallStaticBooleanMethodA(env, cls, mid, jpar); e = allocVector(LGLSXP, 1); LOGICAL(e)[0]=(r)?1:0; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'D': { BEGIN_RJAVA_CALL double r=o? (*env)->CallDoubleMethodA(env, o, mid, jpar): (*env)->CallStaticDoubleMethodA(env, cls, mid, jpar); e = allocVector(REALSXP, 1); REAL(e)[0]=r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'F': { BEGIN_RJAVA_CALL double r = (double) (o? (*env)->CallFloatMethodA(env, o, mid, jpar): (*env)->CallStaticFloatMethodA(env, cls, mid, jpar)); e = allocVector(REALSXP, 1); REAL(e)[0] = r; END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _prof(profReport("Method \"%s\" returned:",mnam)); return e; } case 'L': case '[': { jobject r; BEGIN_RJAVA_CALL r = o? (*env)->CallObjectMethodA(env, o, mid, jpar): (*env)->CallStaticObjectMethodA(env, cls, mid, jpar); END_RJAVA_CALL Rfreejpars(env, tmpo); releaseObject(env, cls); _mp(MEM_PROF_OUT(" %08x LNEW object method \"%s\" result\n", (int) r, mnam)) if (!r) { _prof(profReport("Method \"%s\" returned NULL:",mnam)); return R_NilValue; } e = j2SEXP(env, r, 1); _prof(profReport("Method \"%s\" returned",mnam)); return e; } } /* switch */ _prof(profReport("Method \"%s\" has an unknown signature, not called:",mnam)); releaseObject(env, cls); error("unsupported/invalid method signature %s", retsig); return R_NilValue; } /** like RcallMethod but the call will be synchronized */ REPE SEXP RcallSyncMethod(SEXP par) { SEXP p=par, e; jobject o = 0; JNIEnv *env=getJNIEnv(); p=CDR(p); e=CAR(p); p=CDR(p); if (e==R_NilValue) error("RcallSyncMethod: call on a NULL object"); if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o = (jobject)EXTPTR_PTR(e); } else error("RcallSyncMethod: invalid object parameter"); if (!o) error("RcallSyncMethod: attempt to call a method of a NULL object."); #ifdef RJ_DEBUG rjprintf("RcallSyncMethod: object: "); printObject(env, o); #endif if ((*env)->MonitorEnter(env, o) != JNI_OK) { REprintf("Rglue.warning: couldn't get monitor on the object, running unsynchronized.\n"); return RcallMethod(par); } e = RcallMethod(par); if ((*env)->MonitorExit(env, o) != JNI_OK) { PROTECT(e); REprintf("Rglue.SERIOUS PROBLEM: MonitorExit failed, subsequent calls may cause a deadlock!\n"); UNPROTECT(1); } return e; } /** create new object. fully-qualified class in JNI notation (string) [, constructor parameters] */ REPE SEXP RcreateObject(SEXP par) { SEXP p=par; SEXP e; int silent=0; const char *class; sig_buffer_t sig; jvalue jpar[maxJavaPars]; jobject tmpo[maxJavaPars+1]; jobject o, loader = 0; JNIEnv *env=getJNIEnv(); if (TYPEOF(p)!=LISTSXP) { _dbg(rjprintf("Parameter list expected but got type %d.\n",TYPEOF(p))); error_return("RcreateObject: invalid parameter"); } p=CDR(p); /* skip first parameter which is the function name */ e=CAR(p); /* second is the class name */ if (TYPEOF(e)!=STRSXP || LENGTH(e)!=1) error("RcreateObject: invalid class name"); class = CHAR_UTF8(STRING_ELT(e,0)); _dbg(rjprintf("RcreateObject: new object of class %s\n",class)); init_sigbuf(&sig); strcats(&sig, "("); p=CDR(p); Rpar2jvalue(env, p, jpar, &sig, maxJavaPars, tmpo); strcats(&sig, ")V"); _dbg(rjprintf(" constructor signature is %s\n",sig.sig)); /* look for named arguments */ while (TYPEOF(p)==LISTSXP) { if (TAG(p) && isSymbol(TAG(p))) { if (TAG(p)==install("silent") && isLogical(CAR(p)) && LENGTH(CAR(p))==1) silent=LOGICAL(CAR(p))[0]; /* class.loader */ if (TAG(p)==install("class.loader")) { SEXP e = CAR(p); if (TYPEOF(e) == S4SXP && IS_JOBJREF(e)) { SEXP sref = GET_SLOT(e, install("jobj")); if (sref && TYPEOF(sref) == EXTPTRSXP) { jverify(sref); loader = (jobject)EXTPTR_PTR(sref); } } else if (e != R_NilValue) Rf_error("invalid class.loader"); } } p = CDR(p); } if (!loader) loader = oClassLoader; BEGIN_RJAVA_CALL o = createObject(env, class, sig.sig, jpar, silent, loader); END_RJAVA_CALL done_sigbuf(&sig); Rfreejpars(env, tmpo); if (!o) return R_NilValue; #ifdef RJ_DEBUG { jstring s=callToString(env, o); const char *c="???"; if (s) c=(*env)->GetStringUTFChars(env, s, 0); rjprintf(" new Java object [%s] reference %lx (local)\n", c, (long)o); if (s) { (*env)->ReleaseStringUTFChars(env, s, c); releaseObject(env, s); } } #endif return j2SEXP(env, o, 1); } /** returns the name of an object's class (in the form of R string) */ static SEXP getObjectClassName(JNIEnv *env, jobject o) { jclass cls; jobject r; char cn[128]; if (!o) return mkString("java/jang/Object"); cls = objectClass(env, o); if (!cls) return mkString("java/jang/Object"); r = (*env)->CallObjectMethod(env, cls, mid_getName); _mp(MEM_PROF_OUT(" %08x LNEW object getName result\n", (int) r)) if (!r) { releaseObject(env, cls); releaseObject(env, r); error("unable to get class name"); } cn[127]=0; *cn=0; { int sl = (*env)->GetStringLength(env, r); if (sl>127) { releaseObject(env, cls); releaseObject(env, r); error("class name is too long"); } if (sl) (*env)->GetStringUTFRegion(env, r, 0, sl, cn); } { char *c=cn; while(*c) { if (*c=='.') *c='/'; c++; } } releaseObject(env, cls); releaseObject(env, r); return mkString(cn); } /** creates a new jobjRef object. If klass is NULL then the class is determined from the object (if also o=NULL then the class is set to java/lang/Object) */ HIDE SEXP new_jobjRef(JNIEnv *env, jobject o, const char *klass) { SEXP oo = PROTECT(NEW_OBJECT(PROTECT(MAKE_CLASS("jobjRef")))); if (!inherits(oo, "jobjRef")) error("unable to create jobjRef object"); SET_SLOT(oo, install("jclass"), PROTECT(klass ? mkString(klass) : getObjectClassName(env, o))); SET_SLOT(oo, install("jobj"), PROTECT(j2SEXP(env, o, 1))); UNPROTECT(4); return oo; } /** * creates a new jclassName object. similar to what the jclassName * function does in the R side * * @param env pointer to the jni env * @param cl Class instance */ HIDE SEXP new_jclassName(JNIEnv *env, jobject/*Class*/ cl ) { SEXP oo = PROTECT(NEW_OBJECT(PROTECT(MAKE_CLASS("jclassName")))); if (!inherits(oo, "jclassName")) error("unable to create jclassName object"); SET_SLOT(oo, install("name"), PROTECT(getName(env, cl)) ); SET_SLOT(oo, install("jobj"), PROTECT(new_jobjRef( env, cl, "java/lang/Class" )) ); UNPROTECT(4); return oo; } /** Calls the Class.getName method and return the result as an R STRSXP */ HIDE SEXP getName( JNIEnv *env, jobject/*Class*/ cl){ char cn[128]; jstring r = (*env)->CallObjectMethod(env, cl, mid_getName); cn[127]=0; *cn=0; int sl = (*env)->GetStringLength(env, r); if (sl>127) { error("class name is too long"); } if (sl) (*env)->GetStringUTFRegion(env, r, 0, sl, cn); char *c=cn; while(*c) { if (*c=='.') *c='/'; c++; } SEXP res = mkString(cn); releaseObject(env, r); return res; } static SEXP new_jarrayRef(JNIEnv *env, jobject a, const char *sig) { /* it is too tedious to try to do this in C, so we use 'new' R function instead */ /* SEXP oo = eval(LCONS(install("new"),LCONS(mkString("jarrayRef"),R_NilValue)), R_GlobalEnv); */ SEXP oo = PROTECT(NEW_OBJECT(PROTECT(MAKE_CLASS("jarrayRef")))); /* .. and set the slots in C .. */ if (! IS_JARRAYREF(oo) ) error("unable to create an array"); SET_SLOT(oo, install("jobj"), PROTECT(j2SEXP(env, a, 1))); SET_SLOT(oo, install("jclass"), PROTECT(mkString(sig))); SET_SLOT(oo, install("jsig"), PROTECT(mkString(sig))); UNPROTECT(5); return oo; } #if 0 /* FIXME: no longer used */ /** * Creates a reference to a rectangular java array. * * @param env * @param a the java object * @param sig signature (class of the array object) * @param dim dimension vector */ static SEXP new_jrectRef(JNIEnv *env, jobject a, const char *sig, SEXP dim ) { /* it is too tedious to try to do this in C, so we use 'new' R function instead */ /* SEXP oo = eval(LCONS(install("new"),LCONS(mkString("jrectRef"),R_NilValue)), R_GlobalEnv); */ SEXP oo = PROTECT(NEW_OBJECT(PROTECT(MAKE_CLASS("jrectRef")))); /* .. and set the slots in C .. */ if (! IS_JRECTREF(oo) ) error("unable to create an array"); SET_SLOT(oo, install("jobj"), PROTECT(j2SEXP(env, a, 1))); SET_SLOT(oo, install("jclass"), PROTECT(mkString(sig))); SET_SLOT(oo, install("jsig"), PROTECT(mkString(sig))); SET_SLOT(oo, install("dimension"), dim); UNPROTECT(5); /* oo + slots */ return oo; } #endif /* this does not take care of multi dimensional arrays properly */ /** * Creates a one dimensional java array * * @param an R list or vector * @param cl the class name */ REPC SEXP RcreateArray(SEXP ar, SEXP cl) { JNIEnv *env=getJNIEnv(); if (ar==R_NilValue) return R_NilValue; switch(TYPEOF(ar)) { case INTSXP: { if (inherits(ar, "jbyte")) { jbyteArray a = newByteArrayI(env, INTEGER(ar), LENGTH(ar)); if (!a) error("unable to create a byte array"); return new_jarrayRef(env, a, "[B" ) ; } else if (inherits(ar, "jchar")) { jcharArray a = newCharArrayI(env, INTEGER(ar), LENGTH(ar)); if (!a) error("unable to create a char array"); return new_jarrayRef(env, a, "[C" ); } else if (inherits(ar, "jshort")) { jshortArray a = newShortArrayI(env, INTEGER(ar), LENGTH(ar)); if (!a) error("unable to create a short integer array"); return new_jarrayRef(env, a, "[S"); } else { jintArray a = newIntArray(env, INTEGER(ar), LENGTH(ar)); if (!a) error("unable to create an integer array"); return new_jarrayRef(env, a, "[I"); } } case REALSXP: { if (inherits(ar, "jfloat")) { jfloatArray a = newFloatArrayD(env, REAL(ar), LENGTH(ar)); if (!a) error("unable to create a float array"); return new_jarrayRef(env, a, "[F"); } else if (inherits(ar, "jlong")){ jlongArray a = newLongArrayD(env, REAL(ar), LENGTH(ar)); if (!a) error("unable to create a long array"); return new_jarrayRef(env, a, "[J"); } else { jdoubleArray a = newDoubleArray(env, REAL(ar), LENGTH(ar)); if (!a) error("unable to create double array"); return new_jarrayRef(env, a, "[D"); } } case STRSXP: { jobjectArray a = (*env)->NewObjectArray(env, LENGTH(ar), javaStringClass, 0); int i = 0; if (!a) error("unable to create a string array"); while (i < LENGTH(ar)) { SEXP sa = STRING_ELT(ar, i); if (sa != R_NaString) { jobject so = newJavaString(env, sa); (*env)->SetObjectArrayElement(env, a, i, so); releaseObject(env, so); } i++; } return new_jarrayRef(env, a, "[Ljava/lang/String;"); } case LGLSXP: { /* ASSUMPTION: LOGICAL()=int* */ jbooleanArray a = newBooleanArrayI(env, LOGICAL(ar), LENGTH(ar)); if (!a) error("unable to create a boolean array"); return new_jarrayRef(env, a, "[Z"); } case VECSXP: { int i=0; jclass ac = javaObjectClass; const char *sigName = 0; char buf[256]; while (i0) { const char *cname = CHAR_UTF8(STRING_ELT(cl, 0)); if (cname) { ac = findClass(env, cname, oClassLoader); if (!ac) error("Cannot find class %s.", cname); if (strlen(cname)<253) { /* it's valid to have [* for class name (for mmulti-dim arrays), but then we cannot add [L..; */ if (*cname == '[') { /* we have to add [ prefix to the signature */ buf[0] = '['; strcpy(buf+1, cname); } else { buf[0] = '['; buf[1] = 'L'; strcpy(buf+2, cname); strcat(buf,";"); } sigName = buf; } } } /* if contents class specified */ { jobjectArray a = (*env)->NewObjectArray(env, LENGTH(ar), ac, 0); _mp(MEM_PROF_OUT(" %08x LNEW object[%d]\n", (int)a, LENGTH(ar))) if (ac != javaObjectClass) releaseObject(env, ac); i=0; if (!a) error("Cannot create array of objects."); while (i < LENGTH(ar)) { SEXP e = VECTOR_ELT(ar, i); jobject o = 0; if (e != R_NilValue) { SEXP sref = GET_SLOT(e, install("jobj")); if (sref && TYPEOF(sref) == EXTPTRSXP) { jverify(sref); o = (jobject)EXTPTR_PTR(sref); } } (*env)->SetObjectArrayElement(env, a, i, o); i++; } return new_jarrayRef(env, a, sigName?sigName:"[Ljava/lang/Object;"); } } case RAWSXP: { jbyteArray a = newByteArray(env, RAW(ar), LENGTH(ar)); if (!a) error("unable to create a byte array"); return new_jarrayRef(env, a, "[B"); } } error("Unsupported type to create Java array from."); return R_NilValue; } /** check whether there is an exception pending and return the exception if any (NULL otherwise) */ REPC SEXP RpollException(void) { JNIEnv *env=getJNIEnv(); jthrowable t; BEGIN_RJAVA_CALL t=(*env)->ExceptionOccurred(env); END_RJAVA_CALL _mp(MEM_PROF_OUT(" %08x LNEW RpollException throwable\n", (int)t)) return t?j2SEXP(env, t, 1):R_NilValue; } /** clear any pending exceptions */ REP void RclearException(void) { JNIEnv *env=getJNIEnv(); BEGIN_RJAVA_CALL (*env)->ExceptionClear(env); END_RJAVA_CALL } REPC SEXP javaObjectCache(SEXP o, SEXP what) { if (TYPEOF(o) != EXTPTRSXP) error("invalid object"); if (TYPEOF(what) == RAWSXP || what == R_NilValue) { /* set PROT to the serialization of NULL */ R_SetExternalPtrProtected(o, what); return what; } if (TYPEOF(what) == LGLSXP) return EXTPTR_PROT(o); error("invalid argument"); return R_NilValue; } REPC SEXP RthrowException(SEXP ex) { JNIEnv *env=getJNIEnv(); jthrowable t=0; SEXP exr; int tr=0; SEXP res; if (!inherits(ex, "jobjRef")) error("Invalid throwable object."); exr=GET_SLOT(ex, install("jobj")); if (exr && TYPEOF(exr)==EXTPTRSXP) { jverify(exr); t=(jthrowable)EXTPTR_PTR(exr); } if (!t) error("Throwable must be non-null."); BEGIN_RJAVA_CALL tr = (*env)->Throw(env, t); END_RJAVA_CALL res = allocVector(INTSXP, 1); INTEGER(res)[0]=tr; return res; } extern int existingJVMs(void); /* init.c */ REPC SEXP RgetJVMstate(void) { const char *names[] = { "initialized", "state", "" }; SEXP res = PROTECT(Rf_mkNamed(VECSXP, names)); const char *st = "unknown"; switch (rJava_JVM_state) { case JVM_STATE_NONE: /* could be detached */ st = (existingJVMs() > 0) ? "detached" : "none"; break; case JVM_STATE_CREATED: st = "created"; break; case JVM_STATE_ATTACHED: st = "attached"; break; case JVM_STATE_DEAD: st = "dead"; break; case JVM_STATE_DESTROYED: st = "destroyed"; break; } SET_VECTOR_ELT(res, 0, Rf_ScalarLogical(rJava_initialized)); SET_VECTOR_ELT(res, 1, Rf_mkString(st)); UNPROTECT(1); return res; } rJava/src/otables.c0000644000175100001440000001303315133274032013717 0ustar hornikusers#include "rJava.h" #define RJAVA_LOOKUP 23 /* This uses the mechanism of the RObjectTables package see: http://www.omegahat.org/RObjectTables/ */ /** * Returns the R_UnboundValue */ HIDE SEXP R_getUnboundValue(void) { return(R_UnboundValue); } /** * @param name name of a java class * @param canCache Can R cache this object * @param tb * @return TRUE if the a class called name exists in on of the packages */ /* not actually used by R */ HIDE Rboolean rJavaLookupTable_exists(const char * const name, Rboolean *canCache, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_exists\n" ); #endif if(tb->active == FALSE) return(FALSE); tb->active = FALSE; Rboolean val = classNameLookupExists( tb, name ); tb->active = TRUE; return( val ); } /** * Returns a new jclassName object if the class exists or the * unbound value if it does not * * @param name class name * @param canCache ?? * @param tb lookup table */ SEXP rJavaLookupTable_get(const char * const name, Rboolean *canCache, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_get\n" ); #endif SEXP val; if(tb->active == FALSE) return(R_UnboundValue); tb->active = FALSE; val = PROTECT( classNameLookup( tb, name ) ); tb->active = TRUE; UNPROTECT(1); /* val */ return(val); } /** * Does nothing. Not applicable to java packages */ int rJavaLookupTable_remove(const char * const name, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_remove( %s) \n", name ); #endif error( "cannot remove from java package" ) ; return 0; } /** * Indicates if R can cache the variable name. * Currently always return FALSE * * @param name name of the class * @param tb lookup table * @return always FALSE (for now) */ HIDE Rboolean rJavaLookupTable_canCache(const char * const name, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_canCache\n" ); #endif return( FALSE ); } /** * Generates an error. assign is not possible on our lookup table */ HIDE SEXP rJavaLookupTable_assign(const char * const name, SEXP value, R_ObjectTable *tb){ #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_assign( %s ) \n", name ); #endif error("can't assign to java package lookup"); return R_NilValue; } /** * Returns the list of classes known to be included in the * packages. Currently returns NULL * * @param tb lookup table */ HIDE SEXP rJavaLookupTable_objects(R_ObjectTable *tb) { #ifdef LOOKUP_DEBUG Rprintf( " >> rJavaLookupTable_objects\n" ); #endif tb->active = FALSE; SEXP res = PROTECT( getKnownClasses( tb ) ) ; tb->active = TRUE; UNPROTECT(1); /* res */ return( res ); } REPC SEXP newRJavaLookupTable(SEXP importer){ #ifdef LOOKUP_DEBUG Rprintf( "\n" ); #endif R_ObjectTable *tb; SEXP val, klass; tb = (R_ObjectTable *) malloc(sizeof(R_ObjectTable)); if(!tb) error( "cannot allocate space for an internal R object table" ); tb->type = RJAVA_LOOKUP ; /* FIXME: not sure what this should be */ tb->cachedNames = NULL; R_PreserveObject(importer); tb->privateData = importer; tb->exists = rJavaLookupTable_exists; tb->get = rJavaLookupTable_get; tb->remove = rJavaLookupTable_remove; tb->assign = rJavaLookupTable_assign; tb->objects = rJavaLookupTable_objects; tb->canCache = rJavaLookupTable_canCache; tb->onAttach = NULL; tb->onDetach = NULL; PROTECT(val = R_MakeExternalPtr(tb, install("UserDefinedDatabase"), R_NilValue)); PROTECT(klass = NEW_CHARACTER(1)); SET_STRING_ELT(klass, 0, COPY_TO_USER_STRING("UserDefinedDatabase")); SET_CLASS(val, klass); UNPROTECT(2); #ifdef LOOKUP_DEBUG Rprintf( "\n" ); #endif return(val); } HIDE jobject getImporterReference(R_ObjectTable *tb ){ jobject res = (jobject)EXTPTR_PTR( GET_SLOT( (SEXP)(tb->privateData), install( "jobj" ) ) ); #ifdef LOOKUP_DEBUG Rprintf( " >> getImporterReference : [%d]\n", res ); #endif return res ; } HIDE SEXP getKnownClasses( R_ObjectTable *tb ){ #ifdef LOOKUP_DEBUG Rprintf( " >> getKnownClasses\n" ); #endif jobject importer = getImporterReference(tb); JNIEnv *env=getJNIEnv(); jarray a = (jarray) (*env)->CallObjectMethod(env, importer, mid_RJavaImport_getKnownClasses ) ; SEXP res = PROTECT( getStringArrayCont( a ) ) ; #ifdef LOOKUP_DEBUG Rprintf( " %d known classes\n", LENGTH(res) ); #endif UNPROTECT(1); return res ; } HIDE SEXP classNameLookup( R_ObjectTable *tb, const char * const name ){ #ifdef LOOKUP_DEBUG Rprintf( " >> classNameLookup\n" ); #endif JNIEnv *env=getJNIEnv(); jobject importer = getImporterReference(tb); jobject clazz = newString(env, name ) ; jstring s ; /* Class */ s = (jstring) (*env)->CallObjectMethod(env, importer, mid_RJavaImport_lookup, clazz ) ; SEXP res ; int np ; if( !s ){ res = R_getUnboundValue() ; np = 0; } else{ PROTECT( res = new_jclassName( env, s ) ); np = 1; } releaseObject(env, clazz); releaseObject(env, s); if( np ) UNPROTECT(1); #ifdef LOOKUP_DEBUG Rprintf( "\n" ); #endif return res ; } HIDE Rboolean classNameLookupExists(R_ObjectTable *tb, const char * const name ){ #ifdef LOOKUP_DEBUG Rprintf( " classNameLookupExists\n" ); #endif JNIEnv *env=getJNIEnv(); jobject importer = getImporterReference(tb); jobject clazz = newString(env, name ) ; jboolean s ; /* Class */ s = (jboolean) (*env)->CallBooleanMethod(env, importer, mid_RJavaImport_exists , clazz ) ; Rboolean res = (s) ? TRUE : FALSE; #ifdef LOOKUP_DEBUG Rprintf( " exists( %s ) = %d \n", name, res ); #endif releaseObject(env, clazz); return res ; } rJava/src/rjstring.c0000644000175100001440000001624015133274032014133 0ustar hornikusers#include "rjstring.h" #include #include #include #include #ifdef WIN32 /* -- currently unused - was used to mimick reEnc() extern unsigned int localeCP; static char cpbuf[16]; */ #endif static jchar js_zero[2] = { 0, 0 }; static jchar js_buf[128]; /* if len = -1 then c is assumed to be NUL terminated */ int rj_char_utf16(const char *c, int len, jchar **buf, const char *ifrom, int can_error) { void *ih; const char *ce = (len < 0) ? strchr(c, 0) : (c + len); if (ce == c) { buf[0] = js_zero; return 0; } size_t osize = sizeof(jchar) * (ce - c + 1), isize = ce - c; jchar *js = buf[0] = (osize < sizeof(js_buf)) ? js_buf : (jchar*) R_alloc(sizeof(jchar), ce - c + 1); char *dst = (char*) js; int end_test = 1, is_le = (((char*)&end_test)[0] == 1) ? 1 : 0; if (!ifrom) ifrom = ""; #ifdef DEBUG_ENCODING fprintf(stderr, "rJava.rj_char_utf16_native:"); { const char *c0 = c; while (*c0) fprintf(stderr, " %02x", (int)((unsigned char)*(c0++))); } fprintf(stderr, "\n"); #endif ih = Riconv_open(is_le ? "UTF-16LE" : "UTF-16BE", ifrom); if (ih == (void *)(-1)) { if (can_error) Rf_error("Unable to start conversion to UTF-16"); return -1; } while (c < ce) { size_t res = Riconv(ih, &c, &isize, &dst, &osize); /* this should never happen since we allocated far more than needed */ if (res == -1 && errno == E2BIG) { if (can_error) Rf_error("Conversion to UTF-16 failed due to unexpectedly large buffer requirements."); return -1; } else if(res == -1 && (errno == EILSEQ || errno == EINVAL)) { /* invalid char */ if (is_le) { *(dst++) = '?'; *(dst++) = 0; } else { *(dst++) = 0; *(dst++) = '?'; } osize -= 2; c++; isize--; } } Riconv_close(ih); #ifdef DEBUG_ENCODING { const jchar *j = js; while (j < (const jchar*)dst) fprintf(stderr, " %04x", (unsigned int)*(j++)); } fprintf(stderr, "\n"); #endif return dst - (char*) js; } /* returns string from a CHARSXP making sure that the result is in UTF-16. the buffer is owned by the function and may be static, so copy after use. Returns the length of the resulting string or -1 on error (if can_error is 0). */ static int rj_CHARSXP_utf16_(SEXP s, jchar **buf, int can_error) { cetype_t ce_in = getCharCE(s); const char *ifrom = "", *c = CHAR(s), *ce = strchr(c, 0); if (ce == c) { buf[0] = js_zero; return 0; } switch (ce_in) { #ifdef WIN32 case CE_NATIVE: /* reEnc uses this, but translateCharUtf8 uses "" so let's go with "" sprintf(cpbuf, "CP%d", localeCP); ifrom = cpbuf; */ break; case CE_LATIN1: ifrom = "CP1252"; break; #else case CE_NATIVE: break; /* is already "" */ case CE_LATIN1: ifrom = "latin1"; break; #endif default: ifrom = "UTF-8"; break; } return rj_char_utf16(c, ce - c, buf, ifrom, can_error); } int rj_rchar_utf16(SEXP s, jchar **buf) { return rj_CHARSXP_utf16_(s, buf, 1); } int rj_rchar_utf16_noerr(SEXP s, jchar **buf) { return rj_CHARSXP_utf16_(s, buf, 0); } /* FIXME: we should probably deprecate this as well and use UTF-16 instead. The only reason not to is that we would have to fully implement a full UTF-16 -> UTF-8 conversion including surrogate pairs ... */ /* Java returns *modified* UTF-8 which is incompatible with UTF-8, so we have to detect the illegal surrgoate pairs and convert them */ SEXP rj_mkCharUTF8_(const char *src, int can_error) { const unsigned char *s = (const unsigned char*) src; const unsigned char *c = (const unsigned char*) s; /* check if the string contains any surrogate pairs, i.e. Unicode in the range 0xD800-0xDFFF We want this to be fast since in 99.99% of cases it will be false */ while (*c) { if (c[0] == 0xED && (c[1] & 0xE0) == 0xA0) break; c++; } if (*c) { /* yes, we have to convert them */ SEXP res; const unsigned char *e = (const unsigned char*) strchr((const char*)s, 0); /* find the end for size */ unsigned char *dst = 0, *d, sbuf[64]; if (!e) /* should never occur */ return mkChar(""); /* we use static buffer for small strings and dynamic alloc for large */ if (e - s >= sizeof(sbuf)) { /* allocate temp buffer since our input is const */ d = dst = (unsigned char *) malloc(e - s + 1); if (!dst) { if (can_error) Rf_error("Cannot allocate memory for surrogate pair conversion"); return 0; } } else d = (unsigned char *)sbuf; if (c - s > 0) { memcpy(d, s, c - s); d += c - s; } while (*c) { unsigned int u1, u; *(d++) = *(c++); /* start of a sequence ? */ if ((c[-1] & 0xC0) != 0xC0) continue; if ((c[-1] & 0xE0) == 0xC0) { /* 2-byte, not a surrogate pair */ if ((c[0] & 0xC0) != 0x80) { if (dst) free(dst); if (can_error) Rf_error("illegal 2-byte sequence in Java string"); return 0; } *(d++) = *(c++); continue; } if ((c[-1] & 0xF0) != 0xE0) { /* must be 3-byte */ if (dst) free(dst); if (can_error) Rf_error("illegal multi-byte seqeunce in Java string (>3-byte)"); return 0; } if (((c[0] & 0xC0) != 0x80 || (c[1] & 0xC0) != 0x80)) { if (dst) free(dst); if (can_error) Rf_error("illegal 3-byte sequence in Java string"); return 0; } u1 = ((((unsigned int)c[-1]) & 0x0F) << 12) | ((((unsigned int)c[0]) & 0x3F) << 6) | (((unsigned int)c[1]) & 0x3F); if (u1 < 0xD800 || u1 > 0xDBFF) { /* not a surrogate pair -> regular copy */ *(d++) = *(c++); *(d++) = *(c++); continue; } if (u1 >= 0xDC00 && u1 <= 0xDFFF) { /* low surrogate pair ? */ if (dst) free(dst); if (can_error) Rf_error("illegal sequence in Java string: low surrogate pair without a high one"); return 0; } c += 2; /* move to the low pair */ if (c[0] != 0xED || (c[1] & 0xF0) != 0xB0 || (c[2] & 0xC0) != 0x80) { if (dst) free(dst); if (can_error) Rf_error("illegal sequence in Java string: high surrogate pair not followed by low one"); return 0; } /* the actually encoded unicode character */ u = ((((unsigned int)c[1]) & 0x0F) << 6) | (((unsigned int)c[2]) & 0x3F); u |= (u1 & 0x03FF) << 10; u += 0x10000; c += 3; /* it must be <= 0x10FFFF by design (each surrogate has 10 bits) */ d[-1] = (unsigned char) (((u >> 18) & 0x0F) | 0xF0); *(d++) = (unsigned char) (((u >> 12) & 0x3F) | 0x80); *(d++) = (unsigned char) (((u >> 6) & 0x3F) | 0x80); *(d++) = (unsigned char) ((u & 0x3F) | 0x80); } res = mkCharLenCE((const char*) (dst ? dst : sbuf), dst ? (d - dst) : (d - sbuf), CE_UTF8); if (dst) free(dst); return res; } return mkCharLenCE(src, c - s, CE_UTF8); } SEXP rj_mkCharUTF8(const char *src) { return rj_mkCharUTF8_(src, 0); } SEXP rj_mkCharUTF8_noerr(const char *src) { return rj_mkCharUTF8_(src, 1); } jstring rj_newJavaString(JNIEnv *env, SEXP sChar) { jchar *s; int len = rj_rchar_utf16(sChar, &s); return (*env)->NewString(env, s, (len + 1) >> 1); } jstring rj_newNativeJavaString(JNIEnv *env, const char *str, int len) { jchar *s; int rlen = rj_char_utf16(str, len, &s, "", 0); return (rlen < 0) ? 0 : (*env)->NewString(env, s, (rlen + 1) >> 1); } rJava/src/tools.c0000644000175100001440000001052215133274032013426 0ustar hornikusers/* misc. utility functions, mostly callable from R * * rJava R/Java interface (C)Copyright 2003-2007 Simon Urbanek * (see rJava project root for licensing details) */ #include "rJava.h" /** jobjRefInt object : string */ REPE SEXP RgetStringValue(SEXP par) { SEXP p,e,r; jstring s; const char *c; JNIEnv *env=getJNIEnv(); profStart(); p=CDR(par); e=CAR(p); p=CDR(p); if (e==R_NilValue) return R_NilValue; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); s = (jstring)EXTPTR_PTR(e); } else { error("invalid object parameter"); s = 0; } if (!s) return R_NilValue; c=(*env)->GetStringUTFChars(env, s, 0); if (!c) error("cannot retrieve string content"); r = PROTECT(allocVector(STRSXP, 1)); SET_STRING_ELT(r, 0, mkCharUTF8(c)); UNPROTECT(1); (*env)->ReleaseStringUTFChars(env, s, c); _prof(profReport("RgetStringValue:")); return r; } /** calls .toString() of the object and returns the corresponding string java object */ HIDE jstring callToString(JNIEnv *env, jobject o) { jclass cls; jmethodID mid; jstring s; if (!o) { _dbg(rjprintf("callToString: invoked on a NULL object\n")); return 0; } cls=objectClass(env,o); if (!cls) { _dbg(rjprintf("callToString: can't determine class of the object\n")); releaseObject(env, cls); checkExceptionsX(env, 1); return 0; } mid=(*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;"); if (!mid) { _dbg(rjprintf("callToString: toString not found for the object\n")); releaseObject(env, cls); checkExceptionsX(env, 1); return 0; } BEGIN_RJAVA_CALL; s = (jstring)(*env)->CallObjectMethod(env, o, mid); END_RJAVA_CALL; _mp(MEM_PROF_OUT(" %08x LNEW object method toString result\n", (int) s)) releaseObject(env, cls); return s; } /** calls .toString() on the passed object (int/extptr) and returns the string value or NULL if there is no toString method */ REPE SEXP RtoString(SEXP par) { SEXP p,e,r; jstring s; jobject o; const char *c; JNIEnv *env=getJNIEnv(); p=CDR(par); e=CAR(p); p=CDR(p); if (e==R_NilValue) return R_NilValue; if (TYPEOF(e)==EXTPTRSXP) { jverify(e); o=(jobject)EXTPTR_PTR(e); } else error_return("RtoString: invalid object parameter"); if (!o) return R_NilValue; s=callToString(env, o); if (!s) { return R_NilValue; } c=(*env)->GetStringUTFChars(env, s, 0); PROTECT(r=allocVector(STRSXP,1)); SET_STRING_ELT(r, 0, mkCharUTF8(c)); UNPROTECT(1); (*env)->ReleaseStringUTFChars(env, s, c); releaseObject(env, s); return r; } /* compares two references */ REPC SEXP RidenticalRef(SEXP ref1, SEXP ref2) { SEXP r; if (TYPEOF(ref1)!=EXTPTRSXP || TYPEOF(ref2)!=EXTPTRSXP) return R_NilValue; jverify(ref1); jverify(ref2); r=allocVector(LGLSXP,1); LOGICAL(r)[0]=(R_ExternalPtrAddr(ref1)==R_ExternalPtrAddr(ref2)); return r; } /** create a NULL external reference */ REPC SEXP RgetNullReference(void) { return R_MakeExternalPtr(0, R_NilValue, R_NilValue); } /** TRUE if cl1 x; cl2 y = (cl2) x ... is valid */ REPC SEXP RisAssignableFrom(SEXP cl1, SEXP cl2) { SEXP r; JNIEnv *env=getJNIEnv(); if (TYPEOF(cl1)!=EXTPTRSXP || TYPEOF(cl2)!=EXTPTRSXP) error("invalid type"); if (!env) error("VM not initialized"); jverify(cl1); jverify(cl2); r=allocVector(LGLSXP,1); LOGICAL(r)[0]=((*env)->IsAssignableFrom(env, (jclass)EXTPTR_PTR(cl1), (jclass)EXTPTR_PTR(cl2))); return r; } REPC SEXP RJava_checkJVM(void) { SEXP r = allocVector(LGLSXP, 1); LOGICAL(r)[0] = 0; if (!jvm || !getJNIEnv()) return r; LOGICAL(r)[0] = 1; return r; } extern int rJava_initialized; /* in callJNI.c */ REPC SEXP RJava_needs_init(void) { SEXP r = allocVector(LGLSXP, 1); LOGICAL(r)[0] = rJava_initialized?0:1; return r; } REPC SEXP RJava_set_memprof(SEXP fn) { #ifdef MEMPROF const char *cFn = CHAR(STRING_ELT(fn, 0)); int env = 0; /* we're just faking it so we can call MEM_PROF_OUT */ if (memprof_f) fclose(memprof_f); if (cFn && !cFn[0]) { memprof_f = 0; return R_NilValue; } if (!cFn || (cFn[0]=='-' && !cFn[1])) memprof_f = stdout; else memprof_f = fopen(cFn, "a"); if (!memprof_f) error("Cannot create memory profile file."); MEM_PROF_OUT(" 00000000 REST -- profiling file set --\n"); return R_NilValue; #else error("Memory profiling support was not enabled in rJava."); #endif return R_NilValue; } rJava/src/install.libs.R0000644000175100001440000000526115133274032014647 0ustar hornikusers## the first part just replicates the default installation of libs libarch <- if (nzchar(R_ARCH)) paste("libs", R_ARCH, sep='') else "libs" dest <- file.path(R_PACKAGE_DIR, libarch) files <- Sys.glob(paste("*", SHLIB_EXT, sep='')) if (length(files)) { dir.create(dest, recursive = TRUE, showWarnings = FALSE) file.copy(files, dest, overwrite = TRUE) if (nzchar(Sys.getenv("PKG_MAKE_DSYM")) && length(grep("^darwin", R.version$os))) { message('generating debug symbols (dSYM)') dylib <- Sys.glob(paste(dest, "/*", SHLIB_EXT, sep='')) if (length(dylib)) for (file in dylib) system(paste("dsymutil ", file, sep='')) } } # just a wrapper to system() that shows what we are doing ... sys <- function(x, ...) { message(x) s <- system(x, ...) # if (!isTRUE(s == 0L)) message("-> FAILED") s } ## the next part is about JRI ## on OS X we need to merge architectures into one fat file if (length(grep("^darwin", R.version$os))) { is.fat <- function(fn) { a <- 0L; try({f <- file(fn, "rb"); a <- readBin(f, 1L, 1L); close(f)}, silent=TRUE); isTRUE(a[1] == -1095041334L || a[1] == -889275714L) } ## fat magic is 0xCAFEBABE - either endianness jni <- "../jri/libjri.jnilib" if (isTRUE(file.exists(jni))) { ## continue only if JRI was actually compiled dir.create(file.path(R_PACKAGE_DIR, "jri"), recursive = TRUE, showWarnings = FALSE) dest <- file.path(R_PACKAGE_DIR, "jri", "libjri.jnilib") if (is.fat(jni) || !file.exists(dest)) { ## if the new file is fat we assume it has all archs so we copy; if there is no dest, copy as well file.copy(jni, dest, overwrite = TRUE) } else { ## new file is single arch, so merge ## we try lipo -create first and fall back to -replace if it doesn't work (becasue the arch exists already) if (sys(paste("/usr/bin/lipo -create", shQuote(dest), jni, "-o", shQuote(dest), ">/dev/null 2>&1")) != 0) { if (is.fat(dest)) { # if the file is fat, replace, otherwise it means we have the same arch so copy arch <- gsub("/", "", R_ARCH, fixed=TRUE) sys(paste("/usr/bin/lipo -replace", arch, jni, shQuote(dest), "-o", shQuote(dest), ">/dev/null 2>&1")) } else file.copy(jni, dest, overwrite = TRUE) } } } } else { ## on other platforms we simply install in jri$(R_ARCH) jri <- if (WINDOWS) "jri.dll" else "libjri.so" jni <- file.path("..", "jri", jri) if (isTRUE(file.exists(jni))) { ## continue only if JRI was actually compiled libarch <- if (nzchar(R_ARCH)) paste("jri", R_ARCH, sep='') else "jri" dir.create(file.path(R_PACKAGE_DIR, libarch), recursive = TRUE, showWarnings = FALSE) dest <- file.path(R_PACKAGE_DIR, libarch, jri) file.copy(jni, dest, overwrite = TRUE) } } rJava/src/callback.c0000644000175100001440000000327015133274032014024 0ustar hornikusers#include "rJava.h" #ifdef ENABLE_JRICB #include #include #include "callback.h" int RJava_has_control = 0; /* ipcin -> receives requests on R thread ipcout <- write to place requests to main R thread resout <- written by main thread to respond resin -> read to get info from main thread */ static int ipcin, ipcout, resin, resout; static struct rJavaInfoBlock_s { int ipcin, ipcout, resin, resout; int *has_control; } rJavaInfoBlock; struct rJavaInfoBlock_s *RJava_get_info_block() { return &rJavaInfoBlock; } typedef void(callbackfn)(void*); static void RJava_ProcessEvents(void *data) { long buf[4]; int n = read(ipcin, buf, sizeof(long)); if (buf[0] == IPCC_LOCK_REQUEST) { RJava_has_control = 1; buf[0] = IPCC_LOCK_GRANTED; write(resout, buf, sizeof(long)); n = read(ipcin, buf, sizeof(long)); } if (buf[0] == IPCC_CLEAR_LOCK) { RJava_has_control = 0; } if (buf[0] == IPCC_CONTROL_ADDR) { buf[1] = (long) (void*) &RJava_has_control; write(resout, buf, sizeof(long)*2); } if (buf[0] == IPCC_CALL_REQUEST) { callbackfn *fn; read(ipcin, buf+1, sizeof(long)*2); fn = (callbackfn*) buf[1]; RJava_has_control = 1; fn((void*) buf[2]); RJava_has_control = 0; } } int RJava_init_loop() { int pfd[2]; pipe(pfd); ipcin = pfd[0]; ipcout = pfd[1]; pipe(pfd); resin = pfd[0]; resout = pfd[1]; rJavaInfoBlock.ipcin = ipcin; rJavaInfoBlock.ipcout = ipcout; rJavaInfoBlock.resin = resin; rJavaInfoBlock.resout = resout; rJavaInfoBlock.has_control = &RJava_has_control; addInputHandler(R_InputHandlers, ipcin, RJava_ProcessEvents, RJavaActivity); return 0; } #endif rJava/NAMESPACE0000644000175100001440000000232315133274032012552 0ustar hornikusersexportPattern("^\\.j") export( "J" ) export( "%instanceof%" ) export( clone ) S3method( clone, default ) export(is.jnull, .r2j, .rJava.base.path, toJava) exportClasses(jobjRef, jarrayRef, jrectRef, jfloat, jlong, jbyte, jchar, jclassName) exportMethods(show, "$", "$<-", "==", "!=", "<", ">", "<=", ">=", names, new, as.character, length, head, tail, "[", "[[", "[[<-", str, "dim<-", unique, duplicated, anyDuplicated, sort, rev, min, max, range, rep, clone ) import(methods) importFrom(utils,head) importFrom(utils,tail) importFrom(utils,str) importFrom(utils, assignInNamespace) S3method(with, jobjRef) S3method(with, jarrayRef) S3method(with, jclassName) S3method(within, jobjRef) S3method(within, jarrayRef) S3method(within, jclassName) # within requires that with.jobjRef is visible outside export(with.jobjRef) if( exists( ".DollarNames", asNamespace("utils") ) ) importFrom( utils, .DollarNames ) S3method(.DollarNames, jobjRef) S3method(.DollarNames, jarrayRef) S3method(.DollarNames, jrectRef) S3method(.DollarNames, jclassName) S3method( as.list, jobjRef ) S3method( as.list, jarrayRef ) S3method( as.list, jrectRef ) S3method( "$", "Throwable" ) S3method( "$<-", "Throwable" ) export( javaImport ) rJava/configure.ac0000644000175100001440000003003715133274032013624 0ustar hornikusers# Process this file with autoconf to produce a configure script. AC_INIT([rJava],[0.8],[Simon.Urbanek@r-project.org]) AC_CONFIG_SRCDIR([src/rJava.c]) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_AUX_DIR([tools]) # find R home and set CC/CFLAGS : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi RBIN="${R_HOME}/bin/R" CC=`"${RBIN}" CMD config CC`; CFLAGS=`"${RBIN}" CMD config CFLAGS` LIBS="${PKG_LIBS}" AC_SUBST(R_HOME) RLD=`"${RBIN}" CMD config --ldflags 2>/dev/null` has_R_shlib=no if test -n "$RLD"; then has_R_shlib=yes fi ## enable threads, i.e. Java is running is a separate thread AC_ARG_ENABLE([threads], [AS_HELP_STRING([--enable-threads],[enable the use of threads, i.e. Java is run on a separate thread. This is necessary for some implementations of AWT. This feature is highly experimental, becasue of synchronization issues, so use with care. @<:@no@:>@])], [want_threads="${enableval}"], [want_threads=no]) ## enable JNI-cache AC_ARG_ENABLE([jni-cache], [AS_HELP_STRING([--enable-jni-cache],[enable support for caching of the JNI environment. With this option turned on, the JNI state is stored locally and re-used for subsequent calls. This will work *only* if no threads are used, because each thread has a separate JNI state. Enabling this option can give some performance boost for applications that call JNI very often. If used in a threaded environment, it is bound to crash, so use with care. @<:@no@:>@])], [want_jni_cache="${enableval}"], [want_jni_cache=no]) ## enable JRI AC_ARG_ENABLE([jri], [AS_HELP_STRING([--enable-jri],[enable Java to R interface (JRI), which allows Java programs to embed R. @<:@auto@:>@])], [want_jri="${enableval}"], [want_jri=auto]) ## enable headless AC_ARG_ENABLE([headless], [AS_HELP_STRING([--enable-headless],[enable initialization in headless mode. @<:@auto@:>@])], [want_headless="${enableval}"], [want_headless=auto]) ## enable -Xrs support AC_ARG_ENABLE([Xrs], [AS_HELP_STRING([--enable-Xrs],[use -Xrs in Java initialization. @<:@auto@:>@])], [want_xrs="${enableval}"], [want_xrs=auto]) ## enable dynloaded JVM AC_ARG_ENABLE([dynload], [AS_HELP_STRING([--enable-dynload],[load JVM dynamically (without linking). @<:@auto@:>@])], [want_dynload="${enableval}"], [want_dynload=auto]) ## enable debug flags AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],[enable debug flags and output. @<:@no@:>@])], [want_debug="${enableval}"], [want_debug=no]) ## enable memory profiling AC_ARG_ENABLE([mem-profile], [AS_HELP_STRING([--enable-mem-profile],[enable memory profiling. @<:@debug@:>@])], [want_memprof="${enableval}"], [want_memprof=debug]) ## enable callbacks (experimental) AC_ARG_ENABLE([callbacks], [AS_HELP_STRING([--enable-callbacks],[enable the support for callbacks from Java into R. This requires JRI and is currently experimental/incomplete. @<:@no@:>@])], [want_callbacks="${enableval}"], [want_callbacks=no]) # Checks for programs. AC_LANG(C) AC_PROG_CC # Checks for libraries. # Checks for header files. AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([string.h sys/time.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AS_MESSAGE([checking whether ${CC} supports static inline...]) can_inline=no AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ static inline int foo(int a, int b); static int f = 1; static inline int foo(int a, int b) { return a+b; } int main(void) { return foo(f,-1); } ]])],[can_inline=yes]) AC_MSG_RESULT(${can_inline}) if test "${can_inline}" = yes; then AC_DEFINE(HAVE_STATIC_INLINE, 1, [Define to 1 when static inline works]) fi ### from R m4/R.m4 - needed to hack R 2.9.x AC_CACHE_CHECK([whether setjmp.h is POSIX.1 compatible], [r_cv_header_setjmp_posix], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include ]], [[sigjmp_buf b; sigsetjmp(b, 0); siglongjmp(b, 1);]])], [r_cv_header_setjmp_posix=yes], [r_cv_header_setjmp_posix=no])]) AC_CHECK_DECLS([sigsetjmp, siglongjmp], , , [#include ]) if test "$ac_cv_have_decl_sigsetjmp" = no; then r_cv_header_setjmp_posix=no fi if test "$ac_cv_have_decl_siglongjmp" = no; then r_cv_header_setjmp_posix=no fi if test "${r_cv_header_setjmp_posix}" = yes; then AC_DEFINE(HAVE_POSIX_SETJMP, 1, [Define if you have POSIX.1 compatible sigsetjmp/siglongjmp.]) fi AC_MSG_CHECKING([Java support in R]) R_JAVA_HOME=`"${RBIN}" CMD config JAVA_HOME` : ${JAVA_HOME="${R_JAVA_HOME}"} if test -z "${JAVA_HOME}"; then AC_MSG_ERROR([absent R was configured without Java support. Please run R CMD javareconf as root to add Java support to R. If you do not have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava.]) fi : ${JAR=`"${RBIN}" CMD config JAR|sed 's/ERROR:.*//'`} : ${JAVA=`"${RBIN}" CMD config JAVA|sed 's/ERROR:.*//'`} : ${JAVAC=`"${RBIN}" CMD config JAVAC|sed 's/ERROR:.*//'`} : ${JAVAH=`"${RBIN}" CMD config JAVAH|sed 's/ERROR:.*//'`} : ${JAVA_CPPFLAGS=`"${RBIN}" CMD config JAVA_CPPFLAGS|sed 's/ERROR:.*//'`} : ${JAVA_LIBS=`"${RBIN}" CMD config JAVA_LIBS|sed 's/ERROR:.*//'`} AC_MSG_RESULT([present: interpreter : '${JAVA}' archiver : '${JAR}' compiler : '${JAVAC}' header prep.: '${JAVAH}' cpp flags : '${JAVA_CPPFLAGS}' java libs : '${JAVA_LIBS}']) java_error='One or more Java configuration variables are not set.' if test -z "${JAVA}"; then java_error='Java interpreter is missing or not registered in R' fi if test -z "${JAVAC}"; then java_error='Java Development Kit (JDK) is missing or not registered in R' fi have_all_flags=no if test -n "${JAVA}" && test -n "${JAVAC}" && \ test -n "${JAVA_CPPFLAGS}" && test -n "${JAVA_LIBS}" && test -n "${JAR}"; then have_all_flags=yes; fi if test "${have_all_flags}" = no; then AC_MSG_ERROR([${java_error} Make sure R is configured with full Java support (including JDK). Run R CMD javareconf as root to add Java support to R. If you don't have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava. ]) fi if test `echo foo | sed -e 's:foo:bar:'` = bar; then JAVA_CPPFLAGS0=`echo ${JAVA_CPPFLAGS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LD_LIBRARY_PATH0=`echo ${JAVA_LD_LIBRARY_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` else AC_MSG_WARN([sed is not working properly - the configuration may fail]) JAVA_CPPFLAGS0="${JAVA_CPPFLAGS}" JAVA_LIBS0="${JAVA_LIBS}" JAVA_LD_LIBRARY_PATH0="${JAVA_LD_LIBRARY_PATH}" fi OSNAME=`uname -s 2>/dev/null` LIBS="${LIBS} ${JAVA_LIBS0}" CFLAGS="${CFLAGS} ${JAVA_CPPFLAGS0}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${JAVA_LD_LIBRARY_PATH0}" if test "x$OSNAME" = xDarwin; then ## we need to pull that out of R in case re-export fails (which is does on 10.11) DYLD_FALLBACK_LIBRARY_PATH=`"${RBIN}" --slave --vanilla -e 'cat(Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH"))'` export DYLD_FALLBACK_LIBRARY_PATH fi AC_MSG_CHECKING([whether Java run-time works]) if "$JAVA" -classpath tools getsp; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) AC_MSG_ERROR([Java interpreter '$JAVA' does not work]) fi has_xrs="$want_xrs" if test x"$has_xrs" = xauto; then AC_MSG_CHECKING([whether -Xrs is supported]) if "$JAVA" -Xrs -classpath tools getsp; then has_xrs=yes else has_xrs=no fi AC_MSG_RESULT(${has_xrs}) fi AC_MSG_CHECKING([whether -Xrs will be used]) AC_MSG_RESULT(${has_xrs}) if test x"$has_xrs" = xyes; then AC_DEFINE(HAVE_XRS, 1, [Set if the Java parameter -Xrs is supported]) fi use_dynload="$want_dynload" if test x"$use_dynload" = xauto; then if test "x$OSNAME" = xDarwin; then use_dynload=yes else use_dynload=no fi fi if test x"$use_dynload" != xyes; then use_dynload=no fi AC_MSG_CHECKING([whether JVM will be loaded dynamically]) AC_MSG_RESULT(${use_dynload}) AM_CONDITIONAL(USE_DYNLOAD, [test "x${use_dynload}" = xyes]) AC_MSG_CHECKING([whether JNI programs can be compiled]) AC_LINK_IFELSE([AC_LANG_SOURCE([[ #include int main(void) { jobject o; JNI_CreateJavaVM(0, 0, 0); return 0; } ]])],[AC_MSG_RESULT(yes)], [AC_MSG_ERROR([Cannot compile a simple JNI program. See config.log for details. Make sure you have Java Development Kit installed and correctly registered in R. If in doubt, re-run "R CMD javareconf" as root. ])]) AC_MSG_CHECKING([whether JNI programs run]) AC_RUN_IFELSE([AC_LANG_SOURCE([ #include int main(void) { jsize n; JNI_GetCreatedJavaVMs(NULL, 0, &n); return 0; } ])], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([Unable to run a simple JNI program. Make sure you have configured R with Java support (see R documentation) and check config.log for failure reason.])], [AC_MSG_RESULT([don't know (cross-compiling)])]) AC_MSG_CHECKING([JNI data types]) AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include int main(void) { return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1; } ]])],[AC_MSG_RESULT([ok])],[AC_MSG_ERROR([One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.])],[]) if test "${want_jri}" = auto; then AC_MSG_CHECKING([whether JRI should be compiled (autodetect)]) AC_MSG_RESULT([${has_R_shlib}]) want_jri=${has_R_shlib} fi AM_CONDITIONAL(WANT_JRI, [test "x${want_jri}" = xyes]) AC_MSG_CHECKING([whether debugging output should be enabled]) if test "${want_debug}" = yes; then JAVA_CPPFLAGS="-g -DRJ_DEBUG ${JAVA_CPPFLAGS}" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi AC_MSG_CHECKING([whether memory profiling is desired]) if test "${want_memprof}" = debug; then want_memprof="${want_debug}" fi if test "${want_memprof}" = yes; then AC_DEFINE(MEMPROF, 1, [memory profiling is enabled when defined]) AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi AC_SUBST(JAVA_LIBS) AC_SUBST(JAVA_CPPFLAGS) AC_SUBST(JAVA_HOME) AC_SUBST(JAVA) AC_SUBST(JAVAC) AC_SUBST(JAVAH) use_threads=no AC_MSG_CHECKING([whether threads support is requested]) if test "${want_threads}" = yes; then AC_MSG_RESULT([yes]) AC_MSG_CHECKING([whether threads can be enabled]) # check whether we can add THREADS support # we don't want to run full AC_CANONICAL_HOST, all we care about is OS X if test "x$OSNAME" = xDarwin; then use_threads=yes AC_DEFINE(THREADS, 1, [Set if threading support should be enabled.]) fi AC_MSG_RESULT([${use_threads}]) else AC_MSG_RESULT([no]) fi ## enable callbacks if desired AC_MSG_CHECKING([whether callbacks support is requested]) if test "${want_callbacks}" = yes; then AC_MSG_RESULT([yes]) if test "${want_jri}" != yes; then AC_MSG_ERROR([Callbacks support can be only enabled if JRI is enabled as well.]) fi AC_DEFINE(ENABLE_JRICB, 1, [define if callbacks support is enabled.]) else AC_MSG_RESULT([no]) fi AC_MSG_CHECKING([whether JNI cache support is requested]) if test "${want_jni_cache}" = yes; then AC_MSG_RESULT([yes]) if test "${use_threads}" = yes; then AC_MSG_ERROR([Threads and JNI cache cannot be used at the same time, because JNI cache is by definition not thread-safe. Please disable either option.]) fi AC_DEFINE(JNI_CACHE, 1, [Set if caching JNI environment is enabled.]) else AC_MSG_RESULT([no]) fi AC_MSG_CHECKING([whether headless init is enabled]) if test "${want_headless}" = auto; then want_headless=no ## only Darwin defaults to headless if test "x$OSNAME" = xDarwin; then want_headless=yes fi fi AC_MSG_RESULT([${want_headless}]) if test "${want_headless}" = yes; then AC_DEFINE(USE_HEADLESS_INIT, 1, [Set if headless mode is to be used when starting the JVM]) fi AC_MSG_CHECKING([whether JRI is requested]) if test "${want_jri}" = yes; then AC_MSG_RESULT([yes]) export R_HOME export JAVA_HOME JAVA_CPPFLAGS JAVA_LIBS JAVA_LD_LIBRARY_PATH JAVA JAVAC JAVAH JAR CONFIGURED=1 export CONFIGURED AC_CONFIG_SUBDIRS(jri) else AC_MSG_RESULT([no]) fi AC_CONFIG_FILES([src/Makevars]) AC_CONFIG_FILES([R/zzz.R]) AC_OUTPUT rJava/inst/0000755000175100001440000000000015133274036012314 5ustar hornikusersrJava/inst/jri/0000755000175100001440000000000015133274036013100 5ustar hornikusersrJava/inst/jri/REngine.jar0000644000175100001440000010317515133274036015134 0ustar hornikusersPK/3\ META-INF/þÊPKPK/3\META-INF/MANIFEST.MFóMÌËLK-.Ñ K-*ÎÌϳR0Ô3àår.JM,IMÑuª EôŒL4\“s2 ŠSSò J2Ks5y¹x¹PK Ît@APK /3\org/PK /3\ org/rosuda/PK /3\org/rosuda/REngine/PK/3\ org/rosuda/REngine/RFactor.classuVkoe~Æ3öØÓ mÓ8%‰”ÞHp) ± â *…"B­ .×!Ò~^iÀ®´ûaÁªÝîsÞ™8Á5­t潜ësžó:ýß·Ëv¡la Ž¡˜–ƒ•Õ£&³`âac"ÆE;_öfôRÉ=;Uœ;«!µ¶÷¾Ížl#EY¿o£§j(èHÇt7—û[ò.æÍx³^¡Ê¿àÀ-òÝq£‚[~„>®´ÿ± Äš(»™}!É w wŠ]„á.p7pFЋqNäqìæ€Ý2öàYŽé9ôáUôã-<€÷±c¿m Ö :Óh=ì:M˜ÚÆÚ5$´XHp'ÇVbËc½æX—cí¿ˆ4t(¼ïˆ²š!~Í”c\ÅúUVYêxˆÍ8  î vWÂßXÊI4ÙPkò¢æ ßšÀä1ž‹ÉvÁ½­‡2’ëK\€Pè~ÄéëÄ®KUD}ocd̸BbôkhÑôA“Î4ÂyOàþPà¾Cï‡!¶+.ßDOÛE„¥ó!¶êßúRÕs³#Ü¥×c$æ’8¡¢D%JHk «½AˆYêü:)§‚}‰÷Ö—ôþäÚpÉž„N¯ ×ο7€I"9Åbr¸Cž"ôÓtžWam×`³¥ššOvúDz«Þ§÷¯Ô×\­/ÂpªÀ%W#¶ª*pW¤íHµV”8Ÿe-ý: M‹û¡v¡¶\°RªÌ —j™³”÷“±¾þët.©íQmä³Ú€.?AÕêþälJƒd9Éã=§Mrþ›³Únÿ%y x‘­ ›ð2ß”sÌ÷é<[ñ*}Må¿Aò·„Ñ×ÐIRK{«eœ øÐË—#Zò“’Ø;}Šý‚Íþ‚Enz–\GNú4ù{¨Å7(ÿĬþŒx“Ãýiñv€¢‘†íðÛ8¿~ø$¿‚UX‚\ªðÊþ*€kUCµª”êUúXß×&Ù^DT™(´¿·FV©Ø’NúdTзh¡ã?Ó«@7*?IŠø\H`ÿ²2_ ×TÛt_u|³4Zt¨Ð¹½mœÜ¶ÚÉm»ir?%í?[™©¦•±¨»#pkú¯B-Õ¾ Ü_õ$“®>!ò#µ†kD*QAÓ¸êàÖpÊïà—ìÔW,ï Ÿè ¸J¢£c¢×±NIùõ|ÕéK¤6±eÊÁªj{ QÉÔêþD9¤Е‡JNû¾Cœ¿dÍü‰Û\Á­-ʼ‚ÖÆ6c¨MÂßDd亂öZšüLùUqöÿPKÙÆéÍå PK/3\#org/rosuda/REngine/REXPDouble.classVÏWWþ^˜0 ù!*AQ‚ ¶ÖVЪDZ0¢UA[;À£!C“‰mOO›®»rÕElܸ°Ú‚­ÔmÏé?ÐÓ¡Ýtו¥ßy ‚¿XÜwß}÷Þï~÷Ý7á÷ÿ~yàn™øC+ÿ®øUhۉ6œ-#ÚY#Ι¨Â™(ÎËzAĨˆ1“nã>Ï‹Q\2Ãe‰ˆbR6WD\âcYÇ¢ø¤âö?D†± È×ÄõS¶)cÞþ2ïÚ3 ¡+iŠ‘“ ŠŠ1ròÚTÎ+q7¬É•ä ’H''¹ ¸3ŽBm&WpFÊsSNqÜžÊÓR3æÙÓ7ÏÚóz_ÙŸ+ä¼ãAàE…ŠÄ®ÚÚ©fÜb¶·è–Ê3vïèéB–é¸^>ŸÉ•¼>ñ›fмSÈz׉äB]±½Ü-gؾeŸ›ºáL{ ‰dæ÷½y»í ¬} U,º<çsÓ~4 ¯²Ki·ÌÒJRRR›vi¨à9Y§¨mCf|Ï1¯˜+dim¤u]þÀÞgÀ & Ì’ºç¦©r68ÝX“ŽQˆöOçuOX[b޹åâ´3˜“~Õ û Â 6µp9 {±ÏB7N[ØvÑn(Ä6æWhÚh:UÎågœ¢,ÜD^Äœ…,t"¡°msÀì¬S´p ¼ú¯ʵ0ϸë–ð¢v%ÜÝÓCÛ×<”-ìA‡BËK.4 ôòó‹¼0—E6¿b d@9õ/¸ 9š|®«€õ3¾2îŽÚŸg\²ó'Z¦‘CÝ–xÍrúìùy§ÀyØŸØ »ù‚u·YPœ¯8Žzîê•5¾(3¡kæì/ü‰òœ9y†$ßý†UÈ¥ùÅEèÓX^7dÜ]mW$1œLsÂZùeÂÉ´QÛ!×Ëu»Ì!×~†8>PHr×JzÒkß#¨„n?@D–;ßÁˆÜE$|‡!tQV2ØŠeBM'È‹¶_g:@‡0×X×*º"ËÆD¸sô'Tþ@›òlñÏ·!‚&Ô²‰îÑÑ×"u4øÑ©ßP^6ˆŸÒBë243CõhñKÙ‹Ð Ó… ´è…âº"z¿f'Ø 6Ët’¨±«{ ÆkÐÚHv7ØKAK Z á «ƒk€ëLÏ0á-¹ Êï_eר|ro­)AW;(߯aíÛ¢}+Ä÷þ×NÊwpD»îÔ®¡ÈÆ”)ÊwñÞ›¤”K8Š>í:Áö ñ½~¥Ëf&|,î« ¨OùZüà·ç¾ ©»+¥î¯u«Žaò %e“döŽtÌDè)LýJnüŽk˜›ì«ÀñsÿŠè:œŽTü1ª&–`ÖU/ 0Q³ˆ-c>🛀r¬ûPÍ>L5àjï«$!;qB_Öü:~ÁM´q•Ü#ÔŽû(oB9EzÌœæ8œ~ŽÞIÕÄüüòj”Ÿ5Jé1bš g{+éÔÕQÊê×qÞ€†´Æ¿‡™ªk\ĶK©UâM—üzþXõ¥ÃvqÐyS‹Ø!ywyŸÝÎr!ß°üÂa“Îb#ÔÎã*.ø$,Dž¢Í@LíŒÕ2&MrCþ«ä«m@ó#´<Ä®@á×â!"ÏÞ¶éûEy Õ´ ú|ð?PKjG…}È6 PK/3\)org/rosuda/REngine/REngineStdOutput.class•S]OA=Ó¯i×-…ª ?Ú ¬ àC4’0]£ñqÚŽeqÙmvg5þÿ€ÏòPMüþ(âm…h ‰ÙäÞÙ;çœ{æë×Ù÷Ÿ6ðÌ€‰Rw° Ã¢ëXâ¸k RË:ßÓᾞyÀñ£ÌQá¨2dž;ž£^0$Ë•7 ©ºß‘ “ Ç“ûÑqK¯EË¥J¾ù6p”¬û^èëÿrúVà‡QGXÍ—^—r­q$> Ë^ײUàxÝÚ®VÏÛJ´?ì‰^,ÊñˆÁlÚ‡þ§=†¢K²ëÿ)«6wÜ(<<·¶p¥†f¶m¹ãhxq8c«ÎA¤z‘ZÓ]LLbŠcÅÄ*ÖLX:<Æ:Ã=lGŽÛ‘í]µZ]4é@ž˜xŠM[¿|¹—óŽ Sª­#ÙVWëÂu[´“!CårÔ@{×S2x/Ú´Ò™¸‰ã[¯È·"÷RÿÕÚþ*I¥¤¯=cð5š•­6ÝÓEB•ÇŸJFôzÒë0¬ŽŒ”†»HòYåJ ³åQ !xÜÚõ°„ktõÈc‚^B LÅiú+Qf”ÓÕS°o4`(PÌÄÅQg0;„ÖH"E¹Pú‚Ü _‘9Ar¥”æ%bžAY³§ÁQ¤GÂØæôžèFàæPh Iú€y¢ÿ@úÝ)2ÞG–¤²}äú0.Œ  ÌÑÅù¡Æ\Ü£ž'(ÞŠ'oÿPK%:¡ÿûPK/3\.org/rosuda/REngine/REngineInputInterface.class;õo×>#NvvvFž  ÔÄçü¼âüœTFg Ÿü¢tý¢üâÒ”Dý ×¼ô̼Tmí“•X–¨Ÿ“˜—®\R”™—ní©‰)ÆÈÀœ_Z”œê– 2R ªÛ3¯ ´Ä3¯$µ(-19U¤‘A·m¨êù'e¥&—°120201€# #3 ˆÅÀ $™ØPKrv­–œëPK/3\$org/rosuda/REngine/REXPLogical.classW[SGþfga–u¹¸*,ˆ$F–AðBTÄ  èŠx’àú »¸»˜˜T*Vb’Jªüñ!Iù‹I+ÁªxyLª|Kò˜×T^óžŠ!_÷4»Ã. é™þúœ>ßùÎé|þïÏìÅMC~„0\ çÅÛõ[\,Â%Œõ¡Þ‡>ìðÓdL oxÓÀ[~”bX¸Œ‹·Ë>Xâ9áG &ÅvS>Øb2íCT<'|¸b ¦Á˜³nÎ$¬) ž±. ú;Çcñ´Œ[3´> ÅÇñTÚŠ§/X3ó6Íú;¹Ð¥/--ÝÒà<ߣ“¡¦¡ ·32$' 襄¡·¡+<ÊÇñÄ}K#±¸Ý??;a'‡­‰"ÅCikòÚkNÍ Çâ±ôQá8fúµÎ¸{ÃØòS®\ÕPO(’HF[’‰Ôü”Õ2Ø2Ÿ—"±Tº]Ø]“v£ëØ1òŒ¦¯hÐÂL»(–Š$¢±I!æ´RýV:vÃ>eݰÎN\µ'ÓÊ‘«œ·ÌXñh‹ƒ¶kð[©>ªµ“)‘@x¬Ï72¬T×Í´­0Ê]d¥ºóÌ\AÝf%:”NÆâQ¢D]¼Ý@Üq ¯ÂXJ»ÇR²”ÅòwÛsI{ÒJÛSκ5“ª§ÝöÄ|ÔÙ-7 ƒÞC‰ùä¤Ý•)“j9’4 c µkiêXÐŒD5¨oskÛ+© \ IÆÊ%À)ôp¬Leîb×üô´M¯Íù ±™);ÀY 륽À¼˜5ãFo£ŽP“X{‡enjnæô} 5k½Àê&’â¨P÷êÿé(aÒ'†n ›V©Ÿì)6]]ú}¹§oÈ—! ­¹9;ÎïjÈ•_Z¥ YøÒ‰å¨XÍ•ñ‹g­wd³ô¥íY6dÓK†5iÇv^!^ðŠFàÛlCÑí|÷ [YòW2óW9ßáš¿ÆùN×¼å¼ Ãh$bi!¦ñ¨*»õ5 ï¼ú}iÙıP®•a—dàñwP.V¾E9_  ÔøžFï߈^ý…Údøèße6*¸Ö*˜D%6óGl¸ ž%á1ÄÝçåh`7ÿiKÂK‚YÐ ¼GÞ­—¹/Ô\«0Ä{¼FzïUÞãôÞåÒÛüEú9›«PÞÎ걉 Ê;åRÉŽ¤Äa+æœÁö©`O¹Øèàr0C_@ùì‰ÑÌŸP¯ ™Ïñ{è!3´/#àm¶°ôg–P- Ž;¹Ÿ(b˜ÐÈF0)J#ÐB<‹Â%+"­Š –™KYÿŸ`9t”«ŽêD—’ÿ-ëߌ×U*Ó$"ËØØôÞu„%ÚÃ({%/SW¦° û3Ú¹ ·|TÌçL×Ëg[&fž~Gk2úÕ˜5.ýôÕôÛO^؉y0ÚXÞCdØÆY»ä9&ô+Y"ËSsC+Tôfp—nЭåA†ròª…&ÏV¡ ýì~¦ow„ã!Rrl«”­Ç›kwŒãai-ìj”]ØóAŽiÇ£ÒA˜~£ºò° ÿÄaÊ×{h4å[hŸ¸|ÁÂltæw¥ô^ïYÙ˜¿™2ÊVRS >œàQ9ÉF;Aú}RÑã(x¿ S¥TìR $‡ ‹èbTÊuÊÖÍ2Âñ8º•é·*Ë#N–†+KÓeÑCî4K˜fé Ló×¼4˜æ9¦9ÈsqŽ5Z‘fS¨V)ôȤz\ifd]Œº“f/•s¸?TÜIÂOás‘oZY¢¢lZæî úy<‚†$û_òØ_âí?¶å!açŒIö=‚ý']E:)¹ ¤8Ѳˆ.F>‡˜UwøßVüMG{oDÝs!7w÷M÷‡‹kPžùq*}~XÜvBòlWªÜJ•+.°Ö¼ ¬UÓ£SFw£ÖF;²Œ¾âE¾®¼„Ï£v…Ôb¤v•·Çµòñ䜱ErÏØ»8çÿ(ý«:ç:|qàß‘*ã¿TÆw£dä1JGÉùÆEƒ›8,¢ü*\=ßzˆÊ{h } ¿ܼˆ-Íõ0’‚=]Þ…®[ª"š‹¨«ˆYUë©§(K->â7ö6?Jó¨Âvü”ŸÁÏpŸK•`¼@­j€ãþfOG‰”»„‡£¨”à9¹ûàPKF:bœ¯PK/3\org/rosuda/REngine/REXP.class­W{|SõÿÞÜ$÷&MjHÓP¤N(ˆ¥ Å¶(U4t»M/i°Mj’òP6ëtîí{ Î­SÙƒ)NmÕ*ŠÜt¾_›{ºÍ׺×?2ûþî½iILjÖääÞßï|¿çwÎïüÎùÝ'ÿ{ÿuø·͸ɅJ|[ÁÍ*¾ã†ŒïªTñ=·¨¸UÅm*öªø¾›J?â‡BüHˆ}n,À…¸ÝîPq©Þ¯âNñÿ7ªq—‚»Ý(ÁMÂÒ=âiHŰŠ{Åã=*îðûUŒ¨x@Ń (xHÁà *xDÁ£nñ˜‚Ç……CBù 7æã§âõg*žÿO)ø¹Š§<£àYϹQçÅÄ âéEùúêÆ¼¤âe¯¸±¯Šé›„ø…‚_ºÑˆ'¼æF“VâWbæ×".¿Qð[ v-•JH(o‰'" ñd—¶pÚX$ÓùÞ™-Ñdj¹„â^mG“ÞÙiNé½I R³gC4M­” *7’iu¼K—0¹…жþÞN=q¶ÖÙÃ`\rU£ÉöT"‹d›$¸¢Irè‰hØxnŽ¥ôˆÎu:ÅxOX«…SqsLIpG“gjÑ„ùBTK< kT.Ž&×ĶEñX¯3[´X¤_‹pyNîèKèÉd43—²³·3nÚØ¨›6Ñäm»Áº:ÞÛ×£ïPÄ1=ÜŸHF·éÖÛ=¡ÇÂ|si–CŒ•/PÙѲUÛ¦-ì¡Ñ…æ8cê^³#¬÷¥h•Jn-í$_ìD4$Mñ~ÆÐj’ hÉÆ©ô@#×,çË•9Ãlm ªÆ«"¦9O]¯–lÓRôj½¾s+c aQcN˜£Ôuöè±HªÛØ7.ÙÎý9Õ\Ü&ÃÑSÓΪMÆ@zÏ3¹Gä‰è©S™žÑÎþa5+åö„©%r¶=¥…ÏoÕú¬<ôtkÉcè|¹è¸h¹+Ú«àwbûcÝÌÀTRÁ͓2+OôÆÎŠšŠ§+NÅS“~Ÿ”B«ÆæƒêhRð:£NèZJÏœ¯pz<''[(-¥­Mh½ôkiîãfžµq˜˜I«5q´Úòž×åygÆc>-G¤'Æ´6Ó„ˆ6ÿ?D²°ãc±0!Ó­ù7pB|[&À7!Cœ†&´µ!Ücu5w{¼?Ö×FEíp‰ùZ±¡´a½ëp†„@¢Öh²WK…»G ÜÇy§´iâ´èôk=ɬnoÝ^D·wj}}z¬+ßí"ÏIY.:wG³0³(¿•åðF@ÊÇëМŸèhúÈ+³=½P×¾æñêYÎKŽ@Ÿ¯ïdT¦ò,qÙ8KüÈ¥ÉZW—ðrœ¿³ù ÒÌÏ좘òÉ%rÃøx“D¥<“oå¢ ñ߆t'DQ:‹Òi ª,Õ9$³‰/"¡¬º¶lý)”í8ÛÒ?Þ¢¶Éû²ô|”ç 7“rcz¥”ç WAy^z³)Cè@¹©½”è)?Y€^ å§ Ð[Dùéô–Pn.@¯žò3èL© ×@ÙY€Þ)”áô)» Ð[CÉ®ÎlzsyDÄhÑäPÐk†ã¡,@3"”BMæWƒÜPgèP^(rC•ÐÖ hzsCÕÐõP^YrC]9 ge@ûpAn¨;´=š@27´(ôœ (›fn¨'tSt¶ÝœÝ1ju¶Uê\Á!·TɵÙÔ•܉ s'¸øŽ,`$xvåN&°npk·M+Ë×&ó¿”À)­Õ‡à®Âq{àöóÁ[5„©‚ÊfPM2Tppk¼ŒòÅÂ"lG0EÁqZx¥µx[-ÞÙiÞÁ»Þ4ë!(ö½°‡Ëdw\Dö]³[0Ï"ó*A})OI²|õ½Ó†àÛ Ÿ°AZñ:•'­´¿EÚo8^Æ%g¬ÿ2Ž\Îb~…a¥ré*_àODf`Ôƒ[ŒæÇêôN§†DÞg<Î`ˆ…Gså•åÕQZ]^w“)é×ÌÝpØ÷ ÈÒÞ£op­ôÏFu,V2 åÉÆ¿¹š =¾ÉÙ«ØÒ®F ®a+º–{y5¯§î ÔÞƒ¸ÑXéT8‹>Àd_”f¼G£X0×ÊO d7ã»aËN€AJ~@Xªçr btîJBÃ8ž=¹texª·|/Þ  aÖØö›D{ÅL‡m“‚’£Â¤ÂË‚/ ªùzŨ‘eäD“¶Ê²åõ[–†0›OÞ9âÕ´Os{¡ˆ—l«·VØ®6Í|_1s_â}Éˆä…Æ¡1’bFkõ˜dܹâà2ëŠÛj8nNž FkäÚz{½¶Þá³ûcžm™S®WäzÕ§úƒÈõ.ŸËgÄ̧ÏUçS«|Ê€"-Þ0àâ¿5 R¾Zâ[ì2æ0Ć÷r?ïƒ÷c1F°²u<ŒÓq—¢Gتe9„ò ‹Îc†ƒKáü¥ ¾Ê˜yy”yáâ›9ƉñžG§q.é0JÓØØÙvákøºÉÁ•™+åyEðÖìÆº \Ç¿ÕÁ âiEiY÷J›\o—GÙ æËõNŸ³t3j|ö»ô9ë|ºì¤³ï 8(_ã&ÉD`~¨f B#„ì¢2$ r<àÉ¥ëCö²õèjçDuHöNkFÍ0j‡±p,^õ¼$OqñOcžÁ <Ëû/‹Ïc^@-^ÄIx‰q{‘­ðb^æì#Vóá<ŠœF83&*cRÂãqXT™Ã É7xÊÌ:ù:C"jÇm Góe÷Ö'2BxÁ¼«õ.‰”‡PwKödMž8:ù0–´Œ`i(˜vßi¹_òž4ŒO´‡ìâ™&NƲöc40ÞåŒ +ECʈŽÓŒÎt¼+¨ç]9§SÆâTaläü“yôšð6ïï²à¾‡[ù,âá€ì9®,#øagÅ0ßE5«kƪÖj.íÔsYªXÂŽ«®*¯ïFázo¡êa¬³ï5ÀïCÅaføxu=bØôÀö¨þF}ªaðjËà<£Îñ#`M"xkªîÅÚì¢tÔ€\cA–Y-`ް/Öé°bj0BUŒÍiÖÂŽá‘L_¯µxVÂmúùiç‡yBŽê<\ƒë:‹«‘\Âõ`šKÉÍrÖäáS ¾ë-¾% ¡ð±4ÓÇà8ι ‚oY'‘@87+Ó¹àGxUdì¶H–“Än–ÿc½ àN1¡{F¿ÿ*ŒmäÜÿ]8=ëƒNt79tãÿPK óx; ûPK/3\+org/rosuda/REngine/REngineUIInterface.class;õo×>#nvNv.F® §ÒâÊà’Ä’TF Ÿü¢tý¢üâÒ”Dý ×¼ô̼Tmí©ÆÈÀ䜑Ÿ_œê–™Ô`ˆWC”¦OVbY¢~Nb^º~pIQf^º5ÐÆàüÒ¢d¨âPµ¡žžy%©Ei‰É©z =Œ ª¸ FRÌÈ €°Â?)+5¹„‘‘‰˜X˜X€4+P„‘$ÎÀPKw½ Ý® PK/3\$org/rosuda/REngine/REXPInteger.classUßSWþîfa“% ?…€ˆb‰µUJù¥@0‚ míKº&Ù8ít:Ógú_t:¾øâƒvZ˜VêkgútúÞ§þ-=çî2€Ê˹÷~÷Üóó³Éÿýú À؆ßÒÖD†C¸Î»n1a`8ˆ¯£lÆØŒ¸ÅNALšˆà6?Kq‡Sl¦ƒ¸Ëëx˜06í¯²y{M@[ž 3uC@Ð&2’Ï=;çÍÛÙ’# »E¾Òã‰%ZFòkV§Ýœ3UÚXq söJ–Ȭg¯>¼coªs倛s½!ÿá¼@E|™VÍ´Mç ™d!_,­ÙÉ™Ñ\†ÂÑzïnÚ-zýì7+µ‹S¶ç>r&íGöôÊgÕ¨‹'ÒèœÌÚ¹LÒGû‰.ëä2Þx‚йʼnœçdœ‚D–$Bù:wUÀ´÷n‹œ_‚ëÙÅT¾D©+(e`N¢³^ÁÍe­'´ŒÚÇû |ì?X2@eF¼|ÊY)eüÛÃéª7”Ál¾TXuÆ\–ª† W õ°³@ÛkäQ^aœÇBgÐÌ»{â0‡@ãaèfÉÍ®± cKl–Ãø”NÃQßõu¦ùoÅ×ÌòiŸ!F§n~yŸÍç$nwOaß´¾&åyjPžX[ÞÐqžÁ”@í1úòÕ’l"©ÛËÜÐ Ø››NަúRüh°£½P¢MŒæô ×A/¿§lýq‘¹÷ö—²ùž³AÓ} Xjbh9>y‹sô=7Ño‚ÛN»3hAŒÐV‰jôi‡Ð†³„´’$„:psTû†þzà™ôNdï(²u Ç껺·Qñ¶ÕÕŠ:’‰Ù,f«AÀj ¾OXp&Ð¥8[!¤~]?A¾¯‰/*7ÊB·rmS®•ìúêÙ!_Öûz”o³òÕôÃ~LŸ<‹rïž$ÍÙ+xO¹.RX N™æŽ‘ Æäö j-¹‹õ|7óXOwÿ±žï«¥g  ‚”›Iž'öùÇ¥ý ÓÀû¢‰®âš¢yHú3M¯Œý*Ëx.X±—0·Œ†¶`úœ[¨ÚBxVÿu„ø*Mü5šâ^Ú}p@\e Wp}m„úÄU}–_ŸÎ¼‘ÆöŠ;øHæ$ÙßGȨÊA""é†%Yº¬²f¦AÍLŸà‰é+›"BlëN?§*£_TFÅ—ˆ,ªÂé{9E¥G«ÉPÙÛ¨)ÓçbìGœ~‚³±ïaZÑèj¬=‘êdÒîù’C=;¨¸Ö8n£÷ ²ª !¡R”Ô(uoŒ'{ iLÒÃmYi˜+m7Í5ÕTÀ€Œ0ø?PKKç}X²PK/3\ org/rosuda/REngine/REXPRaw.classQ[KA=³»É俥1ZUAØMÄ@_->¤´PImÑJ}(“dׯ]ÙÝ(þ¢¾ô¡…AН…þ¨Ú3›íÁZ¾Ûœ9çû¾ùþãâÀ¬A5 ‹:º'Q“XÇêl¨¾€±ßÈ>ô|/ÞÈØû-§#`= ú®ÀTÛóÝÑQ× _ªî•‰½XõÞ=SÇI.!Vù¦„ƒfD£¾jî>ö|FÿêEÛ‹âM§#qŸ"C×Ħí<¥”íªÓ${͆TÔ:‹ÝˆÒ¶£[*«hGÅÞ‰»­NÔóî¡Û‹*¶Ó>dÞ*ÐW7 {Á(ì¹O<ÝaIë’yCKÈa¹„,¤ŽVª74š´R»á²C™ XüÇ”É Üܲ}Ë.°ÂßÈðw¸{Ý£,ãò´foX7è+õsˆzãòæ×Ü{X/0>±n H; “¶@®"fPâÖ`\a †„%1A¥¤ùï:Å&S±·¤ÓD³õõs˜·¨•Ù÷ *#.ÁËÎÀÇÎÀÏÈÀf“™—YbÇÈÀ¬¡ÆÈÀ✟’ÊÈÀï“™—êWš›”Z’˜”QÐðÉ/J×/Ê/.MIÔrÍKªÒ>™Å%Ö ½\Áù¥EÉ©n™ õÜ ©`½¬Ä²DV6ÁÉÈ ‰Ã”`Fqr Š Ì@7ƒ#È0 ÉäÉiF ͪµq#ÁÈÀ$Ù ‚`¥œP¥r@­L 9-íí LèjA$ØxnPKM!N<È-PK/3\.org/rosuda/REngine/REXPMismatchException.class}RïoÒP=o0ZºNf™n€ÓÎ)+…ÑÍŸ4&ºÌO8è2?>ÊK×ZÒ>Œ–&Ž%šøøGïcÄ)0›¼sÛ{ïyïÜÓ÷ó×·ె[6tÜVñŽ›îbKÇ=•¹o`ÕQ·Jsôíx˜øâe¨v.+Þ«0íséŸ|òÅ@†qÔT4†µiö‹aØ#&,Ôiz.¥è¤-cûÂÛD;š&<ìjØ3ég”h0›«ÚC”õ‘‰k(˜XÁuçŠYf41/åü•Í8ʺ È †gŽ·3©É äÆÊeéuçTø’A'÷{\YXüÇÂq’8…©ƒF”CÞ'Cu_Ápcž”#lÒ}[¦kº@‹|€zÈ Â ]L EÂUúzOߊ{îw°çX°2#dë#,Ž£7K#hÐA?GÞ­ŸÁpgXúB$:ÐB–pU”PG»¨På&Ö&GlPdݯ0>ÿ¡åÆI›pˆ³­KÓ­UÂòx¤ÊoPKë“=ê„PK/3\(org/rosuda/REngine/REXPEnvironment.class•TkSÓ@=Û–¤ ¤P(òRHÓByú € ÷ˆÃßB›)AH;mÊø£ü€3RfdFýìr¼R„ØÔ¡™ÞÍîž{î¹÷îæ×ïoßL`[B;FCˆ É͘„qLˆ˜1%bZ‚ˆÑ žññ97/‚xÉÇ RyÌr9næƒxÅW^‹x#bÁ¯›9†èF¾˜Kó¥rVK¾K›9ÃÔ«cŠA8ÒÌì‰ÎÞ8Öδä‰fæ’Û‡ÇzÆâ»³†iXó ãJ=š]c{ Å|–ˆ[6²U>=Ô‹ïµCªÉ(¥Í3£˜7OuÓ"¡Jì€!”Ó­UGLD‰Õ’ã'èrko×*f.u«­ïù5íZZæã¦VpâKéO½`y³Ä0Rƒ­™ •JFά-ÃÓ×C(hE;ߨRWîâ¹{«l”vóåbF_6ì’¹öG¹8]X”ÑNñHÄ’Œ¤›FéT³2G7bônü-T§» eã$«:jòÎÈXÆ 7«Ôú>Ãì£Þ*1o±ÆU¯s¡ƒ2†±!c[ 2]—ãbPþ_'’æ²õ¥Ë;A†•ût¹n[­PÐͬ׉ó¨_Ê…¯Þ¯:ø •¿^rß#'Ö=nsUÝÞ= Q÷D¨Ó;vï´iÚCTýº¢Ÿ>yíô-õÑŸÎ9øŽ:Ù ¨·è&¥Ù$!ü4¶¨—`jü>5qÿZbè!F€l+Ù0BhC33Ÿ_AÜ¿D0ª@© 1,ÓKM—hþasIh$ŸÍÞlç6@+ƒñ„;âºHˆ§ô ÁŽ=äÄî%^3Q*hq MÜq†â¸ ÓÕhKN¨<ø[BÉfœ¤qÊvh.Æo«C¡9'Hrµ»‚ÖóÍZ)'xÊaWÊ!¢¾›rŠVf)í¹jÊkî”cˆ;¡ûi´YTʸí'"î8&ìS5òPKpð_a¬PK/3\-org/rosuda/REngine/REXPExpressionVector.class}ÏJÃ@Æ¿MbbclÕ›‚Š Ø?bÀ£Š‰^‚H•"ÞÒt)+º[6‰øP^<<ø>”8ƒE!Xwá›o~3ûñùöàk!<4YZV¬ ø'J«òT`³;Ž­)ªQ÷=VZÆýTåqg à™‘h¥d_VCio²á9Gÿ4þYIn¯~¦FªHž'V…2ZÀmwîÂkSÙ\ž+¿Îü/3yiìÁ}ö”EX€ÏÒØ›³¨Þ(°;‡¼ZZ•cØK¿ÄÇ…à=¤e[pè~·7…x¥—À"çA³»M½.»ÝÞþNŽHC,Íà Šì:ÞKk’F\ÁòPK=}ÏÉPK/3\org/rosuda/REngine/RList.classµWit”Õ~î,ù²LV²O&¬B˜™Id)J„$B*8$cšYjE¥Z·¢¶.€¢ÒÖØšj°:QŠÔ­V{ú£¶=íéžSë9þ±?´`ú¼÷ûf’|™áø£=9¹ß]Þû¾Ï»ßy÷ëWN¨ÅÇ™pãî ”â™Ý+Ã}~(ßC™Ü¾_fÈL‡²°Vfn<(Ëø±,2ð°|‘áQ99,³#2•á17pLΞœ2ÓLž”åSÂøx¶ã'2üT~&OËì!9í—Ùã2‘á>9Õ{zxÆÀÏ30Q•á2<›…È­Âü~){ÏÉÍç <Ÿ‰:ÜŽAùžÍÒñ+¡x1/¥#&û'Óñ²|_00¤àކv†{ VoíÕôõF:k6„Ûz»º/SH[‰FzœU37(¸–wµ‡rWG¢áæ¾ÛÂÝׄ¶urÇWµyuWwGMwWO_{¨fÝŠhIø½víer1»¥7Ô¶£)´KÓx…r«7ÉQYÕ(ÁË»:;);ÒÕ×f_„ífóZg(ÚQÓÒÛ‰vðŠS ÁSÜxU¡&ÅÔÈŒHO3íÖ®-³IÁêU¨®J"!¥ U;vïï]J¶EB6ޱBzO¸w•IR\Õ˜L9zŒͧœœ€2ŽåH‡9¨àŸè*ÑÈ“|8†yà4Pjà*Êœ E®²D¶À¥Ezý^JÔ¼+#× î²3FV‰AÎnj–‰©”8MËÈæBd(¥5d°x×Áo–?pi6#ähÙ3ÉÐy‘ÉÅ&ëâc&âÖÈE#x+ƒ§a¹F~†»íŒóÞ%ÜÕeàJ7úÑI” ÚZä³ù„³®l²ršô«ò&ÓM¥V •·Ši0èø {žé²\¿Àö¢•]Ôhеœx8¬·äLò³®xu]qH]©#Ãe·ÜË”1ÄÔy…arŠ5ðÕxi8Ï8–¼‰$Â#JsLeH”øœõ!T*4Wa¢¢Ë'Tø9¤ÃäõýÃŸŽ 3]ÏP§×"oÛ˜È÷v ÞŽ{,ûÒ™@ÛK)uGBö_yQà^7Jö˜¯ºšœ N‰ÉÛK|Á"WÀ_äŠaê¦9~f±Þ|͆ƒ.æò'E®c(aL‘pîáá/4mCùÓQQ5‹H€wˆó]†ñ{Äù>;˜ė÷b¾‚—á#Ò}Œ«ð{–?hì‹‘–ý5² t*%Íï&\éä;,ýaô¶Ko« Qvg"<}V·qS¿Kì/°?rŒ¢Ë"hÃ_A¿O·Âq¾“ 6K†!12£ÕNü'Žü™0ŽØ+ö±ÿ™co"ú*-â4áVÈ‚A³ãEÿßÛÒD}®ëÍ—[ŠBm±rµŽz ,bµ¾¤ø¯ˆó?,øúšïñaI`ÌP•µÊ……Ê+U¶0d;TºÖ%.Oùy¦½Ôôï±)jTJžß&x¥‡±ž6-m2gŠ–Õ­'‚¢‰N]‚”Dœ°È]æ•ôj–£yþ2w|]Óª³øÃ~ÌcÝ™­ÐÄF1gTùñ™Åg‘Ë_æ ”¹†Pë€\ëþÛH—ݾ å¡ÓrXær‘¯òøS Ÿu¬€\ 1MQùbT«Ô©R,ReX©¼üÁ]k•›U% 1a5‰ù;}j nVSq¯š†Cjº6N 2ÜçQÆt¿ÀÄš=‰/"ϰD³.æ² ÜÊj÷%Ë»˜ð6+(ÎX&\gšðh¸#4°CñÇŒò`€¯Ê U5ŠT ÊÕløÔLUµ¨¹4ô<4¨ùX¥.åK}®V µ’¥H£’¹6%¿Ò¿3oOdÖöÄÃâbàfçÊ ¿óªGÂTÿœP‹‘¡êQ è©Ëé©%·”à–ÙÆñ}{æÛSY]ÁñÜiÑí´Þ O¡Ž¯Ñù—ư€oƒ…ü,’y —FzÁâ~¸ êÍ >M .ç<†%¶w°Z¥1ÃÑn nXPÐBâ÷:óUüM×PKC~T ¬PK/3\!org/rosuda/REngine/REXPNull.classËJÃP†ÿÓKbkÚjmm­Ú]ZÁ€[ÅèBJQw§m(§ÄréS¹ÐUAÁð¡Ä™4«`À˜Ë™oþ™“ïŸ/Ç蔡¡Éf[G«Œ<š:Ú:v´SåªðL oö çÞÔ¨ •k¢—±íß˱C7]sèù3Ë÷‚h*­Û wFùÇ›¡ ÂîÕT0Š'–zŽS.Q “`Ïìÿ)+Ôe0’¡ZØWr!¯Çs{B= ê™Sn9ÒY«[bËw^äOìKÅ»Ux }ĤklÖÚYãv3ž³zB+£ŠŠôùÓ xÙeûäùâ` ñNí˜@ˆ!Ú'A£CµÁá¹4["k ’°D6WxMq¬Výg­a#áº49Þèù§% o)šõ6QO«Š4W%»Å4~PKKõ=Z>fPK/3\7org/rosuda/REngine/REngineConsoleHistoryInterface.classuޱ Â0Eojmµ8ø.ºtí(ŠBAhÁ=¶1¤”Ò´à¯9ø~”Ø€Õ©o¹ð÷œ÷z?ž¶ˆBLBL fiÆZ~”µÕæN°Y&ÚjtÝŒ¦{%¤â}ÆIÉZF+¦ͬ‘JÄ«‹C$š?D”éÆäü +N°øVwZÕºê='e¹¹±œ¯°³;Šóÿ/çkÉsxpãù#ø@—c—Ý%p{„PK©º%©PK/3\#org/rosuda/REngine/REXPString.classUKOa=_gè à P^ZŠ>h;¥å¡(***XЈQÁ˜8ÀXGKKÚ©Ñ7Æ•?Â6.Ð($>ˆ;Wþ ÿ…â½Ó¡ àcó=î½çÜ{Ï/óõç‡UÝÓPN]å¨C7_zUpLƒ|ïåÓq'xïÓP†“Û¯b€/ƒ*N©8ÍÇ>g )8+ Ì›OÒYsV övòùÈL¤ÍL*1áäìLª_À?`glç”@}x§;rC@>—µª’vÆ/ÌM[¹ëætš, á]Q9á˜3ÇÌy7PA£@Ïn±Él.•Èeó…Y3qm8“¢´ßºš´ó)8G奭Lʹ/ …##ª/‚]Ô@ÀÌ›ŽýÈ%ö+Ó¬G .Ù’­h¥VËMœçn#»Ê!Ûùñ!ÚÈ=¥à<5ãdÏ[Ó…ÔFÚß¹K8m"[ÈÍXlV¦Š»(ºâ«c/†ª·ãt4 ‘HÍíγ…{÷¬œ@ãN‡žµr:bèÐq—ÄS#|Û‹}:Fq™L1ö%éÐFZÅâq:=hþƒæíýɃ$ÌR5M™™€ïö”;úZÂÿ/ÍÖœŸ·2ôevìöéí0y}“ت“ݨ·rÎ|ìÎgıæh®‚>’ØÒ±¾ýh¥7TOOªçqЩœÎ$$­AºuуòÑ^]ˆÊŸá›”Œ‰÷Þ¸ &Z÷@¢µ2tT£Ò…‡<ø]3¼Þ…kÐ$¢X„lx¾-¢¨¥zêÐL·Ãð­ŸOA‚ý´¯3À»—ì”퀗-EtLÔ­@þWº µÖD͇Üt§«T¤UÐRʸŴ™´m^R¾ ÚýÑwV_—dñ»VöÄ!/6èÅúäíq”Ž:>âÅ5{qe̹´-ô ­íÿOh;­D½Ðç¤/7q+ý$'¥Á±º€ bK¨{ ŠLbI×_øÄâúwc©¤†5RéÙiè ⸫Zòh ±Nc+*eÖ‰-Ø´H¼ ®ŠÞ­WÏ7¯ž—Q6ùþÉ(ô¨Ë(h´,£b:Wé¼€ÁÐ[T. 7ô šسŒª›†‡ T Øë‹pŽp{ù²AA¸¶z0cޝ-Æo6ÜF­òi?zh6GщcèG/îà8fЇ#NvvvFžâÔÇ’’¢Ì¤Ò’TF= Ÿ¬Ä²DýœÄ¼tý` p^ºµO~Qº~Q~qiJ¢~k^zf^*Ž°Ö cdà Î/-JNuËÌêð--ILÊIÉêÌadâIPÂ>ÿ¤¬Ôä6FF&`dad`f`±X$PKc”ÂPK/3\*org/rosuda/REngine/REXPJavaReference.classRÛNÂ@=ËZ‹(ÞQ¼”z!ñãƒF Q£ÆhŒÖ¦[RŠß¥‰B¢‰àGg¡–¹s©—kÙ (ÙŽQpìF³ªÎ-ƒ4d¯ÏJf£[-np÷ÔëgBÍêHÑ'ºk>ñcÊõ¸1×¾pÓ2ü²n”dÒ…Ýt*üȽMŠM…þœßs‡[¾-$2’X—1†„ðT†)¡ý¦Y«rGFÓ2òÐØ­p6ȹcXrÀ_{QÝ!4† *ÆUÿœTD¯×¹UeØRûÛ?¯ñ¢ß»È¡|,Ñ“¥'Æè§Á†ÉObœP¡Õ2ô’ÖÓ6Þxé°S„‘ŽJêð'<~ŽØA²#ÚfÁ‚a“ž`ž¬ˆ†µWž}ÔáÔÿ¨iBº5Z¤6D4÷ÐM›mDZˆ*1¡n!®Hä·0â/”!œ!ÀìPK·\VΰPK/3\#org/rosuda/REngine/REXPFactor.class¥U[oWþŽ×ñY/ ¹â„@B| ¦¡@۸ܓbjÄb\ÚnìÅlpíÈ»‰Ô‡>÷§ô¥­ÔØ<ô¥? :³^œÔx Š2眙of¿ùÎů߼x`U §ðµÄå0fpEâ*×4qg7$nJ,K¬H|£án©˜ã1«â´ŠÛÂøVƒŠ£ïp±UN¾Ëæ›ûîK¬i8Ž<Öyö@ÅC¿SñˆÇu‰‚ÄcPÕÜ1«¶ÀÑbnÓØ1ÒU£VIç†U«,Qø©Qrê É\½QI7êövÙH¯-×*VÍL¯­¸QÆe¬šå\³=*Å oÔ˦ÀPŽRW·Þ0ëÆF•<ƒyÇ(=¿cl¹k‰¢Ä¬À…Þ•zòX~t/gÙŽû™éX?ªŒÈôE|ðªe¯xª(±8i¨ÇT,Þ_¨°a·!ÉGbñž¢G {Õp¬ó6Åînlš%GàUÞǶ½„Uz;¯Ñ©¦åëÛ’¹b±ÔCÜI›ÌYÆê˜Ç÷ÃÝy:NóLø÷¢ã ŠœþƒŽ9œ8ÑG7:½¢íИO¢@Ô'òŽã<~dó“À@©jØ6/Ü–6t”P晩ã)Üv.글‹ô¹î^¯o[Õ²Ù`ô3_â+6D‘'ÏiòÄŸJgã}âÙšcVLŠY¢IgšÜ2~©Ö2)Üû”?va£1Ÿ«4ëí?G >D–|JE{_†ÎiŽCô£}¯…À)êãƒ7G3lO›µÈÆYºC [[fYèÕÚ{.oÏèÓTÆ7Loá =@€þèD»3:­4†!hÃcdã´ú‡ÞX…F+‘lA$RÿBS^"ð;‚©](‰= ‰¿1@ÿŠl!´ INµ°‡paà%´‚²‡C QZÐó… ¯"ƒ-ÎS4PP"CäŒ ç[8ÒBdGÿr©$ÈŽb€ì ÙÃÁù†ñŒfIò&x‹#P$f$R 4}K‘®€;]pû9ëõó$ý©Dr¡…cÕÐ>¥ˆ›;‰¢DoŠhL»t>c:ì|[ÒOÑ;Fÿ÷$•öHýJ"h|H›a¡“,d²‰Ñ6©OTt–vxŽ$=Cëy¬#åR9çQÉÐnó~·©¤X£ƒ\ö«µµX„†ó´9ŸcŒ^AJ,z•&h¬\ðNNÈõ\"{ž2Ú¸¨‡cÉåŸ]Ð Yzœ<èIª2´‰±nôU²—ðÅ{…›ï†Þ$K/Z§ë€ëÝÃñB ‰N41‰’a©_51™¦E'»+Ý"»äžÌPKÿݳïÑÎPK/3\#org/rosuda/REngine/REXPVector.classQmkÓ`=·‹M³U»ÎêÖê¶:M[·‚_+‚¯0CÜêðCº>ÄGºd¤É~•æ—6ñø£Ä{Ó ¡£b÷Üœ{ï¹Ïyòë÷ÅOO±cc $¬ÛXƉMÆ”iJöЖà# ›RqM´L´ Åg:ÔÉs‚Û:$¯¢"”=ª½ô¤¯â¿?dfÝõ¢8èÆÑ(øÝ÷o€;?¼óô(éÉlq¨Â ù’Ií,=:TÇIgÄ'ÖÖ£½ n눿¬$ÚOb„ªÛò¾úg~wè‡AwÊö‹IôZõÓàªÍÞÒøX½Õrž²¬žêïȬƒ2nIXvPÅ ¡6«ø2ÕʬbÍAOt$É6'ŸÔ±FhÌ1yå¤6§ÎîýÓSÛîu3×ýå§a›uww~ÙØàºyLxäx›¿ŒÄx£=}ç„PáXœ’YërÞº‰¿\kw&(üíµ3Öâî’AriYåjùÜj¾¢`|›Ñ/s¼‹{yߣ(•Úc,ü0¼ÎùÌŠ*Ÿ}…¾ø|¤Ç¼5/a|œd&Šc˜‹ƒ¨ŒQªØœqó|f·l­ÿKÈùO!¹Á†ØÃý?PK‰ÁþƒÃMPK/3\!org/rosuda/REngine/REXPList.classUËRG=­3 #Ûˆ§A`ÙGHB"Äqó~€#G`‚lA^#1ˆ½J¹pRÙe•?È&Uö†E² ©Dª •,“ª|R^äÞÑX¦d‰b¡žéÛçžÓ}îíÑŸÿýò€iŒcAÂ-,tb ·9rGÂ] ‹\’pOA'Þã!Æ‘ûÞWàÁ#ãü¶¬Pâ ¯=±*ãÆ%¬1"!ã¡‚~|Èìë2ñä1ƒ“26ø¹© ƒañJ\ÆÇ>‘ð©€TÔžf Ú–ÀP¼PÊDK…reK‹®-æ3F^®Å²9#Ð1kä s^`$Ð6±.àºSØÒÎÇ)¼RÉ¥ôÒC-•¥ˆ'ajé½e­hÏožBÔreññjC%Ò:™ 3ñ]í‰ÍjùL4a–Œ|ÆJðjåÍ4žè÷iõAjWO›½‰èz”Ϊ,î§õ¢iòe ŸÑÙ³z>cî81šeÞ‡5Ý ´Q^ÕŒR=Ôe”×ôt¥T&%Bj6ÒGB§˜+›…úV›·d€Ì3 wõT%ó¦$ •RZ_2,g_XáLhƒíôT\Ãk J ´1QàBó&8#-0Ö&ãžž×KFz,”;¡"Š)[¸N:Íl·+FvK'à fUèØVñnªÈà†€;¯åtjHô¿š¸½Íys˜_°ÒŽ »ްÂT{*²ÈÑ✊< T¦p$BÓ/†Oi+êì6«õ3 Ú¬/åœf¦w]cuõœ¿m“6úx*°Ù¶‘7[w²«l|nõV±¨çÉ¥É@ Ü+!Ûpj%É ›`ùÛ×*“<9mß궘©çÊd5}øŒ*\qïéOo™,kÙÏͺ±ÖׂOËô)7ƒ;–Þºè‹Æ ÍÒpÒ 0¬ACÀsG²ç\¡ŸáúÖÑxŽœí‚Šúj†i6Ç1zà0&LÐó˜ìy#N‚“¶à.Ñ0ÑÅ`¸÷{àF/Ñg)†X±Î:3 Ñ¡“º[w²Eç·Ê’®_Ñ‘t†ô”’Îp¢Ù–'ä}tà\Â(Eé*+³MÚ¶u¡3ü ®”x¨Š®ÃFºb®[Wñ:½¹(>M¿7pÝÞ’Ÿžt?!3Aê÷Ü+~Æ7qÃFÙh‡« ñ­3à¸æoŸ¢‘¾#6nÄÆ¹y—‡MP®*}|lè†å9müªè9²ú|‚UtWáý²·çno/Ūè;lºÎ5e¸úWõ³ª]K‰¦s ¿ÉL=Ÿ¡?ùRk€x½ƒuò.Æs>ÛÙçXõýˆ¡çˆù¾…òWá{Äk¾*FV&ÇpȦ™dŽÑ:ƒB6êR~žåÇß½ä%²Ë·Ó©®0ÃÕæ#Fèæ€*?JõS ¦©bsT%r:E^—ÈÆ pŸ¢_cÞ²¢îá—Ð/|ÿpCK¡¯›,˜·XßýPKËñ ^ PK/3\$org/rosuda/REngine/REXPWrapper.class}WktTÕþÎǹ¹¹IÈ%“ð(‘IȃDo*!ÐBÀ$UB˜ C˜ÌÄÉDHÅg± ‚-V(Úh ¡NPh@­¶"ÖŠ¯²º–mi»ªR[×rµ«Ò}ν™Éäa~ä»gïýí½ÏcïsæüWÏw(Á% µhæ¸M`˜£EƒŽV NÜα‘c“m’ð]Ž;4èhãØ¬!Uàwi‚»5¤ãŽ{5dànŽû8¾§![4dá~ŽïslÕ0Û’Pƒ8ƒ‡Ä`;Çsü@à9vŠ`ˆÁ8¸‹c·ÀÇ8öÜ˱Oà9ö |œã ‘ÁOÄà§ä8$ðIާ¶s郟qü\Å <­b§ŠÝ*žPqHÅaGUSñŒŠã*:TœPÑ©â$Ç/4TáÙ$Dѥ┆çð<ÇiŽ3 ZC[Ä·jnuõÜ:†ôÊõžÛ=EO°±h^ÀÓÒ2“!¹e](é±HòcßZ lì$¯ „<1•¾&ÔÚˆùMi…>O0¦®‰„ýq®VÖ+‡äšÞñR*‚_£/3­ìsABÌòĘe‰1³üAdƒÍ{3ƒ}^h!­ÒôUµ65øÂµb“bcØÓÌPàîµKÖû¼‘™¹•¡pcQ8ÔÒºÆST=?ØH\ÂeKi™Rj"ï†Åžfé†ã— ê,oÀЩՄZÃ^ß¿ˆ0DPn¡(;p¡¢Ã‡µ Yƒx×ѳ ©ñ|Äzé8‡F Bªöln_¤)ÆyriF±ÖZÇKø• ¿L'"N¶´ ‰ˆÝHˆ w„aÔ Ì-Òñ ~-ü†#Î5• 1­=<åÊP£ßë èxç…Ç×<šÇlðtL½à]Ðq+èX ­¯ìKŸ)ô¯ëøŽÐ+õe:VНôÞ–bCÈîÓ¤F0~«c• Åá2Ó°BÇjñ•ÑÛÆZg²ª3­êðô‹(VžL–›& DÄ7t4ô‹(7„ ëMÃrÞ~ó4žŒV˜FË…·ßéXÓ/7k?ÈôM\Œy)ºBkµbyšR¹2±œ,K¹ 1צ°gÚ}ørž}øæœú„·&ÑÇkOÂdŸÅüM^_sÄ êx k9ÞÖñÞeß‘¦ìë¨P³Eíú=šTvd/Û+¢¯…ã=¿Ç…ÁϤUÚ 'Ñì ¥",u‰F_ÄúêΠ'‰}³'Ðꓽ«ŒÁá®/=L¥fWTPïrWy²Ù}ãªr¡**ÝêÄqÝr¡[.t.wÿ³/ä™îŠB(( Ë-”ŽøÚP¸ÊÓDþsr9ÀÓšI‘-´6ìñú«¸­%âk¢d}aZT—I÷‡Š–šœ°ÏÓÛßD1¥"‚Cwg-=Ò ‰J¦/M”«ÄeÖY¸ÜÂz WXx«…+-\eáj =6XèµpD˜èóô¿‘F£¡#¯ ì}0¬£ÿN)L¦w„ëMSg==m8ñWæ½e/Ô¼sP:ò¢°UN4ìía?£.η‘Ô…£ö4œuù]à µÆi$Õ‘JBëB2 õ¸P"Ŧƅ©Q¤™Â!R˜.„C¢0º0”„qaF.S˜)…YB˜Ű. 'áˆv¤ÆH!Ñ…otLìĨ¸ht®¢l)r Ñ™u'ƶ£”†ãçwÏÉï>£Î°ÛJ.Ǩƒp ·»ù.G‰˜è;|íŠà·[Ìñí(!f1ÏhUÝ¥&Óe?ˆôÉœ²DÒþ)&[Ð…ëk‚ÏmÅÓŒ§-鉗$ãIf®L^.[ž%šh:ËÿZg)9+hÇdbögµ˜EÛLÞÇ ¼"3⤯˜6PÄb3b‰Åäý#NÚQÝ1]òn¼ÉfÄ)ýy½"Õ={1Kå‚ÉÓ3ÕMkÇtN'g[Jo[©ÓåÜš»g?ùs¸œù.'ùsUoq’¿¥?‡Ež!ýɃ7³ ³„h¶™Ü+9û€É ‹ž,™Ü¬ÖAu§ˆd/¢™¾WRÍ­‚¸RÓ©h³¨G’6‡ê²ÞÞ“Ñ„ydWÛ¨}DȺ•$›Ð‚6Ü‡ÍØ†;ñîÁã¸G±$éÆCxÛéêÜIÈ#ø+vá vã²ü{p{™‚},•0ûÙh`98ÈòpˆáIvžb³ÑÎæ.ÂV‹§Y=޲Õ8Ƽx†ùqœ…ÑÁî"Ü‚Nö0N±]xŽ wþzC7Íò,‹â;KoÇ×ßÄKìô»ŒWÙßqž}D/¨Oèr»Š×.(IxCŠ‹Ê¼¥\‡·•±xGqã]¥ï)³ çá’²ï+µø£R‡?)+ðg¥—• ø‹ÒJxþ¦Ü”íøPÙ‰”GqEÙ‡(‡ð±rœðYüK9‹+¯à?ÊE\U.áså}üO¹Œ/”ð¥ò)¾R®áK›ƒÚsÚ2·eš-—%Û ™n+f)¶©,Õv#K³UV³tÛ –‰ ´ã¯1 ù—n×h#µ$ãÇ8ÆP»ýYŸ!)A•ÑǤ*ã3¨ *7ºV¢Çü]‚ª0¦rõUMœUBª©³¦ÄTVÃâºé¶Ýð~9Î!ÞÌ~"7õÜIÌA ®ŸožÂ'‘mÌ•8Þ(“˜k?“L×ÎIó¤ Ø(—XjÌ—8ÃX q”ñ-‰coKœ`THœh,”Xd,’8Ù¨”8ÍX,qöa YD7Û’N,5nŠ¢ú„̧ ªÊ,NTÓït`,å=Ž~¾§YçÐÝ~=r1Åpc:ò0ùT˜¸‰JµEt/O¢²-¦R-!_ÓÉÛ*Ï©TšÓðfˆÃB+¡ü›9ªt ”½ ôPK«Ÿ®žznPK/3\&org/rosuda/REngine/REXPReference.class}UYWGþzèalqAeqÉ0 D1‰QÃ&à°nIL3Ó ­C7™éÁ-fß;ïÉ›/yÐs"æ$ç$oyÈÊÉw{šÚiú«ª[ßwëö­[Uÿþ÷Ç_ã—(Ú1[‰6¤æ¢0q9ÊÞf¢˜‡¥ÂV± Ý£È"'ÓŽèò‹W® \¸!pSà%[/ ¼"ðªÀk¯ ¼!ð¦À[o ¼#ð®À{*Þ¢³2¸-½"øPÚ"ø8‚O¤{[ŧ*>SPfXi ;›îÈÚ¹|Jï˜è·Ò¦e,·] *æt+•1Ô&.ë‹zGF·Òc3—¤ÃÙª¬‘³3‹FjZÏäIÚQÚÙ¹qñtÜ´Lç„‚C±õ–|x™Öiá^;EÿÕ RFóó3FvJŸ‘°šÖu6,ZÕ RÁÎXë:VM:zòʈ¾à¹ŽšÖ¢ž1SºÃAYL\EfM‹¦†ŠÏIè¿–4Ó¶rœ2s“NÖ””’{AA¥™c¤FÖLºý!Ë1ÒF–y{&ã*ô¤cl 3ç¸Ä„6“:ç«Ì\¿µhfmkÞ°‰'—`ZòzÚ(,w}~Æ.ø™6 ~ÊÍÜ„~ÕuÓkÏ/dŒk 6Ðf$óÙœ))pG³FÖ°’Uê^Ðü­±Ö‹«’_°3-Q}9v’Â$ ¹º>;Ï,y¦>þ‚îýBC@’e–î"zñ¯w0 óR2–¨3çf”«–_Ò‡ºÆàmô©LΠW¸[È.QºB)ƒ)ž‚ˆc/oîZw+Yš´óÙ¤1`ºgEB)¦ù Ð5t⸆8¨¡ªøB×øJÌG4Âa_køß*ˆüÛˆ™›×ä\±êì ŽºÈÒð¾Wñƒ†n‰à(žÔp Oièèèè8-0(0$0,pF !0"0*0ާ5L`RÞÑ0³Îἆ ¸¨áY<§ ÎŸªž¼™IY 3Hjø?q[or—»eð3wº}®[r‹'; «Ê·.€¢`óʺSsYûjáDo\±&lÙLuQî­±Y bë÷U¦¹«õÁùUPãÝ+«:pñ~YïæÙ´|­¬rÕ°Ž+ÞD5þ’–¸°`X)bWèÃEëíD—¿|éòÑÌ'­bÂRÏì…¥¤Ý–…Ìv7©kâcu"D.P%Þv¡xû}”Ý£IÁãÄZ â&Tr´›]ÙžƒýœF4ÞÖô;ÂP¾¢Ò9PGÝvZXÜžæ—”™½ñßPñ"ÒÜCñ%¨÷QáwN(wÉÔЀ]ˆ¸m3½…\ï-´€•s¹F{ÍüÁ}Ä=œßcdhkã*"½*¥Œ  ǽ8ZèIa[W¸¨?î6”3•a9™ ÿ[÷¼P£LÚ†;ˆ&¤mûûžë,‚jb!ÄzTÑÖÉ0Žp¦[Øn£; MEhLʼn œt7HÁ ~<ÿ^|Ml]—\K[BÕ¯Å+\»ìAO{£Ÿ}”ØÄ®ö³e¯ú‚Ø5~ö1b{“ŸÝEb×úÙ²[§ƒØ›ýìnâ`{‹Ÿ-ù boõ³O‡ƒØÛüìSÄ3Aì:?[x‰ öv?»‡8ÄÞág÷GƒØõ~vq¬È®÷Ø¡°Ÿ×Oä+ã Ÿ×w}ìÁbGøña*­kðë†Öèø–•Öíòë†×èøü•ÖíöëάÑñÅ,­kôëkt|dKëšüY]£ã»\z—šýëŸÇ%½Ëc—óf*óS'ˆ/@/A ù©SD>þõ´w?vü‰–ó°‡×ÜÞ%ì«ÝOõ©úeÒoe q¿Ó³Ä””ŒÿPKÿgög¯ PK/3\ org/rosuda/REngine/REngine.class¥WùwUþ^3ɤãXh€J±-A¶4i)îÒ¢BKÁj[*E Ôi:m‡NgâdR@Ü÷}ßÜeóŽ…ß<ǿɣÞ73¥!™Iã±çô½™ûîû¾ûî»ËäÏ¿ýÀMøEÂLI¨‡.bZ„!AÀT&Ÿ³|xDBV96×Ë‹˜‘p‡D®Å<*∈ÇD<^‹'𤈧$šŸ–hé><ˇçDýw.!rÊÄ«hâBKÍ™úŒºCW-ÕÈûn vC%¤KUìb úqÍPtíÑbYSp:Þb:ÞBºtë3šeÓôÈpk𮊧«3ÔƒWÉNˆl6Æzo¯>O¼pF7y„Q>Ž0ÄrùlÖ´ìÜ•óQê-žñ’X¾¢Û;ÔOΚ}í73SÄÊp_fmá>ñ]éã+‰ê²1¤›¯¬õ‹%_ ¿¼ªx›¢mætÖGy¦;/‘¼á> çQÛtÑÈ{”ãe">'݃–’-¹±í£ÔŒ]ñÆ¢3ºWD¥a3oeÔ­/o²§·Ž£ÉÔWn–q_0Äçàb:hÚ[Í<Ìl9$_–ZØ×ô1ÕbXšQŒµvœâ~,îÖäx†ƒÄe|‰¯dd0ƹ¾&~7[fk[¬øÚÞ.ßà[†E{Ë,â;ßãòà‚(c=n¤H+Á-Aô\̰²Š’-⸌ð#•R›dœÀI›°YF7zd aCsÀÅl1óÔd¸+~’±½ÊšZnZ±3“Eî¯`i‘V›ïî¸fÄÝ¢œhsŒØ»¿µÓ¹žŸ¹9§¨ÍXÒgØê„jq­Ó ­óÂk†í`{Áõ=wǃæp>39 Ú“fq"åJŸ®«о9CE0W¤’šS±Ôq"¥£Ï˜13 _Þ©XTï‹´–&ÕqÓT¦)GVûëÒ´á]7›U± ê¼´q‰Ÿ>Õ§Z2Ò=;æyJ®kD1Ëì±]¢Y´F¦kä›):ëŸ2çSZËEÔvçdݦ©« 9VØ™¢,«÷q—H0¯nghHŒz›yÛK¸È¿ø;ôÆ€¶í~°ù;›¸œ¦Ðèd¤àô­ <Ýmñû·„ôᾄ~2P­å•žâôL…žÆ[è­™fŠw„“çÁÎ8Š·Òq„QÔâ6ÜŽGõ}õ 4w'/ ¦?õZ."”¾!}áX¤1IÿDÏ£öR*&±Ë¸¦y ÑÓµÔ ¶_Æ‚ô9,‹ÅÃdhg¸1ÌhmI:”¢¥6Zi¾€ZªëŒ4Flo!þåXCníÁ ¹ éˆËÄ \¿ˆËxqáâW?ûB5‹¸ä….¹%hB?Ú Š„š?#E˜™ˆoÐL‚]ùðÞ‘âÒòQM! â>C0€ê×Z \œhU<­ÜXkˆØ…ÄŒ—qå,g ³î¿¸úPKŠaCcPK/3\/org/rosuda/REngine/REngineOutputInterface.class•ŽÍjÂ@…ÏUkjjÀ}nëÆ`¶.KAÐõ4' a¦Ì}·.|ª˜m¡ à]ܳ8÷|÷~¾÷Džô QºÑ¥å¯JUsBò²PZÄZ÷ÁâôMŠRò‹NÛ±¸fRęեÓùhMè§Y¡¾–Ü&ÆäN†GDé¬v¦øí1¼Éð‰0SNç|Vúóç³³röÓÙ¹´\oYÎÇþatõ/@üÕ[½W<·]¡?í¡Ðèº' ðØ8„^³[PKã uGËbPK/3\*org/rosuda/REngine/REXPGenericVector.classVëSWÿÝd“ Ë¢ Õ@¡ØR ¨ø@E*(ÖÚ%,°’4Ù¨ø¨}Pûní‡~ðKÛq¦ÃL3¶SÃL™:m?´3ýÔ¯ýOÚ-=g³€ ã0s³çõ;çþî9÷òÇ¿?ÞЂO4£GF¯zJAõË8.ㄌ“, (ð`PÆ)N³<¤Àav>Ãá#¬•qV=¼¼Èšs d¼Äây/+¨b[4c jXhF”¿ÆBÒ=˜ð`’娌)6L+؆ œ)æÁ q†N04™“¬‰zðŠŒ”Œ´€œÔfc m\ º7‘šŒ¤é̸èŠOq=2Ðk¤Ívw‡7̽µÁânõCÒÁĸ.°¾—Ôý™™1=uJ‹‘¦lÐÔ¢ú´¤-·­TÐÒuæÄJ¯–î×Lã¢~L»¨›Ö£¦ÀÆ`}ï4É‘˜ŸŒä´í2L¥ërTOšF"ž–q‘6Óã“æ”€3XßM¢‘fpK(5Òz4“JS 2j¶1@Ö Éc&Í”ŸÌ¯%§%23qHËL.»)ƒ‰L*ª6˜‘JÞâ=®§ŒèÕžH51„Š]¸$PU,±ŠgТâ2Ô¬AœÀ¦"V:Õ"–\*fq…˸*Pž¿+W\›ÑÓl¿ÆË³*®ãUþº¡â5t TX1ÓˆEŽjé)ê¯ã obNÅ hSñn.c[~¹ý«xïPÝù9dŒØ¸NæÃ8¢â]¼§âºìJ¨•Ad>31Á!GqD@\åúÞWñ>p„FùHÅǸE-nj"—ëÛ‹Ðò¿C*ÎÞ²}ÃÙB½Pžß«Á"@}FzF3£S+=lõ)ÍlÐX[–.è³4ξ`}Ád•ÁjFh&C‘¬íEB$Í4y×kN©@]átŒ¥´q…¿4šˆ›šO÷è³¼…ǧ˜g²Dé3zÜÜo²OwY'V’²î.€P³€¢wåò©dˆïƒdRéÁ =¦²»µ=ðFËf´ËÖ½Ðmê3tŠ‚n¤ðbsW´C³î§îŸ&¶Ð£Ð _ôUBß4°´>GÒW(% 0аÑúe‹pŒ,À9)tRòpÝÆ®†E¸GØ(ýyĹÏHÎX²@W)KGœ^upe Xwë¿#TZi­¦w(ƒ„uØ„rª©»éÁ;‰xž,;à\Â8dDd ô»ÄÁ¶lÿvXuï¶ëž†“þCxå _M¿Îr¬†‹Í*¬”!8–(»3-SËYQ­Ä×ýR^qŽÀdrû6·÷ŠŽ‚¦l6úÂ÷k¾Àè"¼T͆~©Ur¶º|®š;Ø×ö¹Z²Øx%ÎViMâseáksûÝ¿¡Ìïþr•mnËÕïÎbÓðœKÌ/ýâ“nÃÕxwUëïsî­%Ä Ôr¼ä—8^²ã¥°Ÿj©žsRè_á»+\LÀOëúGeÀNb%ˆ:ÔÓÚ@œ„¨-ÂØ‡F@º¨qNPÓœ¦¶9OÔO“=I$déÚq¸‰=¸…½ø”¢>G'¾$Ý×8hqÜÏÁ¸‰E"—e¯ [ºòü2:þAùßp?D‰Œ*ñµ–ª”Ð@m"Qb§}ØuôK¡ðؤc54ïÇméÓºŸjÎyWÛÞ)ßï(­ŸÀï­ô¶Ø~µ¶Ÿ‹³ßÍsí¥•$ÛuÔêêèEÔÐ1h¨èt67dñ”Õ#oÝ<\Þ-¤Ëbëê±ä°Ž[´UÂqNFÍg%ê¸ kd¢Fð+fçù•H⦾¶ˆm#«¹¶®÷éøvô:÷lÆî ø;ï`{à3(!o0‹úáYPy!–çÔ-®†_˜õvòiäMùÕo¥v±§è¨¸]†è ‡Ñ‡3¤…޳ÖÎTHQ'c›ø*h'ݱÿPK½Éf PK/3\)org/rosuda/REngine/REngineCallbacks.class;õo×>#vvVv6F®àüÒ¢äT·ÌœTFÑ ×¼ô̼TçÄœœ¤Ääìb½¬Ä²DFåü¢tý¢üâÒ”D}¨}t¥Œ  Åú9‰yéúþIY©É%@㘠€‘H21°PK*‚hsk„PK/3\-org/rosuda/REngine/REngineEvalException.class•Q]KÂ`=¯n.×LíÛ‹ˆò#ièU`a Ãbš·1uŒÅÚdN©ÿÔMP]ôúQÖ³¡}\´‹çpž÷œó<ï»·éË+€¶EðXO"Ž ›"aNÀCJmvN5õìZm^^µ˜J½†çà :†32ãïô1ðŠ®_è!™2pÁýÀdHÛ®œ0ÔŠšç[²ï G}CÖײ]sŽuíÆ²c¸–Ü |Ûµêj©C! ¯O!i4ÍÑm×ôÛFסNõŸia˜`™A;Z*^,ÑÄ–7ò{æ¹æf^el8Ê]϶ç†9RÈJ 0~úÃz–vÿϥء‡æéÐs# ÄbH¿ñEpá‘’…ùTÓÄ*Ä9B©|P™€•óψ=gÈP]¢S`Ÿ’ ”PŒœÙ™s|ái’œ™éÜ—M¤@•Fר³Œ•™%OÈùòbŸòDÔ<¢ºíºöPKcqË=iUPK/3\$org/rosuda/REngine/REXPUnknown.class…QÛJãP]§­MÑvªã­Þjç’ÆKÁ׊ŠB¡ˆxC‘yˆÓ2Ó9)1Uü'FÐü?J\'æ©Z$d¯}öY{í³Îy~yx°†%Ã( ÂÀŒÊf5ÌéH¡ ó*[È ¨p1ƒ’Ây ß4|H…×-G@ÔÒëžô ÖÌZù˜°å7¸•­{ÒÙmÿ;w‚Cû¼ÉJѬÕýÀ­þE»aWö·¥K ñd¯î]„UÕ¬¹NxI'Í2Å3¡žtÆÌrý}iWš¶t+oÕª€~à·ƒßÎŽ§F䔨‘ü+ý+¹ªÈrøa`Y•ý˜è•Øl{͆˜À¤eº:S‰Åä—À\Ÿ#ÇS¨Ø‡Y ¥óS×i»ÕrdC`Å|oñ½ëøÈ4?Ã+ï»"v˜-øóSÌsøÂ˜çj ~€nu!¬Â=·{”1ué,æ—ÈN‡¬å.’6d¿b#!.>ÁÏÎ ÀÎ ÈÈÀf“™—YbÇÈ «á“_”®_”_\š’¨äš—ž™—ªä“Y\b­ÆÈÀ✟’ÊÈÀïö+ÍMJ- ILÊŠXáшUÆ5"n*Wf±Ob^zib:Ð$f Í( Pp~iQrª[&ÈpA°j¨ ½¬Ä²DV6ÁÉÈ Ëx¸‘ÒxÀ ÈÀ `f` $Ù<9& d``ÓÒÞÎÀ¸Èbdàñ4PH-'T­

ghVç [7îƒë ÝÀsÚqäÞ4Ó¹ŽÂG·7äu³Ë _„Ú[l‘ïrtÛãQGôNÜ †iéMöªæü»äÛá(êó¦/¶)ßxêó»Øƒc±@G:¨"Ûd¨ü?qâd(ýnеª <‹1Clv±O?—¥Ÿ¤w§¢,CyÅ„PK/3\ META-INF/þÊPK/3\ Ît@A=META-INF/MANIFEST.MFPK /3\¿org/PK /3\ áorg/rosuda/PK /3\ org/rosuda/REngine/PK/3\ÙÆéÍå ;org/rosuda/REngine/RFactor.classPK/3\jG…}È6 #norg/rosuda/REngine/REXPDouble.classPK/3\%:¡ÿû)‡ org/rosuda/REngine/REngineStdOutput.classPK/3\rv­–œë.ùorg/rosuda/REngine/REngineInputInterface.classPK/3\F:bœ¯$ñorg/rosuda/REngine/REXPLogical.classPK/3\ óx; ûßorg/rosuda/REngine/REXP.classPK/3\w½ Ý® +e#org/rosuda/REngine/REngineUIInterface.classPK/3\Kç}X²$l$org/rosuda/REngine/REXPInteger.classPK/3\×÷‡ÞÎE )org/rosuda/REngine/REXPRaw.classPK/3\M!N<È-2+org/rosuda/REngine/REXPS4.classPK/3\ë“=ê„.G,org/rosuda/REngine/REXPMismatchException.classPK/3\pð_a¬(.org/rosuda/REngine/REXPEnvironment.classPK/3\=}ÏÉ-ó1org/rosuda/REngine/REXPExpressionVector.classPK/3\C~T ¬S3org/rosuda/REngine/RList.classPK/3\Kõ=Z>f!„)Óxorg/rosuda/REngine/REngineException.classPK&&ÿ hzrJava/inst/jri/JRIEngine.jar0000644000175100001440000002604515133274036015357 0ustar hornikusersPK13\ META-INF/þÊPKPK13\META-INF/MANIFEST.MFóMÌËLK-.Ñ K-*ÎÌϳR0Ô3àår.JM,IMÑuª EôŒL4\“s2 ŠSSò J2Ks5y¹x¹PK Ît@APK 03\org/rosuda/REngine/JRI/PK03\&org/rosuda/REngine/JRI/JRIEngine.classå{y|TEòxU½7ys¼ 0Ü9(QWb1á ¨ì 0fâ$áð¾WÁÕõÄà…¨à…â@TðXðX]ÏÝU÷pw]÷òúîª,’oU¿7“™ º¿ßçóûã—twUwWWWUWU÷<_9úÔ³0–Þqa½A7×Ë \áÄ•nÐ1$ð*é\m`ƒ×TÄ oárÁ7Jq¶ r1êÄ&7×ÍPèvb‹k·NŠõnÜ€çHë\'ž'õù^ õ…n8/rC^,ä.‘âR).“âr)®0ðÇnn-z¥W ¹ÒÚ[ÑåÄ«…ÞOœxÔ× ¯?5ð:74ãõRÜ`àn79ñf7ŒÃÍÞâ?¶Êâ7¸E8¹Õ‰·ÉàÛ¥¸ChÜéÄ­Bð.·9ñn7ÌÀ{¾×‰Û¥ÞáÄûœx¿ }@à¥xÈÀn¨Âå<ìÄGÜàÂ]‚yÔ‰ íÇ¥xB0OØæ†Å¸Û‰{œ¸×‰O¸Oæ=톥øŒ´ž5p¿êð€Ÿøy'¾ õ‹þÌ !Nòº°†úÔÏ/RƒòåŸMBТáBŸÄ¡2¤:ઠ44, Ô­f늢]—Ɔñ'ÓÒ\Û™²Âó˜Œê¥óÃË"-áze1,€ê¥•¡p­hˆ, 4̯M±jopy0 × ›ÎàšÆæ j¼±,ÐT-3ÜÒ`Qä¡L4"ä¥"ZÉc˜žY šƒ1YÈ/èfï<^/Ôó¸Ì +[Ö, Fç–50&½¦™¥2'ÐhÃîëë‚ͬ1èÂü%«k£á£kš£¡ðŠIßKÈ‹ÃOÚŠ`sµ¨¶o2çÉÊM› ‡š§°ä,`euÅŽtL<ŸŠìœ@(\‰4vpY°À ‘“ÿ¶ÉŠüÿ%‹…û~ù©$ ½ŽÆ@´‰3*ÿØRIyQ•¨<¸6ЀP™ŸrLÊŽn馱 ­à=« Ž~øZ²G­áÒë–Ŭh°)Ò°6?'¦Cw”2lJñ Ó?¿<õxƒF4Ú  ÇÍ:£ LävÂ$PMÍ]¹ABz,… ¡sÉu7‹¥Ú‹¥Zà±ÍìmBÑHx 7NJ=«[¡f„ƒë’9ê"b™|8³[kŽn¨ˆÔ­V0G\½Ai-a«¡ç— SÙM-‘hsS|ìgzÅ ôC ]¶æÁ`9Û‰ò™ãmfî²UÁºæÔúìpÈe×] 5%3ˆ4X',Å9<Ö.Õ^Ñi-M:ë!q¢fF«ƒúø2§ü eŽÅ Áš•‘us‚MML°ø~<ÑÒ•ÖÜÌPC·³»^<=:³¡¥ie|;ÌL`mpv¨©9Ý `E$P“ël´DëìU3âA~”¬a¢Mßñ2‡áp„!©}s<|±ç³öá 4°ÑÔoðE[ÂaÞƒ¯ØW‡#;–¦ /¸¾9®Öûê$AŒ¶Ô1ß¾H؈©Ä±NÖ¦qÂ@¡‰éÈ™XVgép/.GŠ›X Ý2Bn¤‰™˜ebÌ6éD:‰£y©Å_KÒÇ{÷…Í¡µA_ChY4Ý`Òx*A˜!=œ`ùì Ëjò5G"¾HCýH_Kc=Ÿ_TŠˆ{|kÍu+}Í+ƒ>› ™ÍN©kõËv'˜4‘üM2i2Î6édœÍãç‡%UŠ¢ÙòJ¾j“¦W]©0éì™t jÒTš&+”š˜ƒ¹&öB·‰^iõ–¢rÊÙ¯›ÈľØÏÄž2­‡›4f L¯Vâ²õÞ!Vyu¥%¬1£&úòeÐ £N*`f}ìÕ‚QËYMšI³ø”TIÜõ£ÑHÔ¤ÙTfâxä æ§àjN¨I 8n€&•‹ÌN™ N1)Áß™TAsxÙ`ŠT‰Pt¼S1´ãdÒ\ÑBF‡iVDÂ+LªloI0}å%E}’ ´°™˜tºpZÍN‘=ŠÆ´5’H#Ç@e`,-!ÙÂ^Ǥš‡0¢›ƒÈÄco%H_}‹”ØÊ"%Þã|“ÐB„áVfá[`QïËoŒr’½¬aƒO"#–…Âõ!ÙÍ"ªål¿s÷ÉU€‡1§•ó+*Ø:¹â›1qN4i1-1é :“ï]±_Á¾Ë¤³h)ǬU,,“~D“–Q yÌ£Iõ"¯ -7i…\kRYª"Å\ÉáQHYiþª@4Ø ÚÎUQÖ…jMAÃu±Ã¢UBqµI ²ƒ¼³,‡$#×p ^·fR˜" 5×xtvj3­)L€Ó“)•±É­ªQM©IM´°¿0©™ZdäZ“ÖÉÊ©ˆVDV„X“2t½Iè6žCY!áÀš ¸Q:WŠóRËqV0Œ†êcû:Ÿ/©œU`IÐ…&]D›t‰—Òe&].–p]Œ00÷öéF5Ö,‹¨íýXŠ+¼©Fž(®J-ªùáÕáÈ:u†6ò©í”]ú–G#k8©Ã ŽÀ)ȾwæqÜ _~Ón*¶Ýfžb(ÌCõ&]-&ÿœcÒ5Òº–~jÒut½I7x£´n’ÖÍ´Ù¤[¨Õ¤-ÞJ·™t;ÝaÒ´Õ¤»hï—}î(ösù*;=Y.Äð2wˤ{è^“¶Ó“î£ûMz€4é!ÚiÒÃì†é²KZÒc&=.àÄŒ=ImlÞ«ÔM ÏVbhÒnÚcÐ^“ž’“»ž6éÚÉ +ó#ëÍ3éY)öÓ“ž²ÏÓ &½(ú6lžy‹k“~Æq˰ÜÄÓé [Di¤…CîFN|²¼onÜÙr€<„n„‚Ô.snK3{,9TQ>±|b^¢ùìçRO˜_–0øez%UtRuY8™ø«ôs“^“tªg‡¤<6˜ô:'<ô½iÒ/è—cºÉh¬tÐÎûVyKH¼MãR6ûcÐqïÊÌfwì$æç­ŒFÖYÏ´¤LŠiR°ƒî»¤›‹MÏÎk+Ï2&Å5©»ÌZž·$ý Ö# ߉Ü|[{ÿâkQyŠ—‚Åßë­‚Ã…¼š4ms$êsì»IìéªWWxžÜX´nhÎuPóÌH´ZÒùphV—Y ×4ë8­³l׺¹1ç†r!s9Tõ”;pr†1é,vMã ¹ù¨6Çl ÷OFòjWe½…ävñR xôÈÎ ‚QÉÀuæSî;¡¦„Ksz¨)éëb™Î„ëÅjzåËgç‹aò³F—v`4Æ.ö®Žý¦gòÊñdŠ÷jê3>C½×8òËËe+c ý©«¦‹ÉLµŸgzw!$&-fÉ£f†äe3Úµ,2Šù·¡Ñ%Ÿ¨LËZ¦67G+%ðÊôò‚.Ï¥»c¨Õ…¤x‘4Nº L'§«‹<óª©nB½]]ü»Pž3Ô»9ñf²¦ãLëM|—áÐݵì%Sú•C³ˆã伈dgÂ|y—kíŠínrEE¼‡%8‹§©’*"Œûþ/” ”ä4”…WrÚÓÜ”J‹åK-ÈNÛ^Í!:-“—¢%eÿͺƒyÞ÷ݦ•&.<]˜~\Yi‘Hƒš^¦æM;î<3æñ$´×,§Ž2í„núS]Üõ{vuò{öÀniXÛK~ñ®Nxñ†A@ð ¼ C¡¼ïsûWòEüšáß$À0üaüÿM€Çðïà?0üqüG†ÿ”ÿ™áOà¿0üiüW†ÿ–ÿá$Àÿdø³øs†¿H€¿dø«øþWüo†¿N€¿aøÛø0ÃÿI€0ü]|”áöå³L€‰a-Öv$Ài  °¼èBwœ~Opʯ êÓtÌPu&f©ºf«º'—º—ªQÞ¦UÝÛ®ûص׮ûb?®‡ ûc¯9€¡“y-ùëõà!HßT»´ÇÞ¥8(_r€|+± Ò`5dAúä;À,$Ÿ˜0Óº":Ø&z8Ô„ÁLä dí½–[َݶ_V(,꿌ÚÇ]¢‘—8›7-Ñ3a Ä!8”KY"1(´>Î]j{B%M!×24 ‡ÛÜŒfnÛ³P\µZ¶»€GcOt+9œÙp~ÒŠÃp„MfÃ2ÆSX”jú%\_Úiz¾=})Ã껗¢‘#¡í]ß æ£q X46B&lR»/jhi|Dcv‘L ©Û ì´l¡µ, . à”ÂÝ^ˆO‚SŠ )2ƒ¬-!ÚÁ좛=Ý zÞx[ ™#È‘2~äÖå ãÈŒ3±ÞBJ„ß}˜·2ÛÀ;^·P}mÂ…Ùý F.Üý¨ÚÔ÷A^­¢£·Á€=0p7øž„A6ZðãÏ|Çú†tLq$LÚNK@côp6éOB¾ê4¸óI(ÈÑ[a€ÅtáèåwÂm#¼Žý…C‘:·ðQVÍJ>,Q€>¥PKiQèÏåõ,õq,éñlÆÙ|o/ÜÌ>õ­Œ¹¦Àí0î`3¸VÂ]_ç0÷‡¢_0ý_²w~›}â;¬ÂwñxO™Q8“Ìèm1£#0þ¸vPlÛÁ6fUçžo¿I\#;8Juc'ÿ¿ÒiÿVèWiÊþ ->FŸ XÒÄõxôæò×ôø!ëñ#õïX濇 œ •r‚TɉÑN†Öp2t'A[9 ÚÍÉÏóJ{ÿ`Ì?úœË/8…ù’]ÃWJoE&z#ÑptÐξF³ ŒJs¥9LÖÜ(ö&–æ†rXtqÏ9X™t⊨ F—8r®[!=Wìàãgð„ØÌeéŽQ2ÍuXÒ)e·ÁØÊàðÏ…3é\8÷ïâ€8jXã8Î-‚ÌÍ ©Ú¥$óù7™¯yÄ·¼ÓÃ0–ó²Iœ•q>6‡ó°El²grîÅ×sÝ¿5%¦SÁ8 # hFÝ]gÀ8G%K¥ÒÁ¥„åBéùîµ8¡#å3;ðI²;ÇØ²Ûϲóp†~ÝUây&Œlƒ·À®Nb±<ãÛ äˆm\íÈì »aâ~yüm0©Ä±ryb6cóÚ`ò8¹ ¦”8ŠÅD}ŠˆºH‘ÆÕ©[ÀÍÕÔV0 ¹žV±#F¼TˆÇth(&ÒMM/qæ:]¬FNÆf0í™YGwÃ,K‘θ"–"ýz^+§9^>rcýzŽ‘¬F· âjtï÷ê»Xl7°1ɲúR™iL« /KÉóÛ4tAÎT£Š1NáøVÍm€]àJÎh×bO¸s`#ö†Ð b_Žuý`?ö‡—8_}%ÿ¦ú1ëä/ì̾äú[ÌÖ>„µ=Té{¤ƒYuº»GvF/§û;8õÃ0D´~”µ.zþ†™¤rERgq,‡WK±K+‡bŸ«D/f­[Z-¶´Zœ¤ÕbK«ÅIZÕY«<1»8I«:'Nâø†Ì±ÌÄUÈõ´91¥i¶Ú’l!—å?{¼‘“Öù¥%£#~8ËÄb$ÀœÍÁ •·ÑÊ™Gk\•솀R ƒ3Äló…ìÉ'³O˜Ë!aÛ÷R AÇÙxk¢®Å ÐÊõV®wpòú9™Oád%ñQà>EÜN³…iXLJU ZÀ˜/²£Hf'ÁŸÈ«X‚O”ÜvÞý¿¢’O†œ†r9 °‡s[ç";ö®nGVìpˆ£sw>!ž$BuBtÎï†Gy×Kà\vï’è?®êç9”?Ÿ<ðÖÑ©|b¦ò‰™Æ'¦”OÌ >1³øÄÌæô¡œ½Ýip.ža5ü˜Û±‚OÍ؆•°çÂãÜ·‡ûžçúe®ßÄx ç)-³ã”|ÃP? ²‚–';IO\›¨Ô™è(cú:)w<›u÷¹˜1ò¿÷LÃ9îí´÷¦TZ”]!*Mr]Ó‰nDUù» µÁœŽûb_•~.b¨–…´†àƒg°1Ÿ©6™ÚèÁœõà«»žÄÈ—5kÆ |ÜùTèg ìX©S@Ø•ãvk®Ÿ}¾áM;ßzÓž½¾r•8ÙtöAg§û=Úx3Çäžm°AÍð¦å˜cÛ º$=7]ꙹé* ¶BêÊ®iƒy­`䦗8 sÓy‹þLoæA8É+9Pþ½0ÒëQ½ÌÐü…ÖœjN¶ ²¥I½Èï¾ÌÄí—{=mP{‡ˆtq­×³–ø ±ðV(óºÂt¯;û ž½zsëLÕJçÖYŠâð}°´6fö?ò»!à7“¢¶¹+Çñ€Ü?u°þ¼êº t€ÿ °ðô–]Ûpì{œx›o=À¾ÞjoJs^òE‡2}-ÒèœB첕²ÌïÜuµ^§°\_¹ƒ"ª#;ØË[¡ÒVˆ\¹.‘Å$ô{Ô>]¢[ÖXVÖVÃ,³:™ðJú>ÕzÓY LzUeñ!ê¹VׯúÛP¹îƒ51dXF~j#ý.¯ëÙ§~·6Þ“ãáö6q0ÒÊñŒâx®j}«Ý¸ŽJÖEó.ó°:ßÞg×zÝB1Ê7Û›Åg Ùï¶6×"›ó ?=×#û믶–P)ˈAËüéÚøŒœ Å@NF!¯˜1𭮿² ^îoú!ÈcöºwÃZ•aHÛ›¾ÖùX_ëÍf603lôçÄö|® Ïã¼ï_±“àXâÎu 3á\·mòõŠwœ_bÆš”d ?KA̯c— ŸkÊ‘èáÍb¿áuy{´ÁE w°Éº¼YÌ_£sq‰{Gûu9ެ´­Ðc\RËC˜§KwØGAA—1‡5ûàòÛî†+uê@á3¦tö÷ãkù^à¯-¨í†ï†+yLÿ}pU­ÐØÈ‹hSmŽCÀ«+;ç¹ÙIFš-y®ÎY¹W/“è‹ÛUý¤î—Z/ÓO“Úrjx=ÔsäÛùrHÇ<+>\ÅQz5G€˜€a¶ÝLÁF˜…gs4ˆrþÔQl†K±6áZŽÖë8¬‡}¸½ÿÙœ;ÏÞÿή€¿áá_x%´ãUèÀèÅÏp~Î÷¹ÌÙÕ¸¯ÁíŒ{qqûI¼÷ãõø*Þ€¯ãÍøÜŒŸà-øOlÅ/ðV<‚·‘†·SÞA}ðNŽ÷P!ÞK§àýt:>@óða: ¡ î¢F|”®ãz3>Fwã´÷Ð.ÜK{ð)z÷Ñ!|š>Àgè|–¾Äýà³ZІâsÚ ø‚6j3ð6®Ž¯kóð -ˆojø í\ü¥v¾¥m·µ›ñí|WÛƒïi/àûÚAü•ö þFû+~¤Æßjßát~¬À?êƒð½ÿ¢Â¿é~üL??×˸®âz!~¡/Æ/%˜àíPìi‡)*êñPÝ–ë*Vqì;8ÏœrÙœñ˜XŒL|wYg…%¶}þ û¨G›Ît9Êú œ„iû§î%)ÛÁyܘz„&%†´o £/Læ±'x²Îì’xh¿¬rÞt;du±¿^GùbĽúQ˜ª‹xŽ@oà’lÂ} iÇS˜Úâo@ËNÏ1¿O,÷ÈŽ†Ä¿xú¡wtwÊ;¦ÄóŽßsÖÁYÔwd?‰e­à(Ú%©k¦ú$ô;pWRÔ÷±#8ÞËŽJ }V^(— ÑP3y½™0[ÕV¦2V[ü7dâ×пø- g1ŽÆ#P‚G9ci‡™\ÏázqzF¨2˜!–éäÔYo‡Ö J³’êNyÍ)œ5ª­»ê 8¾ê²ö:\Ò*¹|\[xo,Ýú©Ê ã¹ÖÎØ›‹6…/?<íºV"Ž»$-ïË9rbv}ÂSHnÚNvC+ÌäêF¿Übr •ûŒà<Å£nƒÓò,ÕÞb¿zϽÌàXóžPô¦µÁM|i¢¯˜ÄÍ­ÐSåèL­ 6 únßÒnmƒ-‚þ·oí@ßÖ· úá"•ÅÐw´Á‚Þ\¤®‹â·š7íR­3{«.ïêrk¸äªÌY½[“Û-æÉwµÂn¹zOãr›ßPRѽgZã9NN¦d¶`]®žx·¸$Ç©×wå¸n…u^#‡)ßãw[{ýW‰éõ´b¤lÛ9"z9Œ]S’‘›!öèR‹Ø±0WÏ5s\[À”»ŸÁÄuMV±Âf[ªjðFväf•è—¹Úw´oÜw2·÷µÂy1¾ÇO{üNMøò:YS?ê`ÓC°ÀzÏô:sU;`‚Í—ÇN-r=v4ÏŽ¥÷_¦á›aÌÌõT]æbß¡vǹä%zNZÞ=ÐCYQNZ=RNÚ”p„{° m-AtgnÏÁÒV8ÄŠ\ÚùÓb&´3¦?fF)µF¹Tóaiz²ñ§KÖÞG†ïjƒGLÏ•ŹÏcþtE‡“ïÇKâɇEç ÁÅÅ|¿­fõ/û &lõXk[3E ¹QO®KÊ6x² Ú”]eÛ¯×çf—蹺ý°6(Wïn˹ºHýSÎn±ZÑ“ØcÍ3RÍ3vʨ½¢òƒÐKé]¿‹§rã)kª3ÕTçΘ1‰^51p5Ìd[qŠ­¸¬Æ½–Ñp™` }ãbÉE÷ºÅHö]æd‹hë~åN=qß;Ðß+Å,o¯ý®IN„éú!¹@ÓãRÓkÚv©µÚGªþF÷J­ÓoPõ!ýe5^ùh: 6s™e€I™Ð‹²` õ€Bê c©œH¹PB½a õéțPE›Ø__ Kwy!H}a5õƒµÔnäz åÁ½| ºÂ#äƒý4Ò`x—†À‡4þAÃà8eÒiz({Söçô)ŸŠðD*Æ…Sh4Φ°’Æà<‹‹ièD\N'á94/§‰x ùq3MÂ-4™S®“9½š‚û9ûNÅ?ÓTüŒ¦áW<ö[šNÍ 4šI&Í¢šM>*£*§ñtM£9ܪ¤%4—ꩊVÑéÔHÕ´ŽÇOóéJZ@×ÐBj¥Et-¦í<òqºŠvÓFÚO›èºš^aÜkt½MgÒ‡tý…–Òô#:BÍ eš‡ê´,ª×úRPF+´h¥6‘BÚtZ¥Í¡ÕÚ: kçÓí"jÐ.eøj:[»‘¢Ú-Ô¬m£m;]¥=@µÇh“ÖFWkÏ0î­ÕÑ:í5Z¯}Äýàþ¿rÿ?¹ÿ_Œû†6hítŽî¥«ô<Ú¨£Mz]­ŸÀ¸qt®>™ÎÓO¡óõ º@ŸOêgÑEz]¬¯¦KôóèRý*î»–®Ðoàù›yþ<ÿnžÿãv2îQÆíeÜ3Œ;Äðk ¿Ãð¯þýDÿ˜®UIä›0Ee†y‡å·»aê÷7• 霹9˜™œ•qÐÛ~\‘>ÁH'xO 8î‡Åô »þ‡`=Ðãp9·¯¤p= wÒ#p7í‚û¹ïaîÛÃõ~®Òð2=©ô1<ßÁ økìÐ„×ØÃ¼Û2c'á˜gØ´äŽNú›×ßN¾…ÈgBKxÝt•8þ+E:ºT¤úÉp‹J %?¿wäLÏÄr&õ³¢B=Ë(+Q²²$[÷æñõÛéȸ’ŽŒKôKl²/Ãû¼í÷áת¶ôº@îF´—õúŸ›§!ƒžá³ó,Ÿ›ýp=ÇçåÖë‹ ŸA#„»è%x”^fݽ/Ы¬»×àuzÞçú·\ÿ™Þ€OéM¥Ïéà> …ÖoŽ=²sŽÀ©ú·Ð» =bÒ}Ö‘ÔWã8õËã,œm÷4ÉþîIå’‡À¡=T¨~4߯?IŸRÑÛà¢wØbßU\i€.$ÿ˜Mh—ïú[;0¹Ÿ¾UÝÏÒû±ÁË¥MO ©¾M¢ÀI*r.õºŽÎS‘‰ž':Îæ.Ë61û²âè ¤>ТP†"Pslcm®Ò…›˜.;}"EŸrŠöר®LžYO_›R¼'|Fghî÷÷†ª¾Ç¸Ï:«íÓÕ7ã侕E‡ä%c?íM±/6ÏùUúi?B'¯òâ¶ÝÓoä%˜¶±¤˜vÌfCc^¤jKDÓôÐ9楱85„,Mƒ¾š5jŒÑœà×\0[3¡BK‡\ŸÁu–˵L%Ú2p¤…!œ®p|¨i‡"û#‘©‚Q1£=Š3×éq&ŽNú }ηE[ΰ¼þâmeTv˜ñ¼hÝ+3À‹…#óöÂÏtèP¿2l­ôÐrÀ§åÆLÀÇàB›n£äC;ŸE·ŸE÷`«º|2݃…ý÷Â!í²^&Û—EÔ/Fv [æ"¬µÉ®°Ã*¶ÈæYd_²^˜ìKŠÝ—uØUدÈï‚zöÏwñ®qª—¯ÚkeËžµ¼“×±:«õœ  šiptååã’n÷òb|/,£½ðÚ±{ÎôGð^ò;ö‚xži“=Ï&[h‘Q߸ˆ¶ØÏ {áu vuþNS+âFB¾V¬))Å ŽïO¸e•?ªÏ‰’?e=)-Sôêà]åü,²wþPK (_± &ùQPK03\1org/rosuda/REngine/JRI/JRIEngine$JRIPointer.class…TkOA=C·]ºly?ËC)-PA@E@#‚Òð² šbKa¡n›m‹Äßá~Ÿü`"˜#ßýþ£žÙCB63÷Þ3gîÜ3wÚï¿¿|0€A˜¡MyíA4 CM®ã†òº DЭ¨òbŠÜ££WÇM_®à ˆ„@ °iç; µÏdݸ›Í_Yñ䤳a;2žHN«QŠî‘=j;va\ +r1=‘ê^Ð&²¯¤À¥BsÅ7ëÒ]²Ö3DB‹+½=kå¼XG¿Žò×¶ceìw$ø"j¿1¹›–¹‚uòz.k;éz‹¬ÞXÌÝ´œ²UÂÊÓ£û¶¬ËD.›¨F³‰J\2qKMƒÒ1lâ6‹÷LŒbÌĸ"ÞW^šbé뤷pRŽq60§Gº+Ÿ—,ºJUÏXÎF|~}K¦ á‹’ ÔüÛµ´éfß–.ÍH®ÎÙ™e+SdPî:öl± wê϶Ceòpv¬ö<œ[óÖk9“Mo{7™âÌ\ÿ§IÊ“Öן¿"PÁ ®ÌKw‡‘I¨®ŠNÆËnp5)3ÒÊK„ùTC|¿eìPU¥zÄÈÇQ°^z_¡A§]ŠÆ ¢ŸQ ÀW§ía"|¿‡±pì4:ƒ´þC†ýtôð!Êëü{h-¡Á}ÔŽ`M£<=Ƨðùâ‘gËPǹåœ#ˆ'¬nšq‚Ìrç°€y,â)êÉh…ï·ùu˜:4Áߑޯ_qþÉ\šz?´JÉFízô|ªòYåpˆRýã%WI-¹º"ÂhÙCÛé¢R2K$ôé9â½TìØS¶×ÓÕ~OXkêT×°wçÏЈe2^“ÂVÈLQí U½$ϱFd•ß,~%­~¥µŒZOdVz2ÅM-ähìZ#í\=îßUž,hýJË:Â+$ài.¶zÅ]CœÖ jòÿªø PK)(Ljava/lang/Object;Ljava/lang/String;ZZ)VCodeLineNumberTable((Ljava/lang/Object;Ljava/lang/String;Z)V()V SourceFileRJavaTools_Test.java  RJavaTools_Test$ExampleClass ExampleClass InnerClassesjava/lang/ObjectRJavaTools_Test *·± *·±  *·±     rJava/inst/java/PrimitiveArrayException.java0000644000175100001440000000044515133274037020732 0ustar hornikusers/** * Generated when one tries to convert an arrays into * a primitive array of the wrong type */ public class PrimitiveArrayException extends Exception{ public PrimitiveArrayException(String type){ super( "cannot convert to single dimension array of primitive type" + type ) ; } } rJava/inst/java/ObjectArrayException.java0000644000175100001440000000040115133274037020160 0ustar hornikusers/** * Generated when one tries to access an array of primitive * values as an array of Objects */ public class ObjectArrayException extends Exception{ public ObjectArrayException(String type){ super( "array is of primitive type : " + type ) ; } } rJava/inst/java/RJavaTools_Test.java0000644000175100001440000006424215133274037017134 0ustar hornikusers // :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Constructor ; import java.lang.reflect.* ; import java.util.Map ; import java.util.Set ; import java.util.HashMap; public class RJavaTools_Test { private static class ExampleClass { public ExampleClass( Object o1, String o2, boolean o3, boolean o4){} public ExampleClass( Object o1, String o2, boolean o3){} public ExampleClass(){} } /* so that we can check about access to private fields and methods */ private int bogus = 0 ; private int getBogus(){ return bogus ; } private static int staticbogus ; private static int getStaticBogus(){ return staticbogus ; } public int x = 0 ; public static int static_x = 0; public int getX(){ return x ; } public static int getStaticX(){ return static_x ; } public void setX( Integer x ){ this.x = x.intValue(); } // {{{ main public static void main( String[] args){ try{ runtests() ; } catch( TestException e){ fails( e ) ; System.exit(1); } } public static void runtests() throws TestException { System.out.println( "Testing RJavaTools.getConstructor" ) ; constructors() ; success() ; System.out.println( "Testing RJavaTools.classHasField" ) ; classhasfield() ; success(); System.out.println( "Testing RJavaTools.classHasMethod" ) ; classhasmethod() ; success() ; System.out.println( "Testing RJavaTools.classHasClass" ) ; classhasclass() ; success(); System.out.println( "Testing RJavaTools.hasField" ) ; hasfield() ; success(); System.out.println( "Testing RJavaTools.hasClass" ) ; hasclass() ; success(); System.out.println( "Testing RJavaTools.getClass" ) ; getclass() ; success() ; System.out.println( "Testing RJavaTools.hasMethod" ) ; hasmethod() ; success() ; System.out.println( "Testing RJavaTools.isStatic" ) ; isstatic() ; success() ; System.out.println( "Testing RJavaTools.getCompletionName" ) ; getcompletionname() ; success(); System.out.println( "Testing RJavaTools.getFieldNames" ) ; getfieldnames() ; success() ; System.out.println( "Testing RJavaTools.getMethodNames" ) ; getmethodnames() ; success() ; System.out.println( "Testing RJavaTools.getStaticFields" ) ; getstaticfields() ; success() ; System.out.println( "Testing RJavaTools.getStaticMethods" ) ; getstaticmethods() ; success() ; System.out.println( "Testing RJavaTools.getStaticClasses" ) ; getstaticclasses() ; success() ; System.out.println( "Testing RJavaTools.invokeMethod" ) ; invokemethod() ; success() ; System.out.println( "Testing RJavaTools.getFieldTypeName" ) ; getfieldtypename(); success() ; System.out.println( "Testing RJavaTools.getMethod" ) ; System.out.println( "NOT YET AVAILABLE" ) ; System.out.println( "Testing RJavaTools.newInstance" ) ; System.out.println( "NOT YET AVAILABLE" ) ; } // }}} // {{{ fails private static void fails( TestException e ){ System.err.println( "\n" ) ; e.printStackTrace() ; System.err.println( "FAILED" ) ; } // }}} // {{{ success private static void success(){ System.out.println( "PASSED" ) ; } // }}} // {{{ @Test getFieldNames private static void getfieldnames() throws TestException{ String[] names; // {{{ getFieldNames(DummyPoint, false) -> c('x', 'y' ) System.out.print( " * getFieldNames(DummyPoint, false)" ) ; names = RJavaTools.getFieldNames( DummyPoint.class, false ) ; if( names.length != 2 ){ throw new TestException( "getFieldNames(DummyPoint, false).length != 2" ) ; } for( int i=0; i<2; i++){ if( !( "x".equals(names[i]) || "y".equals(names[i] ) ) ){ throw new TestException( "getFieldNames(DummyPoint, false).length != c('x','y') " ) ; } } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(Point, true ) --> character(0) System.out.print( " * getFieldNames(DummyPoint, true )" ) ; names = RJavaTools.getFieldNames( DummyPoint.class, true ) ; if( names.length != 0 ){ throw new TestException( "getFieldNames(DummyPoint, true ) != character(0)" ); } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(RJavaTools_Test, true ) --> static_x System.out.print( " * getFieldNames(RJavaTools_Test, true )" ) ; names = RJavaTools.getFieldNames( RJavaTools_Test.class, true ) ; if( names.length != 1 ){ throw new TestException( "getFieldNames(RJavaTools_Test, true ).length != 1" ); } if( ! "static_x".equals( names[0] ) ){ throw new TestException( "getFieldNames(RJavaTools_Test, true )[0] != 'static_x' " ); } System.out.println( " : ok " ) ; // }}} // {{{ getFieldNames(RJavaTools_Test, false ) --> c('x', 'static_x') System.out.print( " * getFieldNames(RJavaTools_Test, false )" ) ; names = RJavaTools.getFieldNames( RJavaTools_Test.class, false ) ; if( names.length != 2 ){ throw new TestException( "getFieldNames(RJavaTools_Test, false ).length != 2" ); } for( int i=0; i<2; i++){ if( ! ( "x".equals( names[i] ) || "static_x".equals(names[i]) ) ){ throw new TestException( "getFieldNames(RJavaTools_Test, false ) != c('x', 'static_x') " ); } } System.out.println( " : ok " ) ; // }}} } // }}} // {{{ @Test getMethodNames private static void getmethodnames() throws TestException{ String[] names ; String[] expected ; int cpt = 0; // {{{ getMethodNames(RJavaTools_Test, true) -> c('getStaticX()', 'main(', 'runtests' ) System.out.print( " * getMethodNames(RJavaTools_Test, true)" ) ; names = RJavaTools.getMethodNames( RJavaTools_Test.class, true ) ; if( names.length != 3 ){ throw new TestException( "getMethodNames(RJavaTools_Test, true).length != 3 (" + names.length + ")" ) ; } expected= new String[]{ "getStaticX()", "main(", "runtests()" }; cpt = 0; for( int i=0; i character(0) ) System.out.print( " * getMethodNames(Object, true)" ) ; names = RJavaTools.getMethodNames( Object.class, true ) ; if( names.length != 0 ){ throw new TestException( "getMethodNames(Object, true).length != 0 (" + names.length + ")" ) ; } System.out.println( " : ok " ) ; // }}} // {{{ getMethodNames(RJavaTools_Test, false) %contains% { "getX()", "getStaticX()", "setX(", "main(" } System.out.print( " * getMethodNames(RJavaTools_Test, false)" ) ; names = RJavaTools.getMethodNames( RJavaTools_Test.class, false ) ; cpt = 0; expected = new String[]{ "getX()", "getStaticX()", "setX(", "main(" }; for( int i=0; i false try{ System.out.print( " * isStatic(RJavaTools_Test.x)" ) ; f = RJavaTools_Test.class.getField("x") ; if( RJavaTools.isStatic( f) ){ throw new TestException( "isStatic(RJavaTools_Test.x) == true" ) ; } System.out.println( " = false : ok " ) ; } catch( NoSuchFieldException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.getX) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.getX() )" ) ; m = RJavaTools_Test.class.getMethod("getX", (Class[])null ) ; if( RJavaTools.isStatic( m ) ){ throw new TestException( "isStatic(RJavaTools_Test.getX() ) == false" ) ; } System.out.println( " = false : ok " ) ; } catch( NoSuchMethodException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.static_x) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.static_x)" ) ; f = RJavaTools_Test.class.getField("static_x") ; if( ! RJavaTools.isStatic( f) ){ throw new TestException( "isStatic(RJavaTools_Test.static_x) == false" ) ; } System.out.println( " = true : ok " ) ; } catch( NoSuchFieldException e){ throw new TestException( e.getMessage() ) ; } // }}} // {{{ isStatic(RJavaTools_Test.getStaticX) -> true try{ System.out.print( " * isStatic(RJavaTools_Test.getStaticX() )" ) ; m = RJavaTools_Test.class.getMethod("getStaticX", (Class[])null ) ; if( ! RJavaTools.isStatic( m ) ){ throw new TestException( "isStatic(RJavaTools_Test.getStaticX() ) == false" ) ; } System.out.println( " = true : ok " ) ; } catch( NoSuchMethodException e){ throw new TestException( e.getMessage() ) ; } // }}} /* classes */ // {{{ isStatic(RJavaTools_Test.TestException) -> true System.out.print( " * isStatic(RJavaTools_Test.TestException )" ) ; Class cl = RJavaTools_Test.TestException.class ; if( ! RJavaTools.isStatic( cl ) ){ throw new TestException( "isStatic(RJavaTools_Test.TestException) == false" ) ; } System.out.println( " = true : ok " ) ; // }}} // {{{ isStatic(RJavaTools_Test.DummyNonStaticClass) -> false System.out.print( " * isStatic(RJavaTools_Test.DummyNonStaticClass )" ) ; cl = RJavaTools_Test.DummyNonStaticClass.class ; if( RJavaTools.isStatic( cl ) ){ throw new TestException( "isStatic(RJavaTools_Test.DummyNonStaticClass) == true" ) ; } System.out.println( " = false : ok " ) ; // }}} } // }}} // {{{ @Test constructors private static void constructors() throws TestException { /* constructors */ Constructor cons ; boolean error ; // {{{ getConstructor( String, null ) System.out.print( " * getConstructor( String, null )" ) ; try{ cons = RJavaTools.getConstructor( String.class, (Class[])null, (boolean[])null ) ; } catch( Exception e ){ throw new TestException( "getConstructor( String, null )" ) ; } System.out.println( " : ok " ) ; // }}} // {{{ getConstructor( Integer, { String.class } ) System.out.print( " * getConstructor( Integer, { String.class } )" ) ; try{ cons = RJavaTools.getConstructor( Integer.class, new Class[]{ String.class }, new boolean[]{false} ) ; } catch( Exception e){ throw new TestException( "getConstructor( Integer, { String.class } )" ) ; } System.out.println( " : ok " ) ; // }}} // disabled for now // // {{{ getConstructor( JButton, { String.class, ImageIcon.class } ) // System.out.print( " * getConstructor( JButton, { String.class, ImageIcon.class } )" ) ; // try{ // cons = RJavaTools.getConstructor( JButton.class, // new Class[]{ String.class, ImageIcon.class }, // new boolean[]{ false, false} ) ; // } catch( Exception e){ // throw new TestException( "getConstructor( JButton, { String.class, ImageIcon.class } )" ) ; // } // System.out.println( " : ok " ) ; // // }}} // {{{ getConstructor( Integer, null ) -> exception error = false ; System.out.print( " * getConstructor( Integer, null )" ) ; try{ cons = RJavaTools.getConstructor( Integer.class, (Class[])null, (boolean[])null ) ; } catch( Exception e){ error = true ; } if( !error ){ throw new TestException( "getConstructor( Integer, null ) did not generate error" ) ; } System.out.println( " -> exception : ok " ) ; // }}} // disabled for now // // {{{ getConstructor( JButton, { String.class, JButton.class } ) -> exception // error = false ; // System.out.print( " * getConstructor( JButton, { String.class, JButton.class } )" ) ; // try{ // cons = RJavaTools.getConstructor( JButton.class, // new Class[]{ String.class, JButton.class }, // new boolean[]{ false, false } ) ; // } catch( Exception e){ // error = true ; // } // if( !error ){ // throw new TestException( "getConstructor( JButton, { String.class, JButton.class } ) did not generate error" ) ; // } // System.out.println( " -> exception : ok " ) ; // // }}} Object o1 = null ; Object o2 = null ; ExampleClass foo = new ExampleClass(o1,(String)o2,false) ; // {{{ getConstructor( ExampleClass, { null, null, false } error = false ; System.out.print( " * getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : " ) ; try{ cons = RJavaTools.getConstructor( ExampleClass.class, new Class[]{ Object.class, Object.class, Boolean.TYPE}, new boolean[]{ true, true, false} ); } catch(Exception e){ error = true ; e.printStackTrace() ; } if( error ){ throw new TestException( "getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : exception " ) ; } System.out.println( " ok" ) ; // }}} } // }}} // {{{ @Test methods private static void methods() throws TestException{ } // }}} // {{{ @Test hasfields private static void hasfield() throws TestException{ DummyPoint p = new DummyPoint() ; System.out.println( " java> DummyPoint p = new DummyPoint()" ) ; System.out.print( " * hasField( p, 'x' ) " ) ; if( !RJavaTools.hasField( p, "x" ) ){ throw new TestException( " hasField( DummyPoint, 'x' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasField( p, 'iiiiiiiiiiiii' ) " ) ; if( RJavaTools.hasField( p, "iiiiiiiiiiiii" ) ){ throw new TestException( " hasField( DummyPoint, 'iiiiiiiiiiiii' ) == true" ) ; } System.out.println( " false : ok" ) ; /* testing a private field */ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * testing a private field " ) ; if( RJavaTools.hasField( ob, "bogus" ) ){ throw new TestException( " hasField returned true on private field" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test hasmethod private static void hasmethod() throws TestException{ DummyPoint p = new DummyPoint() ; System.out.println( " java> DummyPoint p = new DummyPoint()" ) ; System.out.print( " * hasMethod( p, 'move' ) " ) ; if( !RJavaTools.hasMethod( p, "move" ) ){ throw new TestException( " hasField( DummyPoint, 'move' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasMethod( p, 'iiiiiiiiiiiii' ) " ) ; if( RJavaTools.hasMethod( p, "iiiiiiiiiiiii" ) ){ throw new TestException( " hasMethod( Point, 'iiiiiiiiiiiii' ) == true" ) ; } System.out.println( " false : ok" ) ; /* testing a private method */ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * testing a private method " ) ; if( RJavaTools.hasField( ob, "getBogus" ) ){ throw new TestException( " hasMethod returned true on private method" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test hasclass private static void hasclass() throws TestException{ RJavaTools_Test ob = new RJavaTools_Test(); System.out.print( " * hasClass( RJavaTools_Test, 'TestException' ) " ) ; if( ! RJavaTools.hasClass( ob, "TestException" ) ){ throw new TestException( " hasClass( RJavaTools_Test, 'TestException' ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) " ) ; if( ! RJavaTools.hasClass( ob, "DummyNonStaticClass" ) ){ throw new TestException( " hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) == false" ) ; } System.out.println( " true : ok" ) ; } // }}} // {{{ @Test hasclass private static void getclass() throws TestException{ Class cl ; System.out.print( " * getClass( RJavaTools_Test, 'TestException', true ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "TestException", true ); if( cl != RJavaTools_Test.TestException.class ){ throw new TestException( " getClass( RJavaTools_Test, 'TestException', true ) != TestException" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "DummyNonStaticClass", true ); if( cl != null ){ throw new TestException( " getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getClass( RJavaTools_Test, 'DummyNonStaticClass', false ) " ) ; cl = RJavaTools.getClass( RJavaTools_Test.class, "DummyNonStaticClass", false ); if( cl != RJavaTools_Test.DummyNonStaticClass.class ){ throw new TestException( " getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null" ) ; } System.out.println( " : ok" ) ; } // }}} // {{{ @Test classhasfield private static void classhasfield() throws TestException{ } // }}} // {{{ @Test classhasclass private static void classhasclass() throws TestException{ System.out.print( " * classHasClass( RJavaTools_Test, 'TestException', true ) " ) ; if( ! RJavaTools.classHasClass( RJavaTools_Test.class , "TestException", true ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'TestException', true ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) " ) ; if( RJavaTools.classHasClass( RJavaTools_Test.class , "DummyNonStaticClass", true ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) == true" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) " ) ; if( ! RJavaTools.classHasClass( RJavaTools_Test.class , "DummyNonStaticClass", false ) ){ throw new TestException( " classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) == false" ) ; } System.out.println( " true : ok" ) ; } // }}} // {{{ @Test classhasmethod private static void classhasmethod() throws TestException{ System.out.print( " * classHasMethod( RJavaTools_Test, 'getX', false ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getX", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getX', false ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticX', false ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticX", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getStaticX', false ) == false" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getX', true ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getX", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getX', true ) == true (non static method)" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticX', true ) " ) ; if( ! RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticX", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getStaticX', true ) == false (static)" ) ; } System.out.println( " true : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getBogus', false ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getBogus", false ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getBogus', false ) == true (private method)" ) ; } System.out.println( " false : ok" ) ; System.out.print( " * classHasMethod( RJavaTools_Test, 'getStaticBogus', true ) " ) ; if( RJavaTools.classHasMethod( RJavaTools_Test.class, "getStaticBogus", true ) ){ throw new TestException( " classHasMethod( RJavaTools_Test, 'getBogus', true ) == true (private method)" ) ; } System.out.println( " false : ok" ) ; } // }}} // {{{ @Test getstaticfields private static void getstaticfields() throws TestException{ Field[] f ; System.out.print( " * getStaticFields( RJavaTools_Test ) " ) ; f = RJavaTools.getStaticFields( RJavaTools_Test.class ) ; if( f.length != 1 ){ throw new TestException( " getStaticFields( RJavaTools_Test ).length != 1" ) ; } if( ! "static_x".equals( f[0].getName() ) ){ throw new TestException( " getStaticFields( RJavaTools_Test )[0] != 'static_x'" ) ; } System.out.println( " : ok" ) ; System.out.print( " * getStaticFields( Object ) " ) ; f = RJavaTools.getStaticFields( Object.class ) ; if( f != null ){ throw new TestException( " getStaticFields( Object ) != null" ) ; } System.out.println( " : ok" ) ; } // }}} // {{{ @Test getstaticmethods private static void getstaticmethods() throws TestException{ Method[] m ; // {{{ getStaticMethods( RJavaTools_Test ) System.out.print( " * getStaticMethods( RJavaTools_Test ) " ) ; m = RJavaTools.getStaticMethods( RJavaTools_Test.class ) ; String[] expected = new String[]{ "getStaticX" , "main", "runtests" }; int count = 0; if( m.length != expected.length ){ throw new TestException( " getStaticMethods( RJavaTools_Test ).length != 2" ) ; } for( int i=0; i()VCodeLineNumberTable(II)VgetX()Dmoveclone()Ljava/lang/Object; SourceFileDummyPoint.java    DummyPointjava/lang/Objectjava/lang/Cloneable!    #*·±   3*·*µ*µ±   *´‡¯  5*Y´`µ*Y´`µ±  (»Y*´*´·°rJava/inst/java/RJavaImport.class0000644000175100001440000000656415133274037016476 0ustar hornikusersÊþº¾2° 3W 1XY W 1Z[ W 1\ 1] 1^ _`a Wb cdef Dg h Ei jk jlm Dno jp qr st uvwx y 1z{ | } 1~ j Oq O€ O‚ Rƒ R„… 1†‡ˆDEBUGZimportedPackagesLjava/util/Vector;cacheLjava/util/Map;loaderLjava/lang/ClassLoader;(Ljava/lang/ClassLoader;)VCodeLineNumberTablelookup%(Ljava/lang/String;)Ljava/lang/Class; StackMapTable‰Šlookup_exists(Ljava/lang/String;)Zexists_ importPackage(Ljava/lang/String;)V([Ljava/lang/String;)VgetKnownClasses()[Ljava/lang/String;‹Œ4(Ljava/lang/String;Ljava/util/Set;)Ljava/lang/Class;()V SourceFileRJavaImport.java =T ;<java/util/Vector 78java/util/HashMap 9: FB 56Ž java/lang/StringBuilder [J] lookup( ' ‘’' ) =  ' “” •” –K— ˜™ š›java/lang/String œBjava/lang/Exception ž Ÿ  [J] ‘¡ packages š¢. [J] trying class :  [JE] £” IH [J] exists( ' ‘¤ ¥™ JK ¦§ ¨©! [J] getKnownClasses().length = ª« ¬­ ®¯ RJavaImport ABjava/lang/Objectjava/io/Serializablejava/lang/Classjava/io/PrintStream java/util/Set[Ljava/lang/String;java/util/Iteratorjava/lang/SystemoutLjava/io/PrintStream;append-(Ljava/lang/String;)Ljava/lang/StringBuilder;getName()Ljava/lang/String;toStringprintln java/util/Map containsKey(Ljava/lang/Object;)Zget&(Ljava/lang/Object;)Ljava/lang/Object;forNameput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;size()I(I)Ljava/lang/StringBuilder;(I)Ljava/lang/Object; getMessage(Z)Ljava/lang/StringBuilder;addkeySet()Ljava/util/Set;toArray(([Ljava/lang/Object;)[Ljava/lang/Object;iterator()Ljava/util/Iterator;hasNext()Znext()Ljava/lang/Object;!134 56789:;< =>?H *·*+µ*»Y·µ*»Y·µ±@23 456AB?«S*+· M² ™H² » Y· ¶+¶¶,ǧ» Y· ¶,¶¶¶¶¶¶¶,°@@AQBC2ÿ-1DE ÿ1DE FB?óM*´+¹™*´+¹ÀN-¸:°N+¸M§N,Æ*´++¹W,°*´¶>² ™!² » Y· ¶¶¶¶¶ž6¢”*´¶ À:» Y· ¶!¶+¶¶:² ™² » Y· "¶¶¶¶¸M§(:² ™ ² » Y· #¶¶$¶¶¶,Æ*´+,¶¹W,°„§ÿl°%&',/{ÉÌ@nFHJK#L&M'T,U0V4W@XB[J\n]r^{`‰a£bÃcÉfÌdÎeñgõhi^ mCG ÿ&1DGü+üýMÿ1D$úGH?\0*+¶%=² ™%² » Y· &¶+¶¶¶'¶¶¬@tu.vCü.IH?E*´+¹™¬*+· Ƨ¬@ z|C @JK?& *´+¶(W±@ … †JL?I=+¾¢*+2¶)„§ÿð±@ŽŽ‘C üúMN?~@*´¹*L+¹+=½N+-¹,W² ™² » Y· -¶-¾¶¶¶-°@˜ ™š›œ>C þ>OP AQ?-+¹.N-¹/™-¹0À1:*¶2M,Æ,°§ÿß°@¢£¤¥"¦(§+¨C-ýRÿ ODRÿORST?³ ±@UVrJava/inst/java/RJavaArrayTools_Test.class0000644000175100001440000005613215133274037020316 0ustar hornikusersÊþº¾2T ‚› œž Ÿ  ¡¢ £ œ¤¥ ¦ §¨ ©ª «¬ ­® ¯° ±² ³´ µ œ¶· ¸¹º» Ÿ¼ ½¾¿ ÀÁ ½ÃÄÅ ½ÆÇÈ ½ÉÊË ½ÌÍÎÏÐ ½ÑÒÓ ½ÔÕÖ× ½ØÙÚÛÜÝÞßàáâ ½ãäåæçèéêëìíîïðñòóôõö@$™™™™™š ÷øùúûü ½ýþÿ ½ ½ ½  ½    ½ ½ ½ !"#$%&'()*+,-./0123456789 ½:;< ½=>? ½@AB ½CDE ½FGHIJ ½KLM ½NOPQR ½STUVWXYZ[\]^_ ½`ab ½cde ½fgh ½ijk ½lmnop ½qrs ½tuvwxy ½z{| ½}~ ½€‚ ½ƒ„… ½†‡ˆ‰Š ½‹Œ ½Ž ½‘’“”•–—˜™š›œžŸ  ½¡¢ –£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàá ½âãä ½åæç ½èéê ½ëìí ½îïðñò ½óôõ ½ö÷øùúû ½üýþÿ      t ½ t@$()VCodeLineNumberTablemain([Ljava/lang/String;)V StackMapTableruntests Exceptionsfails(LTestException;)Vsuccessisarray getdimlengthgetdims gettruelengthisrect gettypenameisprimrep SourceFileRJavaArrayTools_Test.java ƒ„  !Test suite for RJavaArrayTools" #$ Š„ TestException Œ %&Testing RJavaArrayTools.isArray „ Ž„*Testing RJavaArrayTools.isRectangularArray “„*Testing RJavaArrayTools.getDimensionLength „%Testing RJavaArrayTools.getDimensions ‘„%Testing RJavaArrayTools.getTrueLength ’„)Testing RJavaArrayTools.getObjectTypeName •„+Testing RJavaArrayTools.isPrimitiveTypeName —„Testing RJavaTools.rep ˜„ '! („FAILEDPASSED isArray( int ) )$* +, isArray( int ) ƒ$ false : ok isArray( boolean ) +- isArray( boolean )  isArray( byte ) +. isArray( byte )  isArray( long ) +/ isArray( long )  isArray( short ) +0 isArray( short )  isArray( double ) isArray( double )  isArray( char ) +1 isArray( char )  isArray( float ) +2 isArray( float )  isArray( String )dd +3 isArray( String )  isArray( int[] ) !isArray( int[] )  true : ok/ isArray( double[] (but declared as 0bject) )' !isArray( Object o = new double[2]; )  isArray( null ) isArray( null)  >> actual arrays int[] o = new int[10] ; 45"getDimensionLength( int[10] ) != 1NotAnArrayExceptionnot an array int[10] 1 : ok  int[] o = new int[0] ;!getDimensionLength( int[0] ) != 1not an array int[0][[Ljava/lang/Object; new Object[10][10]-getDimensionLength( new Object[10][10] ) != 2not an array Object[10][10] 2 : ok [[[Ljava/lang/Object; new Object[10][10][10]0getDimensionLength( new Object[10][10][3] ) != 3not an array Object[10][10][3] 3 : ok  >> Object new Double('10.2') 6 782getDimensionLength(Double) did not throw exception -> NotAnArrayException : ok  >> Testing primitive types getDimensionLength( int ) 491 getDimensionLength( int ) not throwing exception ok getDimensionLength( boolean ) 4:5 getDimensionLength( boolean ) not throwing exception : ok getDimensionLength( byte ) 4;2 getDimensionLength( byte ) not throwing exception getDimensionLength( long ) 4<2 getDimensionLength( long ) not throwing exception getDimensionLength( short ) 4=3 getDimensionLength( short ) not throwing exception : ok getDimensionLength( double )4 getDimensionLength( double ) not throwing exception getDimensionLength( char ) 4>3 getDimensionLength( char ) not throwing exception  getDimensionLength( float ) 4?4 getDimensionLength( float ) not throwing exception  getDimensionLength( null )java/lang/NullPointerException;getDimensionLength( null ) throwing wrong kind of exception3 getDimensionLength( null ) not throwing exception @A#getDimensions( int[10]).length != 1 getDimensions( int[10])[0] != 10 c( 10 ) : ok +getDimensions( Object[10][10] ).length != 2(getDimensions( Object[10][10] )[0] != 10(getDimensions( Object[10][10] )[1] != 10 c(10,10) : ok /getDimensions( Object[10][10][10] ).length != 3,getDimensions( Object[10][10][10] )[0] != 10,getDimensions( Object[10][10][10] )[1] != 10not an array Object[10][10][10] c(10,10,10) : ok  >> zeroes "getDimensions( int[0]).length != 1getDimensions( int[0])[0] != 0 c(0) : ok  new Object[10][10][0].getDimensions( Object[10][10][0] ).length != 3+getDimensions( Object[10][10][0] )[0] != 10+getDimensions( Object[10][10][0] )[1] != 10*getDimensions( Object[10][10][0] )[1] != 0not an array Object[10][10][0] c(10,10,0) : ok  new Object[10][0][10]-getDimensions( Object[10][0][0] ).length != 3*getDimensions( Object[10][0][0] )[0] != 10)getDimensions( Object[10][0][0] )[1] != 0not an array Object[10][0][10] c(10,0,0) : ok -getDimensions(Double) did not throw exception getDimensions( int ) @B, getDimensions( int ) not throwing exception getDimensions( boolean ) @C0 getDimensions( boolean ) not throwing exception getDimensions( byte ) @D- getDimensions( byte ) not throwing exception getDimensions( long ) @E- getDimensions( long ) not throwing exception getDimensions( short ) @F. getDimensions( short ) not throwing exception getDimensions( double )/ getDimensions( double ) not throwing exception getDimensions( char ) @G. getDimensions( char ) not throwing exception  getDimensions( float ) @H/ getDimensions( float ) not throwing exception  getDimensions( null )6getDimensions( null ) throwing wrong kind of exception. getDimensions( null ) not throwing exception I5getTrueLength( int[10]) != 10 10 : ok &getTrueLength( Object[10][10] ) != 100 100 : ok +getTrueLength( Object[10][10][10] ) != 1000 1000 : ok getTrueLength( int[0]) != 0'getTrueLength( Object[10][10][0] ) != 0 0 : ok &getTrueLength( Object[10][0][0] ) != 0-getTrueLength(Double) did not throw exception getTrueLength( int ) I9, getTrueLength( int ) not throwing exception getTrueLength( boolean ) I:0 getTrueLength( boolean ) not throwing exception getTrueLength( byte ) I;- getTrueLength( byte ) not throwing exception getTrueLength( long ) I<- getTrueLength( long ) not throwing exception getTrueLength( short ) I=. getTrueLength( short ) not throwing exception getTrueLength( double )/ getTrueLength( double ) not throwing exception getTrueLength( char ) I>. getTrueLength( char ) not throwing exception  getTrueLength( float ) I?/ getTrueLength( float ) not throwing exception  getTrueLength( null )6getTrueLength( null ) throwing wrong kind of exception. getTrueLength( null ) not throwing exception  isRectangularArray( int ) J, isRectangularArray( int )  isRectangularArray( boolean ) J- isRectangularArray( boolean )  isRectangularArray( byte ) J. isRectangularArray( byte )  isRectangularArray( long ) J/ isRectangularArray( long )  isRectangularArray( short ) J0 isRectangularArray( short )  isRectangularArray( double ) isRectangularArray( double )  isRectangularArray( char ) J1 isRectangularArray( char )  isRectangularArray( float ) J2 isRectangularArray( float )  isRectangularArray( String ) J3 isRectangularArray( String )  isRectangularArray( int[] ) !isRectangularArray( int[] ) : isRectangularArray( double[] (but declared as 0bject) )2 !isRectangularArray( Object o = new double[2]; )  isRectangularArray( null ) isRectangularArray( null) [[I$ isRectangularArray( new int[3][4] )& !isRectangularArray( new int[3][4] ) [I& isRectangularArray( new int[2][2,4] )( !isRectangularArray( new int[2][2,4] ) + isRectangularArray( new int[2][2][10,25] )- !isRectangularArray( new int[2][2][10,25] ) KLI M3 getObjectTypeName(int[]) != 'I'  I : ok  boolean[]Z$getObjectTypeName(boolean[]) != 'Z' not an array boolean[10] Z : ok  byte[]B!getObjectTypeName(byte[]) != 'B' not an array byte[10] B : ok  long[]J!getObjectTypeName(long[]) != 'J' not an array long[10] J : ok  short[]S"getObjectTypeName(short[]) != 'S' not an array short[10] S : ok  double[]D#getObjectTypeName(double[]) != 'D' not an array double[10] D : ok  char[]C!getObjectTypeName(char[]) != 'C' not an array char[10] C : ok  float[]F"getObjectTypeName(float[]) != 'F' not an array float[10] F : ok  >> multi dim primitive arrays int[][] ; boolean[][][[Z byte[][][[B long[][][[J short[][][[S double[][][[D char[][][[C float[][][[Fjava.lang.Object4getObjectTypeName(Object[][]) != 'java.lang.Object'  : ok >getObjectTypeName( Object[10][10][10] ) != 'java.lang.Object' !getObjectTypeName(int[0]) != 'I' =getObjectTypeName( Object[10][10][0] ) != 'java.lang.Object' 2 getObjectTypeName( char ) not throwing exception  getObjectTypeName( float ) K?3 getObjectTypeName( float ) not throwing exception  getObjectTypeName( null ):getObjectTypeName( null ) throwing wrong kind of exception2 getObjectTypeName( null ) not throwing exception  isPrimitiveTypeName( 'I' ) NOI not primitive true : ok  isPrimitiveTypeName( 'Z' ) Z not primitive isPrimitiveTypeName( 'B' ) B not primitive isPrimitiveTypeName( 'J' ) J not primitive isPrimitiveTypeName( 'S' ) S not primitive isPrimitiveTypeName( 'D' ) D not primitive isPrimitiveTypeName( 'C' ) C not primitive isPrimitiveTypeName( 'F' ) F not primitive+ isPrimitiveTypeName( 'java.lang.Object' ) Object primitive false : ok  DummyPoint ƒP rep( DummyPoint, 10) ˜Q [LDummyPoint;java/lang/Throwablerep(DummyPoint, 10) failed rep(DummyPoint, 10).length != 10 RS#rep(DummyPoint, 10)[5].getX() != 10: ok RJavaArrayTools_Testjava/lang/Object[[[Ijava/lang/Stringjava/lang/SystemoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vexit(I)VerrprintStackTraceprintRJavaArrayToolsisArray(I)Z(Z)Z(B)Z(J)Z(D)Z(C)Z(F)Z(Ljava/lang/Object;)ZgetDimensionLength(Ljava/lang/Object;)Ijava/lang/DoublevalueOf(D)Ljava/lang/Double;(I)I(Z)I(B)I(J)I(D)I(C)I(F)I getDimensions(Ljava/lang/Object;)[I(I)[I(Z)[I(B)[I(J)[I(D)[I(C)[I(F)[I getTrueLengthisRectangularArraygetObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;equalsisPrimitiveTypeName(Ljava/lang/String;)Z(II)V((Ljava/lang/Object;I)[Ljava/lang/Object;getX()D!‚ ƒ„…*·±† ‡ˆ…e²¶¸§ L+¸¸¸± †"    ‰N Š„…õy²¶² ¶¸ ¸ ² ¶¸ ¸ ²¶¸¸ ²¶¸¸ ²¶¸¸ ²¶¸¸ ²¶¸¸ ²¶¸¸ ±†j!$, /!2#:$=%@'H(K)N+V,Y-\/d0g1j3r4u5x7‹ Œ…9²¶*¶²¶±†<= >? Ž„…% ²¶±† DE „…•—²¶ ¸!™ »Y"·#¿²$¶²%¶ ¸&™ »Y'·#¿²$¶²(¶ ¸)™ »Y*·#¿²$¶²+¶ ¸,™ »Y-·#¿²$¶².¶ ¸/™ »Y0·#¿²$¶²1¶ ¸/™ »Y2·#¿²$¶²3¶ a¸4™ »Y5·#¿²$¶²6¶ ¸7™ »Y8·#¿²$¶²9¶ :¸;™ »Y<·#¿²$¶¼ K²=¶ *¸;š »Y>·#¿²?¶¼L²@¶ +¸;š »YA·#¿²?¶²B¶ ¸;™ »YC·#¿²$¶±†Î3LMNP!T)U0V:XB\J]Q^[`cdkerf|h„lŒm“np¥t­u´v¾xÆ|Î}Ö~à€è„ð…÷†ˆ ŒŽ#+”/•7–>—H™PTž\Ÿc m¢u¦}§„¨Žª–®‰  ! !ü$ü$‚ ‹ „…®òD¶ ¼ K²E¶ *¸FŸ »YG·#¿§L»YI·#¿²J¶¼ K²K¶ *¸FŸ »YL·#¿§L»YM·#¿²J¶  ÅNL²O¶ +¸FŸ »YP·#¿§M»YQ·#¿²R¶   ÅSM²T¶ ,¸FŸ »YU·#¿§N»YV·#¿²W¶²X¶²Y¶ >Z¸\¸FW§:>š »Y]·#¿²^¶²_¶²`¶ >¸aW§:>š »Yb·#¿²c¶²d¶ >¸eW§:>š »Yf·#¿²g¶²h¶ >¸iW§:>š »Yj·#¿²g¶²k¶ > ¸lW§:>š »Ym·#¿²c¶²n¶ >¸oW§:>š »Yp·#¿²q¶²r¶ >¸oW§:>š »Ys·#¿²g¶²t¶ >a¸uW§:>š »Yv·#¿²g¶²w¶ > ¸xW§:>š »Yy·#¿²g¶²z¶ >¸FW§:>§:»Y|·#¿š »Y}·#¿²g¶±'*HI[^H‚”—H½ÏÒH÷H058H\adHˆH´¹¼HàåèH H8>AHejmH‘–™{‘– H†âx´· ¸º»'¿*½+¾5À=ÄAÅIÇQÈ[Ì^Ê_ËiÍqÑz҂ԊՔٗטآڪ޵߽áÅâÏæÒäÓåÝçåëííõî÷ðóñòô õ÷û&þ.ÿ058:<JR Z \ adfhv~†ˆ’”¢ª"²#´%¹(¼&¾'À)Î*Ö.Þ/à1å4è2ê3ì5ú6: ; =@>?A&B.F6G8I>LAJCKEMSN[RcSeUjXmVoWqYZ‡`a‘c–h™d›eh f¢g¬iºjÂm‰y+ü'BH %BH ü*NBH ü,SBH ÿ&NSH aH YH YH YH YH YH ZH YH Y{FH ‹ ‘„…-OK ¼ L²E¶ +¸~K*¾Ÿ »Y·#¿*. Ÿ »Y€·#¿§M»YI·#¿²¶  ÅNM²O¶ ,¸~K*¾Ÿ »Y‚·#¿*. Ÿ »Yƒ·#¿*. Ÿ »Y„·#¿§N»YQ·#¿²…¶   ÅSN²T¶ -¸~K*¾Ÿ »Y†·#¿*. Ÿ »Y‡·#¿*. Ÿ »Yˆ·#¿*. Ÿ »Yˆ·#¿§:»Y‰·#¿²ж²‹¶¼ L²K¶ +¸~K*¾Ÿ »YŒ·#¿*.™ »Y·#¿§:»YM·#¿²޶  ÅSN²¶ -¸~K*¾Ÿ »Y·#¿*. Ÿ »Y‘·#¿*. Ÿ »Y’·#¿*.™ »Y“·#¿§:»Y”·#¿²•¶  ÅSN²–¶ -¸~K*¾Ÿ »Y—·#¿*. Ÿ »Y˜·#¿*.™ »Y™·#¿*.™ »Y™·#¿§:»Yš·#¿²›¶²X¶²Y¶ 6Z¸\¸~K§:6š »Yœ·#¿²^¶²_¶²¶ 6¸žW§:6š »YŸ·#¿²c¶² ¶ 6¸¡W§:6š »Y¢·#¿²g¶²£¶ 6¸¤W§:6š »Y¥·#¿²g¶²¦¶ 6 ¸§W§:6š »Y¨·#¿²c¶²©¶ 6¸ªW§:6š »Y«·#¿²q¶²¬¶ 6¸ªW§:6š »Y­·#¿²g¶²®¶ 6a¸¯W§:6š »Y°·#¿²g¶²±¶ 6 ¸²W§:6š »Y³·#¿²g¶²´¶ 6¸~W§:6§:»Yµ·#¿š »Y¶·#¿²g¶±69H]–™H¿  H5Z]HƒÌÏHõ<?HfpsH¢§ªHÑÖÙHH/47H^cfH’•H¼ÂÅHìñôH #{ +H†¦©rvwyz{$},~6‚9€:DƒL‡Uˆ]Šb‹hŒrŽz„‘Œ’––™”𕤗¬›·œ¿žÄŸÊ Ô¢Ü£æ¥î¦ø¨© ­ «¬®!³)¶-·5¹:º@»J½P¾ZÂ]À_ÁiÃqÇ{ȃʈˎ̘ΠϪѲҼÔÂÕÌÙÏ×ÑØÛÚãÞíßõáúâã åæè"é,ë2ì<ð?îAïKñS÷[ùcúfüpÿsýuþx}‡— Ÿ ¢ §ª¬¯¾ÆÎÑÖÙÛÞíõ"ý#%(& ' )*$.,//1447293<5K6S:[;^=c@f>h?kAzB‚FŠGI’L•J—KšM©N±R¹S¼UÂXÅVÇWÊYÙZá^é_ìañdôböcùeflmo t#p%q(t+r-s7uFvNz‰˜>ý$BH ü-NBH ü/SBH 0BH .BH .BH ÿ'NSHbHZHZHZHZHZH[HZHZ{GH ‹ ’„…Íh; ¼ L²E¶ +¸·; Ÿ »Y¸·#¿§M»YI·#¿²¹¶  ÅNM²O¶ ,¸·;dŸ »Yº·#¿§N»YQ·#¿²»¶   ÅSN²T¶ -¸·;èŸ »Y¼·#¿§:»Y‰·#¿²½¶²‹¶¼ L²K¶ +¸·;™ »Y¾·#¿§:»YM·#¿²޶  ÅSN²¶ -¸·;™ »Y¿·#¿§:»Y”·#¿²À¶  ÅSN²–¶ -¸·;™ »YÁ·#¿§:»Yš·#¿²À¶²X¶²Y¶ 6Z¸\¸·;§:6š »Y·#¿²^¶²_¶²ö 6¸ÄW§:6š »YÅ·#¿²c¶²ƶ 6¸ÇW§:6š »YÈ·#¿²g¶²ɶ 6¸ÊW§:6š »YË·#¿²g¶²̶ 6 ¸ÍW§:6š »Yη#¿²c¶²϶ 6¸ÐW§:6š »YÑ·#¿²q¶²Ò¶ 6¸ÐW§:6š »YÓ·#¿²g¶²Ô¶ 6a¸ÕW§:6š »YÖ·#¿²g¶²×¶ 6 ¸ØW§:6š »YÙ·#¿²g¶²Ú¶ 6¸·W§:6§:»YÛ·#¿š »YÜ·#¿²g¶±$'HK`cH‰Ÿ¢HÊÝàHHBUXH‰ŒH»ÀÃHêïòH!HHMPHw|H¦«®HÕÛÞH  H49<{49DH†>ƒ„†‡ˆ$Œ'Š(‹2:‘C’K”P•V–`šc˜d™n›vŸ ‰¢Ž£•¤Ÿ©¢§¤¨®ª¶¯¾²Â³ÊµÏ¶Ó·Ý»à¹âºì¼ôÀþÁà ÄÅÉÇÈ(Ê0Î:ÏBÑGÒKÓU×XÕZÖdØlÞtà|áã‰æŒäŽå‘ç–è ê¨ï°ò¸ó»õÀøÃöÅ÷Èù×úßþçÿêïòô÷   !#&5=EHMPRUdl"t#w%|(&'„)“*›.£/¦1«4®2°3³5Â6Ê:Ò;Õ=Û@Þ>à?ãAòBúFGI L JKM!N)T1U4W9\<X>YA\DZF[P]_^gb‰‡1ý$BH ü-NBH ü0SBH .BH ,BH ,BH ÿ'NSHbHZHZHZHZHZH[HZHZ{GH ‹ “„…—7²ݶ ¸Þ™ »Yß·#¿²$¶²à¶ ¸á™ »Yâ·#¿²$¶²ã¶ ¸ä™ »Yå·#¿²$¶²æ¶ ¸ç™ »Yè·#¿²$¶²é¶ ¸ê™ »Yë·#¿²$¶²ì¶ ¸ê™ »Yí·#¿²$¶²î¶ a¸ï™ »Yð·#¿²$¶²ñ¶ ¸ò™ »Yó·#¿²$¶²ô¶ :¸õ™ »Yö·#¿²$¶¼ K²÷¶ *¸õš »Yø·#¿²?¶¼L²ù¶ +¸õš »Yú·#¿²?¶²û¶ ¸õ™ »Yü·#¿²$¶ÅýM²þ¶ ,¸õš »Yÿ·#¿²?¶½N-¼ S-¼ S²¶ -¸õ™»Y·#¿²$¶½ý:½S2¼ S2¼ S²¶ ¸õ™»Y·#¿²$¶±†Gijkm!q)r0s:uByJzQ{[}ck‚rƒ|…„‰ŒŠ“‹¥‘­’´“¾•ƙΚ֛àè¡ð¢÷£¥ ©ª«#­+±/²7³>´H¶PºT»\¼c½m¿uÃ}ĄŎǖË̥ͬζоÔÃÕÉÖÏØØÙßÚêÜòàøáâ ãåæ#ç.é6ë‰* ! !ü$ü$‚ ü'ýü3ýüC”‹ •„… tP²E¶ ¼ ¸K*¶š»Y·#¿§L»YI·#¿² ¶² ¶ ¼¸K* ¶š»Y ·#¿§L»Y ·#¿²¶²¶ ¼¸K*¶š»Y·#¿§L»Y·#¿²¶²¶ ¼ ¸K*¶š»Y·#¿§L»Y·#¿²¶²¶ ¼ ¸K*¶š»Y·#¿§L»Y·#¿²¶²¶ ¼¸K*¶š»Y ·#¿§L»Y!·#¿²"¶²#¶ ¼¸K*$¶š»Y%·#¿§L»Y&·#¿²'¶²(¶ ¼¸K*)¶š»Y*·#¿§L»Y+·#¿²,¶²-¶².¶ Åý¸K*¶š»Y·#¿§L»YI·#¿² ¶²/¶ Å0¸K* ¶š»Y ·#¿§L»Y ·#¿²¶²1¶ Å2¸K*¶š»Y·#¿§L»Y·#¿²¶²3¶ Å4¸K*¶š»Y·#¿§L»Y·#¿²¶²5¶ Å6¸K*¶š»Y·#¿§L»Y·#¿²¶²7¶ Å8¸K*¶š»Y ·#¿§L»Y!·#¿²"¶²9¶ Å:¸K*$¶š»Y%·#¿§L»Y&·#¿²'¶²;¶ Å<¸K*)¶š»Y*·#¿§L»Y+·#¿²,¶  ÅNL²O¶ +¸K*=¶š»Y>·#¿§M»YQ·#¿²?¶   ÅSM²T¶ ,¸K*=¶š»Y@·#¿§N»Y‰·#¿²½¶²‹¶¼ N²K¶ -¸K*¶š»YA·#¿§:»YM·#¿²?¶  ÅSM²¶ ,¸K*=¶š»YB·#¿§:»Y”·#¿²?¶  ÅSM²–¶ ,¸K*=¶š»YC·#¿§:»Yš·#¿²À¶²X¶²Y¶ 6Z¸\¸K§:6š»YD·#¿²^¶²_¶²E¶ 6¸FW§:6š»YG·#¿²c¶²H¶ 6¸IW§:6š»YJ·#¿²g¶²K¶ 6¸LW§:6š»YM·#¿²g¶²N¶ 6 ¸OW§:6š»YP·#¿²c¶²Q¶ 6¸RW§:6š»YS·#¿²q¶²T¶ 6¸RW§:6š»YU·#¿²g¶²V¶ 6a¸WW§:6š»YX·#¿²g¶²Y¶ 6 ¸ZW§:6š»Y[·#¿²g¶²\¶ 6¸W§:6§:»Y]·#¿š»Y^·#¿²g¶± $'HD`cH H¾ÚÝHûH8TWHu‘”H²ÎÑHøH7VYHw–™H·ÖÙH÷H7VYHw–™H·ÖÙHÿHC]`H‡¡¤HËåèH),HS]`H‘–™HÂÇÊHóøûH$),HUZ]H†‹ŽH·½ÀHéîñH"{*H†ôö÷ø$ü'ú(û2ý;DKU` cdo xˆ’ ¡¬µ¾ÅÏÚ#Ý!Þ"é$ò(û*+ ,0./&1/587?8I9T=W;X<c>lBuD|E†F‘J”H•I K©O²Q¹RÃSÎWÑUÒVÝXæ[ï^ø`a bfde%g.k7mAnKoVsYqZretnxwz{‹|–€™~𥮅·‡ÁˆË‰ÖÙ‹ÚŒåŽî’÷”• –š˜™%›.Ÿ7¡A¢K£V§Y¥Z¦e¨n¬w®¯‹°–´™²š³¥µ®¹·»Á¼Ë½ÖÁÙ¿ÚÀåÂîÈ÷ÉÿËÌÍÑÏÐ'Ò0Ö;×CÙHÚRÛ]à`Þaßkásæ{éê‡ìŒí–î¡ò¤ð¦ñ°ó¹÷ÃøËúÐûÚüåèþêÿôý  ), . 8@HPS]`beju!}%…(Ž)‘+–.™,›-ž/®0¶4¿5Â7Ç:Ê8Ì9Ï;ß<ç@ðAóCøFûDýEGHL!M$O)R,P.Q1SATIXRYU[Z^]\_]b_r`zdƒe†g‹jŽhi“k£l«p´q·s½vÀtÂuÅwÕxÝ|æ}éî‚ñ€óöƒ„Š‹’"Ž$'’*,‘7“G”O˜‰ò^ü$–ÿHü –-BH -BH -BH -BH -BH -BH -BH 9BH 0BH 0BH 0BH 0BH 0BH 0BH 0BH ü3NBH ü5SBH ü5BH 4BH 4BH ÿ'–NSHcH[H[H[H[H[H\H[H[{GH ‹ —„…¬W²_¶ ¸`š»Ya·#¿²b¶²c¶  ¸`š»Yd·#¿²b¶²e¶ ¸`š»Yf·#¿²b¶²g¶ ¸`š»Yh·#¿²b¶²i¶ ¸`š»Yj·#¿²b¶²k¶ ¸`š»Yl·#¿²b¶²m¶ $¸`š»Yn·#¿²b¶²o¶ )¸`š»Yp·#¿²b¶²q¶ =¸`™»Yr·#¿²s¶±†2 ž&ŸL r¡˜¢¾£ä¤ ¥0§9¨M©Vª‰ %%%%%%%%‹ ˜„…Ïd»tY  ·uKL²v¶ * ¸wÀxL§M»Yz·#¿+¾ Ÿ»Y{·#¿+2¶|}—™»Y·#¿²€¶±!$y†6 ¯ ±²´!·$µ%¶0¸7¹B»O¼Z¾cÀ‰ÿ$txy ‹™šrJava/inst/java/RJavaTools.class0000644000175100001440000002344715133274037016323 0ustar hornikusersÊþº¾2C dª « ¬ c­ ® c¯° ª ± ²³ ´ µ¶ · c¸¹ º» c¼½ c¾ ¿¬ ÀÁÂà ª ÄÅ Æ ¿µ dÇ cÈ cÉ ¬ µ ¬ µ cÊ cË ‹Ì ‹ÍÎ ‹ÏÐ .Ñ cÒ cÓ Ì Í ÔÕ Ö× Ø ‹À cÙ Ú cÛÜ 7Ý Þß d® àß áß âß ãß äß åß æ cçè cé êëìí î ï ðñòóôõö÷ø ùú [Ýû [ü [Æ ý þÿ()VCodeLineNumberTablegetClass7(Ljava/lang/Class;Ljava/lang/String;Z)Ljava/lang/Class; StackMapTablegetStaticClasses%(Ljava/lang/Class;)[Ljava/lang/Class;isStatic(Ljava/lang/Class;)ZgetStaticFields-(Ljava/lang/Class;)[Ljava/lang/reflect/Field;getStaticMethods.(Ljava/lang/Class;)[Ljava/lang/reflect/Method; getFieldNames'(Ljava/lang/Class;Z)[Ljava/lang/String;getMethodNamesgetMemberNames1([Ljava/lang/reflect/Member;Z)[Ljava/lang/String;getCompletionName.(Ljava/lang/reflect/Member;)Ljava/lang/String;(Ljava/lang/reflect/Member;)ZhasField'(Ljava/lang/Object;Ljava/lang/String;)ZhasClass classHasField'(Ljava/lang/Class;Ljava/lang/String;Z)ZclassHasMethod classHasClass hasMethod newInstanceJ(Ljava/lang/Class;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object; Exceptions arg_is_null([Ljava/lang/Object;)[Z invokeMethodn(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;getConstructorF(Ljava/lang/Class;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Constructor;  isPrimitive getMethodS(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Method;isMoreSpecific7(Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;)ZA(Ljava/lang/reflect/Constructor;Ljava/lang/reflect/Constructor;)Z'([Ljava/lang/Class;[Ljava/lang/Class;)Z getClasses&(Ljava/lang/Object;)[Ljava/lang/Class; getClassNames'(Ljava/lang/Object;)[Ljava/lang/String;getSimpleClassNames((Ljava/lang/Object;Z)[Ljava/lang/String;getSimpleClassName&(Ljava/lang/Object;)Ljava/lang/String; getSimpleName&(Ljava/lang/String;)Ljava/lang/String;getFieldTypeName7(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String; SourceFileRJavaTools.java ef œ   ¤¥   nojava/util/Vector  java/lang/Class  java/lang/reflect/Modifier  n~java/lang/reflect/Field java/lang/reflect/Method yzjava/lang/String |}  )java/lang/StringBuilder (  i ‚ƒ …ƒ „ƒ ‘’  !"java/lang/Throwable ‡#+java/lang/reflect/InvocationTargetException $% Ž –— &'[Ljava/lang/Class; ‘(java/lang/NoSuchMethodException )* •o +o ˜š,No constructor matching the given parameters e,- ./012345 –6 ˜™+No suitable method for the given parameters ˜› 7 Exceptionerror condition 89 :; <=intdoublebooleanbytelongfloatshortchar <>java/lang/StringBuffer[] ? @A Bjava/lang/NoSuchFieldException RJavaToolsjava/lang/Object[Ljava/lang/reflect/Field;java/lang/reflect/Method;[Ljava/lang/String;[Z[Ljava/lang/Object;java/lang/reflect/Constructor [Ljava/lang/reflect/Constructor;java/lang/SecurityException()[Ljava/lang/Class;getName()Ljava/lang/String;equals(Ljava/lang/Object;)Zaddsize()ItoArray(([Ljava/lang/Object;)[Ljava/lang/Object; getModifiers getFields()[Ljava/lang/reflect/Field; getMethods()[Ljava/lang/reflect/Method;java/lang/reflect/MembergetParameterTypesappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString()Ljava/lang/Class; isAccessible()Z setAccessible(Z)V'([Ljava/lang/Object;)Ljava/lang/Object;getTargetException()Ljava/lang/Throwable;invoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;3([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;getConstructors"()[Ljava/lang/reflect/Constructor;isAssignableFrom(Ljava/lang/String;)Vjava/lang/BooleanTYPELjava/lang/Class;java/lang/Integerjava/lang/Doublejava/lang/Floatjava/lang/Longjava/lang/Shortjava/lang/Character@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method; getSuperclass lastIndexOf(I)IcharAt(I)C substring(II)Ljava/lang/String;(I)Ljava/lang/String;,(Ljava/lang/String;)Ljava/lang/StringBuffer;getField-(Ljava/lang/String;)Ljava/lang/reflect/Field;getType!cd efg*·±h$ ijg{;*¶N6-¾¢--2¶¸+¶™™ -2¸™-2°„§ÿÒ°h./0.13/94ký5%ú lmg½V*¶L+ǰ»Y·M+¾>6¢+2:¸™ ,¶ W„§ÿâ,¶ š°,¶ ½ :,¶ W°h:?@ BCDE%F-G4D:JAKCMLNSOkü 5þ ú nog3*¶ ~™§¬hYk@ pqgÂW*¶L+¾š°»Y·M+¾>6¢+2:¸™ ,¶ W„§ÿâ,¶ š°,¶ ½:,¶ W°h>cd e ghi j&k.l5i;oBpDrMsTtkü rþ ú stgÂW*¶L»Y·M+¾š°+¾>6¢+2:¸™ ,¶ W„§ÿâ,¶ š°,¶ ½:,¶ W°h>~ €ƒ„ …&†.‡5„;ŠB‹DMŽTkýuýú vwg! *¶¸°h› xwg! *¶¸°h§ yzg„M*¾>š½°™T»Y·:6¢"*2:¸™¸¶ W„§ÿÞ¶ š½°¶ ½M,¶ W§"½M6¢,*2¸S„§ÿì,°hV«¬­ ®°±²$³*´2µ=²C¸K¹P»Y¼`½c¿hÀqÁ|À‚Äký{ýú úüú |}gH*Á™ *¹°*Á™3*À¶¾š§L»Y·*¹¶¶+¶¶°°hÔÕÖ(×EÙk A n~g5*¹ ~™§¬hãk@ €g" *¶!+¸"¬hñ €g" *¶!+¸#¬hÿ ‚ƒgx8*¶N6-¾¢*+-2¶$¶™™-2¶%~™¬„§ÿÕ¬h.06kýr%ú „ƒgx8*¶N6-¾¢*+-2¶&¶™™-2¶'~™¬„§ÿÕ¬h#$%.&0$6'kýu%ú …ƒgx8*¶N6-¾¢*+-2¶¸¶™™ -2¸™¬„§ÿÕ¬h678.9076:ký5%ú †€g" *¶!+¸(¬hH ‡ˆg† z+¾¼N6+¾¢-+2ǧT„§ÿæ*,-¸):¶*6š¶+§:6+¶-:š&¶+§:¶/¿:š ¶+¿°9?B,GO^.GOf^hfhRSTUT%X-[4\9^?aB_D`GfOkTl^g`ifkmltmwnk‚ ý‰ÿ Š5‰‰ÿ Š5‰‰úÿ Š5‰‹,V.G,þ ,ÿ Š5‰‹dŒ,Žg)*ǰ*¾¼L=*¾¢+*2ǧT„§ÿé+°hrs tu!t'wk2ý‰ÿЉ‰ÿЉ‰ú g" [*,-¸0¸1:¶26š¶3§:6+-¶4:š&¶3§:¶/¿: š ¶3 ¿°",'0?.'0G?IGhB „…‡Š"ˆ$‰'0”5•?A’G”N•U–X—kMÿ" dŠ5,W.G,þ ,ÿ dŠ5dŒ, ‘’gà Î*ǰN+Æ+¾š*À5¶6N-°*+¶6N-Æ-°§:N*¶8:6¾¢2:¶9:+¾¾Ÿ§b+¾66 6  ¢<, 3™+ 2¸:™%6 §%+ 2Æ 2+ 2¶;š 6 § „ §ÿà ™-Æ -¸<™N„§ÿ}-Ç »7Y=·>¿-°'+7hŽ#¨©«®¯°µ"¶&·(º+¸-½/¾5¿@ÀGÁNÂVÃYÄ]Å`ÆjÇqÉ{Ê~ËΗÏšÐÆ£ÕµÖ¸¿¾ÙÂÚÌÝkGü ‹ B7ý “ý ‹5þ úÿ 5‰‹“ú Œ”7•og‚L*²?¶@š?*²A¶@š5*²B¶@š+*²C¶@š!*²D¶@š*²E¶@š *²F¶@™§¬hãä,å@æKãkûF@ –—gô ä*ǰ,Æ,¾š *+À5¶G°*+,¶G:ư§::*¶:6¾¢“2:¶&+¶š§w¶:,¾¾Ÿ§e,¾6 6 6   ¢<- 3™, 2¸:™%6 §%, 2Æ 2, 2¶;š 6 § „ §ÿà ™Æ ¸H™:„§ÿkÇ »7YI·>¿°(,7hŽ#÷øûü!&),. 1 7 B IUX_gjnq{‚Œ’¨«®´#È$Ì Ò'×(á*kb üÿ 5‰7þ uüü5þ úÿ 5‰uúŒ”7 ˜™g0*¶M+¶N,-¸J¬h78 9 ˜šg0*¶9M+¶9N,-¸J¬hFG H ˜›g N*¾=>6¢9*2+2¥(*2+2¶;™ „ÿ§+2+2¶;™„„§ÿÇž§¬h* YZ[\]'^-_;`>[Dbkþ$ú@ œgu/»Y·L*¶!M,Æ+,¶ W,¶KM§ÿñ+¶ ½ N+-¶ W-°h"kl mnoq'r-sk ý   žŸgx2»Y·L*¶!M,Æ+,¶¶ W,¶KM§ÿî+¶ ½N+-¶ W-°h"|} ~€"‚*ƒ0„k ý    ¡gál=»Y·N*¶!:Æ*¶¸:L¶™=-¶ W¶K:§ÿ×™š -L¶ W-M¶ W-N¶ W-¶ ½:-¶ W°hFŽ ‘’“)”+–2—<™@šD›KRžY¡b¢i£kþ üú ¢£g# *¶!¶¸°h¨ ¤¥g°è*[¶O<›**[¶O`¶PL **[¶O`*;¶O¶QK§f*¶P=I  RK§TD  SK§HZ  TK§<B  UK§0J  VK§$F  WK§S  XK§ C YK*$¶O=› *`¶ZK*.¶O>› *`¶ZK›*»[Y*·\:6£]¶^W„§ÿï¶_°*°hŠ"¬­ ®¯2±8²>³D´JµP¶V·\¸b¹hºn»t¼z½€¾†¿ŒÀ’Á•ƜǠȨ˯̳Í»пÑÉÓÒÔÚÓàÖæØk&ü2ü úüüý[ù ¦§gfM*+¶`¶a¶M§NM,°bhåçëèêìkÿ b¨©rJava/inst/java/RJavaArrayTools$ArrayDimensionMismatchException.class0000644000175100001440000000122015133274037025561 0ustar hornikusersÊþº¾2(     (II)VCodeLineNumberTable SourceFileRJavaArrayTools.javajava/lang/StringBuilder dimension of indexer ( !" !#) too large for array (depth =) $% &'/RJavaArrayTools$ArrayDimensionMismatchExceptionArrayDimensionMismatchException InnerClassesjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;(Ljava/lang/String;)VRJavaArrayTools!  B&*»Y·¶¶¶¶¶¶· ± )%*   rJava/inst/java/TestException.java0000644000175100001440000000025315133274037016677 0ustar hornikusers/** * Generated as part of testing rjava internal java tools */ public class TestException extends Exception{ public TestException(String message){super(message);} } rJava/inst/java/DummyPoint.java0000644000175100001440000000055615133274037016214 0ustar hornikusers public class DummyPoint implements Cloneable { public int x; public int y ; public DummyPoint(){ this( 0, 0 ) ; } public DummyPoint( int x, int y){ this.x = x ; this.y = y ; } public double getX(){ return (double)x ; } public void move(int x, int y){ this.x += x ; this.y += y ; } public Object clone() { return new DummyPoint(x, y); } } rJava/inst/java/RectangularArrayExamples.class0000644000175100001440000001151015133274037021230 0ustar hornikusersÊþº¾2s OPQRSTUVWXY OZ [ \ ]^_ `abcdefghijkl()VCodeLineNumberTable#getIntDoubleRectangularArrayExample()[[I StackMapTable'getBooleanDoubleRectangularArrayExample()[[Z$getByteDoubleRectangularArrayExample()[[B$getLongDoubleRectangularArrayExample()[[J%getShortDoubleRectangularArrayExample()[[S&getDoubleDoubleRectangularArrayExample()[[D$getCharDoubleRectangularArrayExample()[[C%getFloatDoubleRectangularArrayExample()[[F&getStringDoubleRectangularArrayExample()[[Ljava/lang/String;*getDummyPointDoubleRectangularArrayExample()[[LDummyPoint;#getIntTripleRectangularArrayExample()[[[I'getBooleanTripleRectangularArrayExample()[[[Z$getByteTripleRectangularArrayExample()[[[B$getLongTripleRectangularArrayExample()[[[J%getShortTripleRectangularArrayExample()[[[S&getDoubleTripleRectangularArrayExample()[[[D$getCharTripleRectangularArrayExample()[[[C%getFloatTripleRectangularArrayExample()[[[F&getStringTripleRectangularArrayExample()[[[Ljava/lang/String;*getDummyPointTripleRectangularArrayExample()[[[LDummyPoint; SourceFileRectangularArrayExamples.java ![[I[[Z[[B[[J[[S[[D[[C[[F[[Ljava/lang/String;java/lang/StringBuilder mn mo pq[[LDummyPoint; DummyPoint r[[[I[[[Z[[[B[[[J[[[S[[[D[[[C[[[F[[[Ljava/lang/String;[[[LDummyPoint;RectangularArrayExamplesjava/lang/Objectappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;(II)V! !"*·±# $%"|.ÅK<=¢>¢*2O„„§ÿï„§ÿâ*°#"  & ,&þ üúú '("†5ÅK<=¢&>¢*2T„š§<§ÿè„§ÿÛ*°#" -3&þ ü@úú )*"}/ÅK<=¢ >¢*2‘T„„§ÿî„§ÿá*°#"!" #$%$'#-(&þ üúú +,"}/ÅK<=¢ >¢*2…P„„§ÿî„§ÿá*°#",- ./0/'.-3&þ üúú -."}/ÅK<=¢ >¢*2“V„„§ÿî„§ÿá*°#"78 9:;:'9->&þ üúú /0"1ÅK<=¢">¢*2‡cR„„§ÿì„§ÿß*°#"BC DEF E)D/I&þ üúú 12"}/ÅK<=¢ >¢*2’U„„§ÿî„§ÿá*°#"MN OPQP'O-T&þ üúú 34"1Å K<=¢">¢*2† bQ„„§ÿì„§ÿß*°#"XY Z[\ [)Z/_&þ  üúú 56"Ž@Å K<=¢1>¢$*2» Y·  ¶¶¶S„„§ÿÝ„§ÿÐ*°#"cd efg/f8e>j&þ  üú%ú 78"„6ÅK<=¢'>¢*2»Y·S„„§ÿç„§ÿÚ*°#"no pqr%q.p4u&þ üúú 9:"žAÅK<=¢1>¢$6¢*22O„„§ÿë„§ÿÝ„§ÿÐ*°#* {| }~!€*3~9}?„&þ üüúúú ;<"¨HÅK<=¢8>¢+6¢*22T„š§<§ÿä„§ÿÖ„§ÿÉ*°#* ˆ‰ Š‹Œ!*Œ:‹@ŠF‘&þ üü@úúú =>"ŸBÅK<=¢2>¢%6¢*22‘T„„§ÿê„§ÿÜ„§ÿÏ*°#* •– —˜™!š+™4˜:—@ž&þ üüúúú ?@"ŸBÅK<=¢2>¢%6¢*22…P„„§ÿê„§ÿÜ„§ÿÏ*°#* ¢£ ¤¥¦!§+¦4¥:¤@«&þ üüúúú AB"ŸBÅK<=¢2>¢%6¢*22“V„„§ÿê„§ÿÜ„§ÿÏ*°#* ¯° ±²³!´+³4²:±@¸&þ üüúúú CD"¡DÅK<=¢4>¢'6¢*22‡cR„„§ÿè„§ÿÚ„§ÿÍ*°#* ¼½ ¾¿À!Á-À6¿<¾BÅ&þ üüúúú EF"ŸBÅK<=¢2>¢%6¢*22’U„„§ÿê„§ÿÜ„§ÿÏ*°#* ÉÊ ËÌÍ!Î+Í4Ì:Ë@Ò&þ üüúúú GH"¡DÅK<=¢4>¢'6¢*22 †bQ„„§ÿè„§ÿÚ„§ÿÍ*°#* Ö× ØÙÚ!Û-Ú6Ù<ØBß&þ üüúúú IJ"°SÅK<=¢C>¢66¢'*22» Y·  ¶¶¶S„„§ÿÙ„§ÿË„§ÿ¾*°#* ãä åæç!è<çEæKåQì&þ üüú)úú KL"¦IÅK<=¢9>¢,6¢*22»Y·S„„§ÿã„§ÿÕ„§ÿÈ*°#* ðñ òóô!õ2ô;óAòGù&þ üüúúúMNrJava/inst/java/RJavaTools_Test$DummyNonStaticClass.class0000644000175100001440000000056515133274037023207 0ustar hornikusersÊþº¾2  this$0LRJavaTools_Test;(LRJavaTools_Test;)VCodeLineNumberTable SourceFileRJavaTools_Test.java  #RJavaTools_Test$DummyNonStaticClassDummyNonStaticClass InnerClassesjava/lang/Object()VRJavaTools_Test! " *+µ*·±    rJava/inst/java/RJavaTools_Test.class0000644000175100001440000004202715133274037017315 0ustar hornikusersÊþº¾2m \7 F8 F9 F: F; w< F=> F? @A @BC DE FF FGH FIJ FKL FMN FOP FQR FST FUV FWX FYZ F[\ F]^ F_` Fab Fcd Fef Fghij @kl mnop Dqr stu v Vwxyz{|}~€‚ƒ„ s…† O7‡ Oˆ O‰Š O‹ŒŽ‘’“”•–—˜ v™ sš›œ gžŸ ¡¢£ v¤¥¦§ rž¨©ª«¬­ s®¯°±²³´µ¶·¸ s¹º»¼½¾¿ sÀÁÂÃÄÅÆÇÈ –ÉÊ ËÌ mÍÎ :7ÏÐ sÑÒÓÔÕÖ× F7ØÙÚÛ sÜÝÞßà áâ sãäåæþçè séêëìíîï sðñòóôõö s÷øùúûüýþÿ  s   s    s ï7 1 1 \ s s!"#$DummyNonStaticClass InnerClasses TestException ExampleClassbogusI staticbogusxstatic_x()VCodeLineNumberTablegetBogus()IgetStaticBogusgetX getStaticXsetX(Ljava/lang/Integer;)Vmain([Ljava/lang/String;)V StackMapTableruntests Exceptionsfails"(LRJavaTools_Test$TestException;)Vsuccess getfieldnames%getmethodnamesgetcompletionname&'isstatic constructors(methodshasfield hasmethodhasclassgetclass classhasfield classhasclassclasshasmethodgetstaticfields)getstaticmethods*getstaticclasses invokemethod+,getfieldtypename SourceFileRJavaTools_Test.java      - RJavaTools_Test$TestException . /0 12!Testing RJavaTools.getConstructor3 45 !  Testing RJavaTools.classHasField (!Testing RJavaTools.classHasMethod * Testing RJavaTools.classHasClass )Testing RJavaTools.hasField $Testing RJavaTools.hasClass &Testing RJavaTools.getClass 'Testing RJavaTools.hasMethod %Testing RJavaTools.isStatic  $Testing RJavaTools.getCompletionName  Testing RJavaTools.getFieldNames !Testing RJavaTools.getMethodNames "Testing RJavaTools.getStaticFields +#Testing RJavaTools.getStaticMethods -#Testing RJavaTools.getStaticClasses /Testing RJavaTools.invokeMethod 0#Testing RJavaTools.getFieldTypeName 3Testing RJavaTools.getMethodNOT YET AVAILABLETesting RJavaTools.newInstance 62 7FAILEDPASSED& * getFieldNames(DummyPoint, false) 85 DummyPoint9 :;,getFieldNames(DummyPoint, false).length != 2 5 <=y6getFieldNames(DummyPoint, false).length != c('x','y')  : ok & * getFieldNames(DummyPoint, true )0getFieldNames(DummyPoint, true ) != character(0)+ * getFieldNames(RJavaTools_Test, true )RJavaTools_Test1getFieldNames(RJavaTools_Test, true ).length != 17getFieldNames(RJavaTools_Test, true )[0] != 'static_x' , * getFieldNames(RJavaTools_Test, false )2getFieldNames(RJavaTools_Test, false ).length != 2=getFieldNames(RJavaTools_Test, false ) != c('x', 'static_x') + * getMethodNames(RJavaTools_Test, true) >;java/lang/StringBuilder3getMethodNames(RJavaTools_Test, true).length != 3 ( ?@ ?A) BCjava/lang/String getStaticX()main( runtests()PgetMethodNames(RJavaTools_Test, true) != {'getStaticX()','main(', 'runtests()' }" * getMethodNames(Object, true)java/lang/Object*getMethodNames(Object, true).length != 0 (, * getMethodNames(RJavaTools_Test, false)getX()setX(HgetMethodNames(RJavaTools_Test, false) did not contain expected methods * * getCompletionName(RJavaTools_Test.x) DE FG,getCompletionName(RJavaTools_Test.x) != 'x'  == 'x' : ok java/lang/NoSuchFieldException HC1 * getCompletionName(RJavaTools_Test.static_x):getCompletionName(RJavaTools_Test.static_x) != 'static_x'  == 'static_x' : ok 0 * getCompletionName(RJavaTools_Test.getX() )[Ljava/lang/Class; IJ8getCompletionName(RJavaTools_Test.getX() ) != ''getX()'  == 'getX()' : ok java/lang/NoSuchMethodException9 * getCompletionName(RJavaTools_Test.setX( Integer ) )java/lang/Classjava/lang/Integer=getCompletionName(RJavaTools_Test.setX(Integer) ) != 'setX('  == 'setX(' : ok ! * isStatic(RJavaTools_Test.x) KL#isStatic(RJavaTools_Test.x) == true = false : ok ' * isStatic(RJavaTools_Test.getX() )*isStatic(RJavaTools_Test.getX() ) == false( * isStatic(RJavaTools_Test.static_x)+isStatic(RJavaTools_Test.static_x) == false = true : ok - * isStatic(RJavaTools_Test.getStaticX() )0isStatic(RJavaTools_Test.getStaticX() ) == false. * isStatic(RJavaTools_Test.TestException ) KM0isStatic(RJavaTools_Test.TestException) == false4 * isStatic(RJavaTools_Test.DummyNonStaticClass )#RJavaTools_Test$DummyNonStaticClass5isStatic(RJavaTools_Test.DummyNonStaticClass) == true$ * getConstructor( String, null )[Z NOjava/lang/ExceptiongetConstructor( String, null )1 * getConstructor( Integer, { String.class } )+getConstructor( Integer, { String.class } )% * getConstructor( Integer, null )6getConstructor( Integer, null ) did not generate error -> exception : ok RJavaTools_Test$ExampleClass PM * getConstructor( ExampleClass, {Object.class, Object.class, boolean}) : Q RSQgetConstructor( ExampleClass, {Object.class, Object.class, boolean}) : exception  ok) java> DummyPoint p = new DummyPoint() * hasField( p, 'x' ) TU% hasField( DummyPoint, 'x' ) == false true : ok% * hasField( p, 'iiiiiiiiiiiii' )  iiiiiiiiiiiii0 hasField( DummyPoint, 'iiiiiiiiiiiii' ) == true false : ok * testing a private field ( hasField returned true on private field * hasMethod( p, 'move' ) move VU( hasField( DummyPoint, 'move' ) == false& * hasMethod( p, 'iiiiiiiiiiiii' ) , hasMethod( Point, 'iiiiiiiiiiiii' ) == true * testing a private method * hasMethod returned true on private method3 * hasClass( RJavaTools_Test, 'TestException' ) WU6 hasClass( RJavaTools_Test, 'TestException' ) == false true : ok9 * hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) < hasClass( RJavaTools_Test, 'DummyNonStaticClass' ) == false9 * getClass( RJavaTools_Test, 'TestException', true ) XYD getClass( RJavaTools_Test, 'TestException', true ) != TestException : ok? * getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) A getClass( RJavaTools_Test, 'DummyNonStaticClass', true ) != null@ * getClass( RJavaTools_Test, 'DummyNonStaticClass', false ) > * classHasClass( RJavaTools_Test, 'TestException', true ) Z[A classHasClass( RJavaTools_Test, 'TestException', true ) == falseD * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) F classHasClass( RJavaTools_Test, 'DummyNonStaticClass', true ) == trueE * classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) H classHasClass( RJavaTools_Test, 'DummyNonStaticClass', false ) == false7 * classHasMethod( RJavaTools_Test, 'getX', false ) \[: classHasMethod( RJavaTools_Test, 'getX', false ) == false= * classHasMethod( RJavaTools_Test, 'getStaticX', false ) @ classHasMethod( RJavaTools_Test, 'getStaticX', false ) == false6 * classHasMethod( RJavaTools_Test, 'getX', true ) L classHasMethod( RJavaTools_Test, 'getX', true ) == true (non static method)< * classHasMethod( RJavaTools_Test, 'getStaticX', true ) H classHasMethod( RJavaTools_Test, 'getStaticX', true ) == false (static); * classHasMethod( RJavaTools_Test, 'getBogus', false ) N classHasMethod( RJavaTools_Test, 'getBogus', false ) == true (private method)@ * classHasMethod( RJavaTools_Test, 'getStaticBogus', true ) M classHasMethod( RJavaTools_Test, 'getBogus', true ) == true (private method)) * getStaticFields( RJavaTools_Test ) ]^/ getStaticFields( RJavaTools_Test ).length != 1 _C4 getStaticFields( RJavaTools_Test )[0] != 'static_x' * getStaticFields( Object ) " getStaticFields( Object ) != null* * getStaticMethods( RJavaTools_Test ) `a0 getStaticMethods( RJavaTools_Test ).length != 2M getStaticMethods( RJavaTools_Test ) != c('main', 'getStaticX', 'runtests' ) ! * getStaticMethods( Object ) # getStaticMethods( Object ) != null! * getStaticClasses( Object ) bc# getStaticClasses( Object ) != null* * getStaticClasses( RJavaTools_Test ) 0 getStaticClasses( RJavaTools_Test ).length != 1E getStaticClasses( RJavaTools_Test ) != RJavaTools_Test.TestException. * testing enforcing accessibility (bug# 128)java/util/HashMap de fg Xhiterator[Ljava/lang/Object; ijjava/lang/Throwable) : FAILED (expected for JDK-17 and above)% * getFieldTypeName( DummyPoint, x ) klint(getFieldTypeName( DummyPoint, x ) != int: ok[Ljava/lang/String;java/lang/reflect/Fieldjava/lang/reflect/Methodjava/lang/reflect/Constructor[Ljava/lang/reflect/Field;java/lang/reflect/Method; java/util/Map java/util/SetintValuejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)VerrprintStackTraceprint RJavaTools getFieldNames'(Ljava/lang/Class;Z)[Ljava/lang/String;equals(Ljava/lang/Object;)ZgetMethodNamesappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;getField-(Ljava/lang/String;)Ljava/lang/reflect/Field;getCompletionName.(Ljava/lang/reflect/Member;)Ljava/lang/String; getMessage getMethod@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;isStatic(Ljava/lang/reflect/Member;)Z(Ljava/lang/Class;)ZgetConstructorF(Ljava/lang/Class;[Ljava/lang/Class;[Z)Ljava/lang/reflect/Constructor;((Ljava/lang/Object;Ljava/lang/String;Z)Vjava/lang/BooleanTYPELjava/lang/Class;hasField'(Ljava/lang/Object;Ljava/lang/String;)Z hasMethodhasClassgetClass7(Ljava/lang/Class;Ljava/lang/String;Z)Ljava/lang/Class; classHasClass'(Ljava/lang/Class;Ljava/lang/String;Z)ZclassHasMethodgetStaticFields-(Ljava/lang/Class;)[Ljava/lang/reflect/Field;getNamegetStaticMethods.(Ljava/lang/Class;)[Ljava/lang/reflect/Method;getStaticClasses%(Ljava/lang/Class;)[Ljava/lang/Class;put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;entrySet()Ljava/util/Set;()Ljava/lang/Class; invokeMethodn(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;getFieldTypeName7(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/String;!F\   /*·*µ*µ±      *´¬     ²¬   *´¬    ²¬  ! *+¶µ±   Q¸§ L+¸ ¸ ± !%"# $&F  ²  ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸² ¶ ¸¸²  ¶ ¸!¸² "¶ ¸#¸² $¶ ¸%¸² &¶ ¸'¸² (¶ ¸)¸² *¶ ¸+¸² ,¶ ¸-¸² .¶ ¸/¸² 0¶ ² 1¶ ² 2¶ ² 1¶ ± â8)* +-./1$2'3*5265789@:C;F=N>Q?TA\B_CbEjFmGpIxJ{K~M†N‰OŒQ”R—SšU¢V¥W¨Y°Z³[¶]¾^Á_ÄaÌbÏcÒeÚfÝgàièjëkîmönþpqs  9²34¶ *¶5²36¶ ± yz {|  % ² 7¶ ± ‚  ½ ² 8¶9:¸;K*¾Ÿ »Y<·=¿<¢)>*2¶?š@*2¶?š »YA·=¿„§ÿز B¶ ² C¶9:¸;K*¾™ »YD·=¿² B¶ ² E¶9F¸;K*¾Ÿ »YG·=¿H*2¶?š »YI·=¿² B¶ ² J¶9F¸;K*¾Ÿ »YK·=¿<¢)>*2¶?šH*2¶?š »YL·=¿„§ÿز B¶ ± ~Š‹Œ&<‘FL”T˜\™cšh›rz¡‚¢‰£¤™¦¤§®©¶­¾®Å¯Ë°Õ²Ü³ò´ü²· º üü$ú%&&ü$ú  =Y=² M¶9F¸NK*¾Ÿ$»Y»OY·PQ¶R*¾¶ST¶R¶U·=¿½VYWSYXSYYSL=>*¾¢,6+¾¢*2+2¶?™ „§ „§ÿã„§ÿÔ+¾Ÿ»Y»OY·PZ¶R¶S¶U·=¿² B¶ ² [¶9\¸NK*¾™$»Y»OY·P]¶R*¾¶ST¶R¶U·=¿² B¶ ² ^¶9F¸NK=½VY_SYWSY`SYXSL>*¾¢,6+¾¢*2+2¶?™ „§ „§ÿã„§ÿÔ+¾Ÿ »Ya·=¿² B¶ ± –%ÁÄ ÅÆÇ8ÉLÊNËVÌ`ÍmÎpÏsÌyËӅԠ֨ڰ۷ܼÝÝßåãíäôåöæçè!é.ê1ë4è:ç@ïFðPòXö6þ8ÿüúú <ü3üúú  ² b¶9F>¶cK>*¸d¶?š »Ye·=¿² f¶ §N»Y-¶h·=¿² i¶9FH¶cKH*¸d¶?š »Yj·=¿² k¶ §N»Y-¶h·=¿² l¶9FmÀn¶oL_+¸d¶?š²3+¸d¶ »Yp·=¿² q¶ §N»Y-¶s·=¿² t¶9Fu½vYwS¶oL`+¸d¶?š²3+¸d¶ »Yx·=¿² y¶ §N»Y-¶s·=¿±.1g>log|¸»rÈ  r Ž#&. 12 >FNZdlop|„œ¦ °"¸%»#¼$È*Ð+á,í-÷.0 3 1 26= ü&ÿ gü %Jg ü3ÿ rü 8Jr    _5² z¶9F>¶cK*¸{™ »Y|·=¿² }¶ §M»Y,¶h·=¿² ~¶9FmÀn¶oL+¸{™ »Y·=¿² }¶ §M»Y,¶s·=¿² €¶9FH¶cK*¸{š »Y·=¿² ‚¶ §M»Y,¶h·=¿² ƒ¶9F„Àn¶oL+¸{š »Y…·=¿² ‚¶ §M»Y,¶s·=¿² †¶9M,¸‡š »Yˆ·=¿² ‚¶ ² ‰¶9ŠM,¸‡™ »Y‹·=¿² }¶ ±),g9firvŸ¢g¯Üßr ®+@ABC!E)H,F-G9MANMOTP^RfUiSjTvZ~[†\]—_Ÿb¢`£a¯g·hÃiÊjÔlÜoßmànìuôv÷wþxz~€",ƒ4…Dü!ÿ gü ü$ÿ rü  Jg $Jr üv# ! ýý² Œ¶9VÀnÀ¸ŽK§M»Y·=¿² B¶ ² ‘¶9w½vYVS¼YT¸ŽK§M»Y’·=¿² B¶ <² “¶9wÀnÀ¸ŽK§M<š »Y”·=¿² •¶ MN»–Y,-ÀV·—:<² ˜¶9–½vY\SY\SY²™S¼YTYTYT¸ŽK§ :<¶š™ »Y›·=¿² œ¶ ±4JMjx{±ÚÝ Ž#‘”’“$•,™4›JžMœNXŸ`°b±j³x¶{´|µ~·‚¸Œº”Ï–ИѧÓ©Ô±ÖÚÜÝÙßÚáÛæÝêÞôàüä: Yü "h ÿ"" ÿP"\\–  # ± ê $ ë‚»:Y·K² ž¶ ² Ÿ¶9*>¸ š »Y¡·=¿² ¢¶ ² £¶9*¤¸ ™ »Y¥·=¿² ¦¶ »FY·§L² ¨¶9+©¸ ™ »Yª·=¿² ¦¶ ± Bðñòó!ô+ö3ø;ùDúNüVÿ^foyü+:"ü*F % ë‚»:Y·K² ž¶ ² «¶9*¬¸­š »Y®·=¿² ¢¶ ² ¯¶9*¤¸­™ »Y°·=¿² ¦¶ »FY·§L² ±¶9+²¸ ™ »Y³·=¿² ¦¶ ± B !+3;DNV^foy!#ü+:"ü*F & šO»FY·§K² ´¶9*µ¸¶š »Y··=¿² ¸¶ ² ¹¶9*º¸¶š »Y»·=¿² ¸¶ ± * )+,-#/+132<3F5N7 ü#F" ' Þz² ¼¶9Fµ¸½K*¥ »Y¾·=¿² ¿¶ ² À¶9Fº¸½K*Æ »YÁ·=¿² ¿¶ ² ¶9Fº¸½K*Š¥ »YÁ·=¿² ¿¶ ± B>?@A!C)E1F:G>HHJPLXMaNgOqQyS ü!v&( ( ± Y ) Ãp² ö9Fµ¸Äš »YÅ·=¿² ¸¶ ² ƶ9Fº¸Ä™ »YÇ·=¿² ¦¶ ² ȶ9Fº¸Äš »YÉ·=¿² ¸¶ ± 6 ^_`b%d-e8fBhJjRk]lgnop$$ * eß² ʶ9Fm¸Ëš »YÌ·=¿² ¸¶ ² Ͷ9F„¸Ëš »Yη=¿² ¸¶ ² ϶9Fm¸Ë™ »Yз=¿² ¦¶ ² Ѷ9F„¸Ëš »YÒ·=¿² ¸¶ ² Ó¶9F²¸Ë™ »YÔ·=¿² ¦¶ ² Õ¶9Fָ˙ »Y×·=¿² ¦¶ ± fvwxz%|-}8~B€J‚Rƒ]„g†oˆw‰‚ŠŒŒ”Žœ§±’¹”Á•Ì–Ö˜Þš$$$$$ + »c² ض9F¸ÙK*¾Ÿ »YÚ·=¿H*2¶Û¶?š »YÜ·=¿² ¿¶ ² ݶ9\¸ÙK*Æ »YÞ·=¿² ¿¶ ± 6 ¡¢£¤¦,§6©>«F¬L­P®Z°b² ü,# - 5¦² ß¶9F¸àK½VY„SYáSYâSL=*¾+¾Ÿ »Yã·=¿>*¾¢/6+¾¢*2¶ä+2¶?™ „§ „§ÿà„§ÿÑ+¾Ÿ »Yå·=¿² ¿¶ ² æ¶9\¸àK*Æ »Yç·=¿² ¿¶ ± Zº»¼"½$¾+¿5Á=ÂGÃWÄZÅ]ÂcÁiÉoÊyÌЉÑÒ“ÓÕ¥Øþ5.üüúú# / µ]² è¶9\¸éK*Æ »Yê·=¿² ¿¶ ² ë¶9F¸éK*¾Ÿ »Yì·=¿*2¥ »Yí·=¿² ¿¶ ± 6 àáâãå$é,ê2ë8ìBîJïTñ\ô ün% 0 ¬K² î¶9»ïY·ðK*>>¹ñW*¹òL+¶ó+ôÀõÀn¸öM§ M² ø¶ ±² B¶ ±"58÷ . ûüýþ"589ABJÿ812÷  3 f,² ù¶9:>¸úK*û¶?š »Yü·=¿² ý¶ ±   #+ü#V4 ³± 56ÿŠFþF –F rJava/inst/java/ArrayWrapper.java0000644000175100001440000002257015133274037016526 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Array ; /** * Utility class to deal with arrays */ public class ArrayWrapper extends RJavaArrayIterator { /** * is this array rectangular */ private boolean isRect ; /** * The type name of the objects stored */ private String typeName ; /** * true if the array stores primitive types */ private boolean primitive ; private int length ; /** * Constructor * * @param array the array to check * @throws NotAnArrayException if array is not an array */ public ArrayWrapper(Object array) throws NotAnArrayException { super( RJavaArrayTools.getDimensions(array) ); this.array = array ; typeName = RJavaArrayTools.getObjectTypeName(array ); primitive = RJavaArrayTools.isPrimitiveTypeName( typeName ) ; if( dimensions.length == 1){ isRect = true ; } else{ isRect = isRectangular_( array, 0 ); } // reset the dimensions if the array is not rectangular if( !isRect ){ dimensions = null ; length = -1; } else{ length = 1; for( int i=0; i*(LRJavaClassLoader;Ljava/io/InputStream;)VCodeLineNumberTable Exceptions! resolveClass.(Ljava/io/ObjectStreamClass;)Ljava/lang/Class;" SourceFileRJavaClassLoader.java  #$ %&' ()* +,'RJavaClassLoader$RJavaObjectInputStreamRJavaObjectInputStream InnerClassesjava/io/ObjectInputStreamjava/io/IOException java/lang/ClassNotFoundException(Ljava/io/InputStream;)Vjava/io/ObjectStreamClassgetName()Ljava/lang/String;RJavaClassLoadergetPrimaryLoader()LRJavaClassLoader;java/lang/ClassforName=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;    + *+µ*,·± rs t $ +¶¸¸° v rJava/inst/java/boot/RJavaClassLoader$UnixDirectory.class0000644000175100001440000000064015133274037023145 0ustar hornikusersÊþº¾2  this$0LRJavaClassLoader;'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTable SourceFileRJavaClassLoader.java  RJavaClassLoader$UnixDirectory UnixDirectory InnerClassesRJavaClassLoader$UnixFileUnixFileRJavaClassLoader  , *+µ*+,·± ¸¹ º  rJava/inst/java/boot/RJavaClassLoader.java0000644000175100001440000004556215133274037020200 0ustar hornikusers// :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: // {{{ imports import java.io.*; import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Vector; import java.util.Enumeration; import java.util.Iterator; import java.util.StringTokenizer; import java.util.zip.*; // }}} /** * Class loader used internally by rJava * * The class manages the class paths and the native libraries (jri, ...) */ public class RJavaClassLoader extends URLClassLoader { // {{{ fields /** * path of RJava */ String rJavaPath ; /** * lib sub directory of rJava */ String rJavaLibPath; /** * map of libraries */ HashMap/**/ libMap; /** * The class path vector */ Vector/**/ classPath; /** * singleton */ public static RJavaClassLoader primaryLoader = null; /** * Print debug messages if is set to true */ public static boolean verbose = false; /** * Should the system class loader be used to resolve classes * as well as this class loader */ public boolean useSystem = true; // }}} // {{{ UnixFile class /** * Light extension of File that handles file separators and updates */ class UnixFile extends File { /** * cached "last time modified" stamp */ long lastModStamp; /** * Constructor. Modifies the path so that * the proper path separator is used (most useful on windows) */ public UnixFile(String fn) { super( u2w(fn) ) ; lastModStamp=0; } /** * @return whether the file modified since last time the update method was called */ public boolean hasChanged() { long curMod = lastModified(); return (curMod != lastModStamp); } /** * Cache the result of the lastModified stamp */ public void update() { lastModStamp = lastModified(); } } // }}} // {{{ UnixJarFile /** * Specialization of UnixFile that deals with jar files */ class UnixJarFile extends UnixFile { /** * The cached jar file */ private ZipFile zfile ; /** * common prefix for all URLs within this jar file */ private String urlPrefix ; public UnixJarFile( String filename ){ super( filename ); } /* @Override */ public void update(){ try { if (zfile != null){ zfile.close(); } zfile = new ZipFile( this ) ; } catch (Exception tryCloseX) {} /* time stamp */ super.update( ) ; } /** * Get an input stream for a resource contained in the jar file * * @param name file name of the resource within the jar file * @return an input stream representing the resouce if it exists or null */ public InputStream getResourceAsStream( String name ){ if (zfile==null || hasChanged()) { update(); } try { if (zfile == null) return null; ZipEntry e = zfile.getEntry(name); if (e != null) return zfile.getInputStream(e); } catch(Exception e) { if (verbose) System.err.println("RJavaClassLoader$UnixJarFile: exception: "+e.getMessage()); } return null; } public URL getResource(String name ){ if( zfile == null || zfile.getEntry( name ) == null ){ return null ; } URL u = null ; if( urlPrefix == null ){ try{ urlPrefix = "jar:" + toURL().toString() + "!" ; } catch( java.net.MalformedURLException ex){ } } try{ u = new URL( urlPrefix + name ) ; } catch( java.net.MalformedURLException ex ){ /* not to worry */ } return u ; } } // }}} // {{{ UnixDirectory class /** * Specialization of UnixFile representing a directory */ /* it is not really a specialization but makes possible to dispatch on instanceof*/ class UnixDirectory extends UnixFile { public UnixDirectory( String dirname ){ super( dirname ) ; } } // }}} // {{{ getPrimaryLoader /** * Returns the singleton instance of RJavaClassLoader */ public static RJavaClassLoader getPrimaryLoader() { return primaryLoader; } // }}} // {{{ constructor /** * Constructor. The first time an RJavaClassLoader is created, it is * cached as the primary loader. * * @param path path of the rJava package * @param libpath lib sub directory of the rJava package */ public RJavaClassLoader(String path, String libpath) { this(path, libpath, null); } /** * Constructor. The first time an RJavaClassLoader is created, it is * cached as the primary loader. * * @param path path of the rJava package * @param libpath lib sub directory of the rJava package * @param parent parent loader if we should fall back upstream or NULL */ public RJavaClassLoader(String path, String libpath, RJavaClassLoader parent) { super(new URL[] {}, (parent == null) ? ClassLoader.getSystemClassLoader() : parent); // respect rJava.debug level String rjd = System.getProperty("rJava.debug"); if (rjd != null && rjd.length() > 0 && !rjd.equals("0")) verbose = true; if (verbose) System.out.println("RJavaClassLoader(\""+path+"\", \""+libpath+"\", "+ ((parent == null) ? "no parent" : parent) + ")"); if (primaryLoader==null) { primaryLoader = this; if (verbose) System.out.println(" - primary loader"); } else { if (verbose) System.out.println(" - NOT primrary (this="+this+", primary="+primaryLoader+")"); } libMap = new HashMap/**/(); classPath = new Vector/**/(); classPath.add(new UnixDirectory(path+"/java")); rJavaPath = path; rJavaLibPath = libpath; /* load the rJava library */ UnixFile so = new UnixFile(rJavaLibPath+"/rJava.so"); if (!so.exists()) so = new UnixFile(rJavaLibPath+"/rJava.dll"); if (so.exists()) libMap.put("rJava", so); /* load the jri library */ UnixFile jri = new UnixFile(path+"/jri/libjri.so"); String rarch = System.getProperty("r.arch"); if (rarch != null && rarch.length()>0) { UnixFile af = new UnixFile(path+"/jri"+rarch+"/libjri.so"); if (af.exists()) jri = af; else { af = new UnixFile(path+"/jri"+rarch+"/jri.dll"); if (af.exists()) jri = af; } } if (!jri.exists()) jri = new UnixFile(path+"/jri/libjri.jnilib"); if (!jri.exists()) jri = new UnixFile(path+"/jri/jri.dll"); if (jri.exists()) { libMap.put("jri", jri); if (verbose) System.out.println(" - registered JRI: "+jri); } /* if we are the primary loader, make us the context loader so projects that rely on the context loader pick us */ if (primaryLoader == this) Thread.currentThread().setContextClassLoader(this); if (verbose) { System.out.println("RJavaClassLoader initialized.\n\nRegistered libraries:"); for(Iterator entries = libMap.keySet().iterator(); entries.hasNext(); ) { Object key = entries.next(); System.out.println(" " + key + ": '" + libMap.get(key) + "'"); } System.out.println("\nRegistered class paths:"); for (Enumeration e = classPath.elements() ; e.hasMoreElements() ;) System.out.println(" '"+e.nextElement()+"'"); System.out.println("\n-- end of class loader report --"); } } // }}} // {{{ classNameToFile /** * convert . to / */ String classNameToFile(String cls) { return cls.replace('.','/'); } // }}} // {{{ findClass protected Class findClass(String name) throws ClassNotFoundException { Class cl = null; if (verbose) System.out.println(""+this+".findClass("+name+")"); if ("RJavaClassLoader".equals(name)) return getClass(); // {{{ use the usual method of URLClassLoader if (useSystem) { try { cl = super.findClass(name); if (cl != null) { if (verbose) System.out.println("RJavaClassLoader: found class "+name+" using URL loader"); return cl; } } catch (Exception fnf) { if (verbose) System.out.println(" - URL loader did not find it: " + fnf); } } if (verbose) System.out.println("RJavaClassLoader.findClass(\""+name+"\")"); // }}} // {{{ iterate through the elements of the class path InputStream ins = null; Exception defineException = null; Enumeration/**/ e = classPath.elements() ; while( e.hasMoreElements() ){ UnixFile cp = (UnixFile) e.nextElement(); if (verbose) System.out.println(" - trying class path \""+cp+"\""); try { ins = null; /* a file - assume it is a jar file */ if (cp instanceof UnixJarFile){ ins = ((UnixJarFile)cp).getResourceAsStream( classNameToFile(name) + ".class" ) ; if (verbose) System.out.println(" JAR file, can get '" + classNameToFile(name) + "'? " + ((ins == null) ? "NO" : "YES")); } else if ( cp instanceof UnixDirectory ){ UnixFile class_f = new UnixFile(cp.getPath()+"/"+classNameToFile(name)+".class"); if (class_f.isFile() ) { ins = new FileInputStream(class_f); } if (verbose) System.out.println(" Directory, can get '" + class_f + "'? " + ((ins == null) ? "NO" : "YES")); } /* some comments on the following : we could call ZipEntry.getSize in case of a jar file to find out the size of the byte[] directly also ByteBuffer seems more efficient, but the ByteBuffer class is java >= 1.4 and the defineClass method that uses the class is java >= 1.5 */ if (ins != null) { int al = 128*1024; byte fc[] = new byte[al]; int n = ins.read(fc); int rp = n; if( verbose ) System.out.println(" loading class file, initial n = "+n); while (n > 0) { if (rp == al) { int nexa = al*2; if (nexa<512*1024) nexa=512*1024; byte la[] = new byte[nexa]; System.arraycopy(fc, 0, la, 0, al); fc = la; al = nexa; } n = ins.read(fc, rp, fc.length-rp); if( verbose ) System.out.println(" next n = "+n+" (rp="+rp+", al="+al+")"); if (n>0) rp += n; } ins.close(); n = rp; if (verbose) System.out.println("RJavaClassLoader: loaded class "+name+", "+n+" bytes"); try { cl = defineClass(name, fc, 0, n); } catch (Exception dce) { // we want to save this one so we can pass it on defineException = dce; break; } if (verbose) System.out.println(" defineClass('" + name +"') returned " + cl); // System.out.println(" - class = "+cl); return cl; } } catch (Exception ex) { // System.out.println(" * won't work: "+ex.getMessage()); } } // }}} if (defineException != null) // we bailed out on class interpretation, re-throw it throw (new ClassNotFoundException("Class not found - candidate class binary found but could not be loaded", defineException)); // giving up if (cl == null) { if( verbose ) System.out.println(" >> ClassNotFoundException "); throw (new ClassNotFoundException()); } return cl; } // }}} // {{{ findResource public URL findResource(String name) { if (verbose) System.out.println("RJavaClassLoader: findResource('"+name+"')"); // {{{ use the standard way if (useSystem) { try { URL u = super.findResource(name); if (u != null) { if (verbose) System.out.println("RJavaClassLoader: found resource in "+u+" using URL loader."); return u; } } catch (Exception fre) { } } // }}} // {{{ iterate through the classpath if (verbose) System.out.println(" - resource not found with URL loader, trying alternative"); Enumeration/**/ e = classPath.elements() ; while( e.hasMoreElements()) { UnixFile cp = (UnixFile) e.nextElement(); try { /* is a file - assume it is a jar file */ if (cp instanceof UnixJarFile ) { URL u = ( (UnixJarFile)cp ).getResource( name ) ; if (u != null) { if (verbose) System.out.println(" - found in a JAR file, URL "+u); return u; } } else if(cp instanceof UnixDirectory ) { UnixFile res_f = new UnixFile(cp.getPath()+"/"+name); if (res_f.isFile()) { if (verbose) System.out.println(" - find as a file: "+res_f); return res_f.toURL(); } } } catch (Exception iox) { } } // }}} return null; } // }}} // {{{ addRLibrary /** add a library to path mapping for a native library */ public void addRLibrary(String name, String path) { libMap.put(name, new UnixFile(path)); } // }}} // {{{ addClassPath /** * adds an entry to the class path */ public void addClassPath(String cp) { UnixFile f = new UnixFile(cp); // use the URLClassLoader if (useSystem) { try { addURL(f.toURL()); if (verbose) System.out.println("RJavaClassLoader: added '" + cp + "' to the URL class path loader"); //return; // we need to add it anyway so it appears in .jclassPath() } catch (Exception ufe) { } } UnixFile g = null ; if( f.isFile() && (f.getName().endsWith(".jar") || f.getName().endsWith(".JAR"))) { g = new UnixJarFile(cp) ; if (verbose) System.out.println("RJavaClassLoader: adding Java archive file '"+cp+"' to the internal class path"); } else if( f.isDirectory() ){ g = new UnixDirectory(cp) ; if (verbose) System.out.println("RJavaClassLoader: adding class directory '"+cp+"' to the internal class path"); } else if (verbose) System.err.println(f.exists() ? ("WARNING: the path '"+cp+"' is neither a directory nor a .jar file, it will NOT be added to the internal class path!") : ("WARNING: the path '"+cp+"' does NOT exist, it will NOT be added to the internal class path!")); if (g != null && !classPath.contains(g)) { // this is the real meat - add it to our internal list classPath.add(g); // this is just cosmetics - it doesn't really have any meaning System.setProperty("java.class.path", System.getProperty("java.class.path")+File.pathSeparator+g.getPath()); } } /** * adds several entries to the class path */ public void addClassPath(String[] cp) { int i = 0; while (i < cp.length) addClassPath(cp[i++]); } // }}} // {{{ getClassPath /** * @return the array of class paths used by this class loader */ public String[] getClassPath() { int j = classPath.size(); String[] s = new String[j]; int i = 0; while (i < j) { s[i] = ((UnixFile) classPath.elementAt(i)).getPath(); i++; } return s; } // }}} // {{{ findLibrary protected String findLibrary(String name) { if (verbose) System.out.println("RJavaClassLoader.findLibrary(\""+name+"\")"); //if (name.equals("rJava")) // return rJavaLibPath+"/"+name+".so"; UnixFile u = (UnixFile) libMap.get(name); String s = null; if (u!=null && u.exists()) s=u.getPath(); if (verbose) System.out.println(" - mapping to "+((s==null)?"":s)); return s; } // }}} // {{{ bootClass /** * Boots the specified method of the specified class * * @param cName class to boot * @param mName method to boot (typically main). The method must take a String[] as parameter * @param args arguments to pass to the method */ public void bootClass(String cName, String mName, String[] args) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, java.lang.ClassNotFoundException { Class c = findClass(cName); resolveClass(c); java.lang.reflect.Method m = c.getMethod(mName, new Class[] { String[].class }); m.invoke(null, new Object[] { args }); } // }}} // {{{ setDebug /** * Set the debug level. At the moment, there is only verbose (level > 0) * or quiet * * @param level debug level. verbose (>0), quiet otherwise */ public static void setDebug(int level) { verbose=(level>0); } // }}} // {{{ u2w /** * Utility to convert paths for windows. Converts / to the path separator in use * * @param fn file name */ public static String u2w(String fn) { return (File.separatorChar != '/') ? fn.replace('/', File.separatorChar) : fn ; } // }}} // {{{ main /** * main method * *

This uses the system properties:

*
    *
  • rjava.path : path of the rJava package
  • *
  • rjava.lib : lib sub directory of the rJava package
  • *
  • main.class : main class to "boot", assumes Main if not specified
  • *
  • rjava.class.path : set of paths to populate the initiate the class path
  • *
* *

and boots the "main" method of the specified main.class, * passing the args down to the booted class

* *

This makes sure R and rJava are known by the class loader

*/ public static void main(String[] args) { String rJavaPath = System.getProperty("rjava.path"); if (rJavaPath == null) { System.err.println("ERROR: rjava.path is not set"); System.exit(2); } String rJavaLib = System.getProperty("rjava.lib"); if (rJavaLib == null) { // it is not really used so far, just for rJava.so, so we can guess rJavaLib = rJavaPath + File.separator + "libs"; } RJavaClassLoader cl = new RJavaClassLoader(u2w(rJavaPath), u2w(rJavaLib)); String mainClass = System.getProperty("main.class"); if (mainClass == null || mainClass.length()<1) { System.err.println("WARNING: main.class not specified, assuming 'Main'"); mainClass = "Main"; } String classPath = System.getProperty("rjava.class.path"); if (classPath != null) { StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator); while (st.hasMoreTokens()) { String dirname = u2w(st.nextToken()); cl.addClassPath(dirname); } } try { cl.bootClass(mainClass, "main", args); } catch (Exception ex) { System.err.println("ERROR: while running main method: "+ex); ex.printStackTrace(); } } // }}} //----- tools ----- // {{{ RJavaObjectInputStream class class RJavaObjectInputStream extends ObjectInputStream { public RJavaObjectInputStream(InputStream in) throws IOException { super(in); } protected Class resolveClass(ObjectStreamClass desc) throws ClassNotFoundException { return Class.forName(desc.getName(), false, RJavaClassLoader.getPrimaryLoader()); } } // }}} // {{{ toByte /** * Serialize an object to a byte array. (code by CB) * * @param object object to serialize * @return byte array that represents the object * @throws Exception */ public static byte[] toByte(Object object) throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream((OutputStream) os); oos.writeObject(object); oos.close(); return os.toByteArray(); } // }}} // {{{ toObject /** * Deserialize an object from a byte array. (code by CB) * * @param byteArray * @return the object that is represented by the byte array * @throws Exception */ public Object toObject(byte[] byteArray) throws Exception { InputStream is = new ByteArrayInputStream(byteArray); RJavaObjectInputStream ois = new RJavaObjectInputStream(is); Object o = (Object) ois.readObject(); ois.close(); return o; } // }}} // {{{ toObjectPL /** * converts the byte array into an Object using the primary RJavaClassLoader */ public static Object toObjectPL(byte[] byteArray) throws Exception{ return RJavaClassLoader.getPrimaryLoader().toObject(byteArray); } // }}} } rJava/inst/java/boot/RJavaClassLoader$UnixFile.class0000644000175100001440000000130715133274037022061 0ustar hornikusersÊþº¾2'       lastModStampJthis$0LRJavaClassLoader;'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTable hasChanged()Z StackMapTableupdate()V SourceFileRJavaClassLoader.java ! "# $  %&RJavaClassLoader$UnixFileUnixFile InnerClasses java/io/FileRJavaClassLoaderu2w&(Ljava/lang/String;)Ljava/lang/String;(Ljava/lang/String;)V lastModified()J    7*+µ*,¸·* µ±LM NO>*¶@*´”™§¬ UVü@% **¶µ± ]^ rJava/inst/java/boot/RJavaClassLoader.class0000644000175100001440000002776515133274037020371 0ustar hornikusersÊþº¾2? ® ® ç Ì ®  › › ®    ! "# $ è%&'()  ®*+  ®,-. "/ 0 ®1 ®234 (/ (567 89:;<=>?@A BC BDE F GH éI éJKL MNO P êQR êST ›UVWX ¥Y ÌZ[\]^_`abc ®de Wfghij (kl (mn bop ïqr s t ïuvwx ïyz{| ®}~€ v‚ƒ v„… ̆‡ˆ‰ WŠ‹Œ ( ®Ž (‘’ ›“” W/•– (—˜ ™š›œ ž Ÿ  ¡ ®¢ £¤ ¥¦§¨ ®Z ®©ª« ¢¬­ ®¯ Ÿ°±² ³´ Ÿµ¶X ®· ®¸¹º»¼½ µ¸ µ¾ µ¿ ®ÀÁ QÂà ½Ä ¿Å ¿Æ ¿y ½ÇÈ ÄÉÊ ÆË ÆÌ Æy ®Í ®ÎÏRJavaObjectInputStream InnerClasses UnixDirectory UnixJarFileUnixFile rJavaPathLjava/lang/String; rJavaLibPathlibMapLjava/util/HashMap; classPathLjava/util/Vector; primaryLoaderLRJavaClassLoader;verboseZ useSystemgetPrimaryLoader()LRJavaClassLoader;CodeLineNumberTable'(Ljava/lang/String;Ljava/lang/String;)V9(Ljava/lang/String;Ljava/lang/String;LRJavaClassLoader;)V StackMapTableÐÑÒÓÔclassNameToFile&(Ljava/lang/String;)Ljava/lang/String; findClass%(Ljava/lang/String;)Ljava/lang/Class;ÕÖ Exceptions findResource"(Ljava/lang/String;)Ljava/net/URL; addRLibrary addClassPath(Ljava/lang/String;)V([Ljava/lang/String;)V getClassPath()[Ljava/lang/String; findLibrary bootClass:(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)VרÙsetDebug(I)Vu2wmaintoByte(Ljava/lang/Object;)[BtoObject([B)Ljava/lang/Object; toObjectPL()V SourceFileRJavaClassLoader.java ÙÚ âä java/net/URL ÚÛ âÜ ÝÜ rJava.debugÝ Þì ßà0 áâ ÛÜ ãäjava/lang/StringBuilder â RJavaClassLoader(" åæ", "",  no parent åç) èé êö - primary loader - NOT primrary (this= , primary=java/util/HashMap ÕÖjava/util/Vector רRJavaClassLoader$UnixDirectory/java âë ìâ ÒÓ ÔÓRJavaClassLoader$UnixFile /rJava.so íî /rJava.dllrJava ïð/jri/libjri.sor.arch/jri /libjri.so/jri.dll/jri/libjri.jnilib /jri/jri.dlljri - registered JRI: ñ òó ôõ4RJavaClassLoader initialized. Registered libraries: ö÷ø ùú ûî üý : ' þÿ' Registered class paths:  î ' ý! -- end of class loader report --  .findClass(RJavaClassLoader  íîRJavaClassLoader: found class  using URL loaderjava/lang/Exception - URL loader did not find it: RJavaClassLoader.findClass("") - trying class path ""RJavaClassLoader$UnixJarFile ëì.class   JAR file, can get ''? NOYES  é/  îjava/io/FileInputStream â  Directory, can get '  " loading class file, initial n = å    next n =  (rp=, al=  RJavaClassLoader: loaded class ,  bytes  defineClass(' ') returned  java/lang/ClassNotFoundExceptionFClass not found - candidate class binary found but could not be loaded â >> ClassNotFoundException  RJavaClassLoader: findResource('') òó$RJavaClassLoader: found resource in  using URL loader.9 - resource not found with URL loader, trying alternative ó - found in a JAR file, URL  - find as a file:  RJavaClassLoader: added '' to the URL class path loader é.jar .JAR,RJavaClassLoader: adding Java archive file '' to the internal class path î*RJavaClassLoader: adding class directory '  äWARNING: the path 'Z' is neither a directory nor a .jar file, it will NOT be added to the internal class path!B' does NOT exist, it will NOT be added to the internal class path! !âjava.class.path" #Ó $% õö &àjava/lang/String '(RJavaClassLoader.findLibrary(" - mapping to  )*java/lang/Class[Ljava/lang/String; +,java/lang/Object- ./ 01 rjava.pathERROR: rjava.path is not set 2 rjava.lib 3Ólibs ì âã main.class2WARNING: main.class not specified, assuming 'Main'Mainrjava.class.pathjava/util/StringTokenizer 4î 5é ûü"ERROR: while running main method: 6 java/io/ByteArrayOutputStreamjava/io/ObjectOutputStream â7 89 :;java/io/ByteArrayInputStream â<'RJavaClassLoader$RJavaObjectInputStream â= >ý Þß java/net/URLClassLoader[Ljava/net/URL;java/lang/ClassLoaderjava/io/PrintStreamjava/util/Iteratorjava/util/Enumerationjava/io/InputStream[B java/lang/IllegalAccessException+java/lang/reflect/InvocationTargetExceptionjava/lang/NoSuchMethodExceptiongetSystemClassLoader()Ljava/lang/ClassLoader;)([Ljava/net/URL;Ljava/lang/ClassLoader;)Vjava/lang/System getPropertylength()Iequals(Ljava/lang/Object;)ZoutLjava/io/PrintStream;append-(Ljava/lang/String;)Ljava/lang/StringBuilder;-(Ljava/lang/Object;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;println'(LRJavaClassLoader;Ljava/lang/String;)Vaddexists()Zput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/lang/Thread currentThread()Ljava/lang/Thread;setContextClassLoader(Ljava/lang/ClassLoader;)VkeySet()Ljava/util/Set; java/util/Setiterator()Ljava/util/Iterator;hasNextnext()Ljava/lang/Object;get&(Ljava/lang/Object;)Ljava/lang/Object;elements()Ljava/util/Enumeration;hasMoreElements nextElementreplace(CC)Ljava/lang/String;getClass()Ljava/lang/Class;getResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream;getPathisFile(Ljava/io/File;)Vread([B)I(I)Ljava/lang/StringBuilder; arraycopy*(Ljava/lang/Object;ILjava/lang/Object;II)V([BII)Iclose defineClass)(Ljava/lang/String;[BII)Ljava/lang/Class;*(Ljava/lang/String;Ljava/lang/Throwable;)V getResourcetoURL()Ljava/net/URL;addURL(Ljava/net/URL;)VgetNameendsWith(Ljava/lang/String;)Z isDirectoryerrcontains java/io/File pathSeparator setProperty8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;size elementAt(I)Ljava/lang/Object; resolveClass(Ljava/lang/Class;)V getMethod@(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;java/lang/reflect/Methodinvoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; separatorCharCexit separator hasMoreTokens nextTokenprintStackTrace(Ljava/io/OutputStream;)V writeObject(Ljava/lang/Object;)V toByteArray()[B([B)V*(LRJavaClassLoader;Ljava/io/InputStream;)V readObject!®ÌÒÓÔÓÕÖר ÙÚ ÛÜÝÜ ÞßರáÄâãà$*+,·±á ÑÒâäà» 5*½-Ç ¸§-·*µ¸:ƶ ž ¶ š³ ² ™<² »Y·¶+¶¶,¶¶-ǧ-¶¶¶¶²Ç*³² ™=² ¶§2² ™,² »Y·¶*¶¶²¶¶¶¶*»Y·µ*»Y· µ!*´!»"Y*»Y·+¶#¶¶·$¶%W*+µ&*,µ'»(Y*»Y·*´'¶)¶¶·*:¶+š#»(Y*»Y·*´'¶,¶¶·*:¶+™*´-¶.W»(Y*»Y·+¶/¶¶·*:0¸:Æt¶ žl»(Y*»Y·+¶1¶¶2¶¶·*:¶+™ :§6»(Y*»Y·+¶1¶¶3¶¶·*:¶+™:¶+š »(Y*»Y·+¶4¶¶·*:¶+š »(Y*»Y·+¶5¶¶·*:¶+™/*´6¶.W² ™² »Y·7¶¶¶¶²*¦ ¸8*¶9² ™©² :¶*´¶;¹<:¹=™?¹>: ² »Y·?¶ ¶@¶*´ ¶A¶B¶¶¶§ÿ½² C¶*´!¶D:¹E™*² »Y·F¶¹G¶B¶¶¶§ÿÒ² H¶±á¾/Ý:àá:âyãäƒå”çÃêÎìÙíüïðó&ô.õNöV÷búû†ü“ýºþÂÿÉðøü!) F N Z zˆŽ–®çêò,4å°ÿ››®æÿ››®æçÿ)®››®›ÿ/®››®›èÿ®››®›è¥ .üŠ(þf(›(ú2$$3 üéúEüêú0ëìà! +./¶I°á&íîਠVM² ™*² »Y·J¶*¶K¶+¶¶¶¶L+¶ ™*¶M°*´™V*+·NM,Æ)² ™!² »Y·O¶+¶P¶¶¶,°§#N² ™² »Y·R¶-¶¶¶² ™!² »Y·S¶+¶T¶¶¶N:*´!¶D:¹E™Y¹GÀ(:² ™"² »Y·U¶¶V¶¶¶NÁW™\ÀW»Y·*+¶X¶Y¶¶¶ZN² ™±² »Y·[¶*+¶X¶\¶-Ç]§^¶¶¶§~Á"™v»(Y*»Y·¶_¶`¶*+¶X¶Y¶¶·*:¶a™ »bY·cN² ™0² »Y·d¶¶\¶-Ç]§^¶¶¶-Æ>e6¼:-¶f6  6 ² ™² »Y·g¶ ¶h¶¶ žŒ  -h6  i¢i6  ¼:  ¸j : 6- ¾ d¶k6 ² ™6² »Y·l¶ ¶hm¶ ¶hn¶¶h¶¶¶ žÿ  `6 §ÿu-¶o 6 ² ™+² »Y·p¶+¶q¶ ¶hr¶¶¶*+ ¶sM§ :  :§5² ™%² »Y·t¶+¶u¶,¶¶¶,°§:§ý£Æ»vYw·x¿,Dz ™ ² y¶»vY·z¿,°DswQàëîQô$Q÷ $Qáþ?,-/.=1D3J4N5r6t:w8x9—<»@½AÀBÉCÓDßFHJK.LgMoNO¥P¯Râ_æ`êaðbøcüde!f(g.h9i?jJkNlRnbo›pªr®s²tàvë{îwðyôz÷|~!‚$€&ƒ)†.‡:Š>‹LŒTŽå ü/¢ 4BQ#þ ïQêü:(ÿT®›¢ïQê(èÿ®›¢ïQê(è› üG(ÿ'®›¢ïQê((èÿ®›¢ïQê((è›úÿ9 ®›¢ïQê(ðüúûH5MQ'ÿ®›¢ïQê(BQúñvòóà÷'² ™!² »Y·{¶+¶|¶¶¶*´™7*+·}M,Æ)² ™!² »Y·~¶,¶¶¶¶,°§M² ™ ² €¶*´!¶DM,¹E™ª,¹GÀ(N-ÁW™8-ÀW+¶:Æ&² ™² »Y·‚¶¶¶¶°§\-Á"™U»(Y*»Y·-¶_¶`¶+¶¶·*:¶a™)² ™² »Y·ƒ¶¶¶¶¶„°§:§ÿS°+Z^QˆÀ QÁ Qáj”$—+™1š5›Yœ[Ÿ^ž_¤m¥u¦~§ˆ«¬™­ž®¾¯Á±Ë²ï³÷´µ¹ ¸"º%¼å6$ü4úBQ üêýH(úüR(úBQúôãà/*´+»(Y*,·*¶.W±á ÃÄõöàO»(Y*+·*M*´™3*,¶„¶…² ™!² »Y·†¶+¶‡¶¶¶§NN,¶a™L,¶ˆ‰¶Šš,¶ˆ‹¶Š™4»WY*+·ŒN² ™¢² »Y·¶+¶޶¶¶§,¶™4»"Y*+·$N² ™j² »Y·¶+¶޶¶¶§I² ™C²‘,¶+™»Y·’¶+¶“¶¶§»Y·’¶+¶”¶¶¶-Æ<*´!-¶•š1*´!-¶%W–»Y·–¸¶²—¶-¶_¶¶¸˜W±=@QábÌ ÏÑÒ=Õ@ÔAØCÙbÚlÛ“ÜšݤÞËßÑàÛáöâàä æ)è4éJèNëå4 ü=(BQü (07jèÿ®›((è›<õ÷àC=+¾¢*+„2¶™§ÿð±áñòóåüøùàn-*´!¶š<½›M>¢,*´!¶œÀ(¶_S„§ÿç,°áûü ýþÿ%+å þ£úìààl² ™!² »Y·¶+¶T¶¶¶*´+¶AÀ(MN,Æ,¶+™,¶_N² ™%² »Y·ž¶-ÇŸ§-¶¶¶-°á$ 0 2BjåB$ý(›ÿ®›(›èÿ®›(›è›ûüàV.*+¶ :*¶¡,½¢Y£S¶¤:½¥Y-S¶¦W±á  !-"ñ ýþÿv à4 ž§³ ±á - .å@ ìà;²§/Ÿ*/²§¶I§*°á8å@› ÷à}Ψ¸L+Dz‘©¶¸ª«¸M,Ç»Y·+¶²¬¶­¶¶M»®Y+¸¯,¸¯·°N±¸:Æ ¶ ¢²‘²¶³:´¸:Æ,»µY²—·¶:¶·™¶¸¸¯:-¶™§ÿè-¹*¶º§$:²‘»Y·»¶¶¶¶¶¼± ©¬QáfNO PQST U:WJXQY_Zg[k]r^w_…`a—bc f©j¬g®hÈiÍkå)ü›ü#›ý$®› ý›µúKQ àG»½Y·¾L»¿Y+·ÀM,*¶Á,¶Â+¶Ã°á„…†‡ˆñQàH »ÄY+·ÅM»ÆY*,·ÇN-¶È:-¶É°á• –—˜™ñQ à ¸Ê*¶Ë°á¢ñQ  à% ³³ ±á /4  Î"Æ®Í"®ÏW®Ð(®ÑrJava/inst/java/boot/RJavaClassLoader$UnixJarFile.class0000644000175100001440000000373615133274037022526 0ustar hornikusersÊþº¾2p 4 5 6 78 9: ; < ; = > ?@ ABC DE F G H IJ KL M HNOP QRUzfileLjava/util/zip/ZipFile; urlPrefixLjava/lang/String;this$0LRJavaClassLoader;'(LRJavaClassLoader;Ljava/lang/String;)VCodeLineNumberTableupdate()V StackMapTablegetResourceAsStream)(Ljava/lang/String;)Ljava/io/InputStream; getResource"(Ljava/lang/String;)Ljava/net/URL;W SourceFileRJavaClassLoader.java $% &' ! X+java/util/zip/ZipFile &Yjava/lang/Exception *+ Z[ \] ^_` abc dejava/lang/StringBuilder &+)RJavaClassLoader$UnixJarFile: exception: fg hi jik lm "#jar: no!java/net/MalformedURLException java/net/URL &mRJavaClassLoader$UnixJarFile UnixJarFile InnerClassesRJavaClassLoader$UnixFileUnixFilejava/lang/Stringclose(Ljava/io/File;)V hasChanged()ZgetEntry,(Ljava/lang/String;)Ljava/util/zip/ZipEntry;getInputStream/(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;RJavaClassLoaderverboseZjava/lang/SystemerrLjava/io/PrintStream;append-(Ljava/lang/String;)Ljava/lang/StringBuilder; getMessage()Ljava/lang/String;toStringjava/io/PrintStreamprintln(Ljava/lang/String;)VtoURL()Ljava/net/URL;  !"#$%&'(, *+µ*+,·±)rs t*+(e#*´Æ *´¶*»Y*·µ§L*·±)yz|}€",N-.(¶Y*´Æ *¶ ™*¶ *´Ç°*´+¶ M,Æ *´,¶ °§&M² ™²»Y·¶,¶¶¶¶°404)* ‹Œ$‘(’1•4“5”W–, B"/0(Ùf*´Æ*´+¶ ǰM*´Ç)*»Y·¶*¶¶¶¶¶µ§N»Y»Y·*´¶+¶¶·M§N,°?BC`c). ›œŸ ¢?¤B£C¨`«c©d¬,ÿ-1_23T?S?VrJava/inst/java/RJavaArrayTools_Test.java0000644000175100001440000012402315133274037020125 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: public class RJavaArrayTools_Test { // {{{ main public static void main(String[] args){ System.out.println( "Test suite for RJavaArrayTools" ) ; try{ runtests() ; } catch( TestException e){ fails( e ) ; System.exit(1); } System.exit(0); } // }}} // {{{ runtests public static void runtests() throws TestException { System.out.println( "Test suite for RJavaArrayTools" ) ; System.out.println( "Testing RJavaArrayTools.isArray" ) ; isarray(); success() ; System.out.println( "Testing RJavaArrayTools.isRectangularArray" ) ; isrect(); success() ; System.out.println( "Testing RJavaArrayTools.getDimensionLength" ) ; getdimlength(); success() ; System.out.println( "Testing RJavaArrayTools.getDimensions" ) ; getdims(); success() ; System.out.println( "Testing RJavaArrayTools.getTrueLength" ) ; gettruelength(); success() ; System.out.println( "Testing RJavaArrayTools.getObjectTypeName" ) ; gettypename(); success() ; System.out.println( "Testing RJavaArrayTools.isPrimitiveTypeName" ) ; isprim(); success() ; System.out.println( "Testing RJavaTools.rep" ) ; rep(); success() ; } // }}} // {{{ fails private static void fails( TestException e ){ System.err.println( "\n" ) ; e.printStackTrace() ; System.err.println( "FAILED" ) ; } // }}} // {{{ success private static void success(){ System.out.println( "PASSED" ) ; } // }}} // {{{ isarray private static void isarray() throws TestException { // {{{ int System.out.print( " isArray( int )" ) ; if( RJavaArrayTools.isArray( 0 ) ){ throw new TestException( " isArray( int ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ boolean System.out.print( " isArray( boolean )" ) ; if( RJavaArrayTools.isArray( true ) ){ throw new TestException( " isArray( boolean ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ byte System.out.print( " isArray( byte )" ) ; if( RJavaArrayTools.isArray( (byte)0 ) ){ throw new TestException( " isArray( byte ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ long System.out.print( " isArray( long )" ) ; if( RJavaArrayTools.isArray( (long)0 ) ){ throw new TestException( " isArray( long ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ short System.out.print( " isArray( short )" ) ; if( RJavaArrayTools.isArray( (double)0 ) ){ throw new TestException( " isArray( short ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ double System.out.print( " isArray( double )" ) ; if( RJavaArrayTools.isArray( 0.0 ) ){ throw new TestException( " isArray( double ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ char System.out.print( " isArray( char )" ) ; if( RJavaArrayTools.isArray( 'a' ) ){ throw new TestException( " isArray( char ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ float System.out.print( " isArray( float )" ) ; if( RJavaArrayTools.isArray( 0.0f ) ){ throw new TestException( " isArray( float ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ String System.out.print( " isArray( String )" ) ; if( RJavaArrayTools.isArray( "dd" ) ){ throw new TestException( " isArray( String ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ int[] int[] x = new int[2] ; System.out.print( " isArray( int[] )" ) ; if( ! RJavaArrayTools.isArray( x ) ){ throw new TestException( " !isArray( int[] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ Object o = new double[2] Object o = new double[2]; System.out.print( " isArray( double[] (but declared as 0bject) )" ) ; if( ! RJavaArrayTools.isArray( o ) ){ throw new TestException( " !isArray( Object o = new double[2]; ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ null System.out.print( " isArray( null )" ) ; if( RJavaArrayTools.isArray( null ) ){ throw new TestException( " isArray( null) " ) ; } System.out.println( " false : ok" ) ; // }}} } // }}} // {{{ getdimlength private static void getdimlength() throws TestException{ System.out.println( " >> actual arrays" ) ; // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ if( RJavaArrayTools.getDimensionLength( o ) != 1 ){ throw new TestException( "getDimensionLength( int[10] ) != 1" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " 1 : ok " ); // }}} // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ if( RJavaArrayTools.getDimensionLength( o ) != 1 ){ throw new TestException( "getDimensionLength( int[0] ) != 1" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " 1 : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ if( RJavaArrayTools.getDimensionLength( ob ) != 2 ){ throw new TestException( "getDimensionLength( new Object[10][10] ) != 2" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " 2 : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ if( RJavaArrayTools.getDimensionLength( obj ) != 3 ){ throw new TestException( "getDimensionLength( new Object[10][10][3] ) != 3" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][3]" ) ; } System.out.println( " 3 : ok " ); // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ RJavaArrayTools.getDimensionLength( Double.valueOf(10.3) ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getDimensionLength(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getDimensionLength( int )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getDimensionLength( boolean )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getDimensionLength( byte )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getDimensionLength( long )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getDimensionLength( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getDimensionLength( short )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getDimensionLength( double )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getDimensionLength( char )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getDimensionLength( float )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensionLength( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getDimensionLength( null )" ) ; ok = false; try{ RJavaArrayTools.getDimensionLength( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getDimensionLength( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getDimensionLength( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ getdims private static void getdims() throws TestException{ int[] res = null ; // {{{ actual arrays // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getDimensions( o ); if( res.length != 1 ){ throw new TestException( "getDimensions( int[10]).length != 1" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( int[10])[0] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " c( 10 ) : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getDimensions( ob ) ; if( res.length != 2 ){ throw new TestException( "getDimensions( Object[10][10] ).length != 2" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10] )[1] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " c(10,10) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][10][10] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[1] != 10" ); } if( res[2] != 10 ){ throw new TestException( "getDimensions( Object[10][10][10] )[1] != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " c(10,10,10) : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getDimensions( o ) ; if( res.length != 1 ){ throw new TestException( "getDimensions( int[0]).length != 1" ); } if( res[0] != 0){ throw new TestException( "getDimensions( int[0])[0] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " c(0) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][10][0] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][10][0] )[0] != 10" ); } if( res[1] != 10 ){ throw new TestException( "getDimensions( Object[10][10][0] )[1] != 10" ); } if( res[2] != 0 ){ throw new TestException( "getDimensions( Object[10][10][0] )[1] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " c(10,10,0) : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getDimensions( obj ) ; if( res.length != 3 ){ throw new TestException( "getDimensions( Object[10][0][0] ).length != 3" ); } if( res[0] != 10 ){ throw new TestException( "getDimensions( Object[10][0][0] )[0] != 10" ); } if( res[1] != 0 ){ throw new TestException( "getDimensions( Object[10][0][0] )[1] != 0" ); } if( res[2] != 0 ){ throw new TestException( "getDimensions( Object[10][0][0] )[1] != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " c(10,0,0) : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getDimensions( Double.valueOf(10.3) ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getDimensions(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getDimensions( int )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getDimensions( boolean )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getDimensions( byte )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getDimensions( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getDimensions( long )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getDimensions( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getDimensions( short )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getDimensions( double )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getDimensions( char )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getDimensions( float )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getDimensions( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getDimensions( null )" ) ; ok = false; try{ RJavaArrayTools.getDimensions( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getDimensions( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getDimensions( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ gettruelength private static void gettruelength() throws TestException{ int res = 0 ; // {{{ actual arrays // {{{ int[] o = new int[10] ; int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getTrueLength( o ); if( res != 10 ){ throw new TestException( "getTrueLength( int[10]) != 10" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " 10 : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( ob ) ; if( res != 100 ){ throw new TestException( "getTrueLength( Object[10][10] ) != 100" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " 100 : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 1000 ){ throw new TestException( "getTrueLength( Object[10][10][10] ) != 1000" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " 1000 : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getTrueLength( o ) ; if( res != 0 ){ throw new TestException( "getTrueLength( int[0]) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " c(0) : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 0 ){ throw new TestException( "getTrueLength( Object[10][10][0] ) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " 0 : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getTrueLength( obj ) ; if( res != 0){ throw new TestException( "getTrueLength( Object[10][0][0] ) != 0" ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " 0 : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getTrueLength( Double.valueOf(10.3) ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getTrueLength(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getTrueLength( int )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getTrueLength( boolean )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getTrueLength( byte )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getTrueLength( long )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getTrueLength( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getTrueLength( short )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getTrueLength( double )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getTrueLength( char )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getTrueLength( float )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getTrueLength( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getTrueLength( null )" ) ; ok = false; try{ RJavaArrayTools.getTrueLength( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getTrueLength( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getTrueLength( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ isRectangular private static void isrect() throws TestException { // {{{ int System.out.print( " isRectangularArray( int )" ) ; if( RJavaArrayTools.isRectangularArray( 0 ) ){ throw new TestException( " isRectangularArray( int ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ boolean System.out.print( " isRectangularArray( boolean )" ) ; if( RJavaArrayTools.isRectangularArray( true ) ){ throw new TestException( " isRectangularArray( boolean ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ byte System.out.print( " isRectangularArray( byte )" ) ; if( RJavaArrayTools.isRectangularArray( (byte)0 ) ){ throw new TestException( " isRectangularArray( byte ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ long System.out.print( " isRectangularArray( long )" ) ; if( RJavaArrayTools.isRectangularArray( (long)0 ) ){ throw new TestException( " isRectangularArray( long ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ short System.out.print( " isRectangularArray( short )" ) ; if( RJavaArrayTools.isRectangularArray( (double)0 ) ){ throw new TestException( " isRectangularArray( short ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ double System.out.print( " isRectangularArray( double )" ) ; if( RJavaArrayTools.isRectangularArray( 0.0 ) ){ throw new TestException( " isRectangularArray( double ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ char System.out.print( " isRectangularArray( char )" ) ; if( RJavaArrayTools.isRectangularArray( 'a' ) ){ throw new TestException( " isRectangularArray( char ) " ); } System.out.println( " false : ok" ) ; // }}} // {{{ float System.out.print( " isRectangularArray( float )" ) ; if( RJavaArrayTools.isRectangularArray( 0.0f ) ){ throw new TestException( " isRectangularArray( float ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ String System.out.print( " isRectangularArray( String )" ) ; if( RJavaArrayTools.isRectangularArray( "dd" ) ){ throw new TestException( " isRectangularArray( String ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ int[] int[] x = new int[2] ; System.out.print( " isRectangularArray( int[] )" ) ; if( ! RJavaArrayTools.isRectangularArray( x ) ){ throw new TestException( " !isRectangularArray( int[] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ Object o = new double[2] Object o = new double[2]; System.out.print( " isRectangularArray( double[] (but declared as 0bject) )" ) ; if( ! RJavaArrayTools.isRectangularArray( o ) ){ throw new TestException( " !isRectangularArray( Object o = new double[2]; ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ null System.out.print( " isRectangularArray( null )" ) ; if( RJavaArrayTools.isRectangularArray( null ) ){ throw new TestException( " isRectangularArray( null) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ 2d rectangular int[][] x2d = new int[3][4]; System.out.print( " isRectangularArray( new int[3][4] )" ) ; if( ! RJavaArrayTools.isRectangularArray( x2d ) ){ throw new TestException( " !isRectangularArray( new int[3][4] ) " ) ; } System.out.println( " true : ok" ) ; // }}} // {{{ 2d not rectangular int[][] x2d_not = new int[2][] ; x2d_not[0] = new int[2] ; x2d_not[1] = new int[3] ; System.out.print( " isRectangularArray( new int[2][2,4] )" ) ; if( RJavaArrayTools.isRectangularArray( x2d_not ) ){ throw new TestException( " !isRectangularArray( new int[2][2,4] ) " ) ; } System.out.println( " false : ok" ) ; // }}} // {{{ 3d not rectangular int[][][] x3d_not = new int[1][][] ; x3d_not[0] = new int[2][]; x3d_not[0][0] = new int[1] ; x3d_not[0][1] = new int[2] ; System.out.print( " isRectangularArray( new int[2][2][10,25] )" ) ; if( RJavaArrayTools.isRectangularArray( x3d_not ) ){ throw new TestException( " !isRectangularArray( new int[2][2][10,25] ) " ) ; } System.out.println( " false : ok" ) ; // }}} } // }}} // {{{ getObjectTypeName private static void gettypename() throws TestException { String res ; // {{{ actual arrays // {{{ int[] o = new int[10] ; System.out.print( " int[] o = new int[10] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new int[1] ); if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " I : ok " ); // }}} // {{{ boolean[] ; System.out.print( " boolean[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new boolean[1] ); if( !res.equals("Z") ){ throw new TestException( "getObjectTypeName(boolean[]) != 'Z' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array boolean[10]" ) ; } System.out.println( " Z : ok " ); // }}} // {{{ byte[] ; System.out.print( " byte[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new byte[1] ); if( !res.equals("B") ){ throw new TestException( "getObjectTypeName(byte[]) != 'B' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array byte[10]" ) ; } System.out.println( " B : ok " ); // }}} // {{{ long[] ; System.out.print( " long[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new long[1] ); if( !res.equals("J") ){ throw new TestException( "getObjectTypeName(long[]) != 'J' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array long[10]" ) ; } System.out.println( " J : ok " ); // }}} // {{{ short[] ; System.out.print( " short[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new short[1] ); if( !res.equals("S") ){ throw new TestException( "getObjectTypeName(short[]) != 'S' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array short[10]" ) ; } System.out.println( " S : ok " ); // }}} // {{{ double[] ; System.out.print( " double[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new double[1] ); if( !res.equals("D") ){ throw new TestException( "getObjectTypeName(double[]) != 'D' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array double[10]" ) ; } System.out.println( " D : ok " ); // }}} // {{{ char[] ; System.out.print( " char[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new char[1] ); if( !res.equals("C") ){ throw new TestException( "getObjectTypeName(char[]) != 'C' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array char[10]" ) ; } System.out.println( " C : ok " ); // }}} // {{{ float[] ; System.out.print( " float[]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new float[1] ); if( !res.equals("F") ){ throw new TestException( "getObjectTypeName(float[]) != 'F' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array float[10]" ) ; } System.out.println( " F : ok " ); // }}} System.out.println(" >> multi dim primitive arrays" ) ; // {{{ int[] o = new int[10] ; System.out.print( " int[][] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new int[1][1] ); if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } System.out.println( " I : ok " ); // }}} // {{{ boolean[] ; System.out.print( " boolean[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new boolean[1][1] ); if( !res.equals("Z") ){ throw new TestException( "getObjectTypeName(boolean[]) != 'Z' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array boolean[10]" ) ; } System.out.println( " Z : ok " ); // }}} // {{{ byte[] ; System.out.print( " byte[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new byte[1][1] ); if( !res.equals("B") ){ throw new TestException( "getObjectTypeName(byte[]) != 'B' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array byte[10]" ) ; } System.out.println( " B : ok " ); // }}} // {{{ long[] ; System.out.print( " long[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new long[1][1] ); if( !res.equals("J") ){ throw new TestException( "getObjectTypeName(long[]) != 'J' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array long[10]" ) ; } System.out.println( " J : ok " ); // }}} // {{{ short[] ; System.out.print( " short[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new short[1][1] ); if( !res.equals("S") ){ throw new TestException( "getObjectTypeName(short[]) != 'S' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array short[10]" ) ; } System.out.println( " S : ok " ); // }}} // {{{ double[] ; System.out.print( " double[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new double[1][1] ); if( !res.equals("D") ){ throw new TestException( "getObjectTypeName(double[]) != 'D' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array double[10]" ) ; } System.out.println( " D : ok " ); // }}} // {{{ char[] ; System.out.print( " char[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new char[1][1] ); if( !res.equals("C") ){ throw new TestException( "getObjectTypeName(char[]) != 'C' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array char[10]" ) ; } System.out.println( " C : ok " ); // }}} // {{{ float[] ; System.out.print( " float[][]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( new float[1][1] ); if( !res.equals("F") ){ throw new TestException( "getObjectTypeName(float[]) != 'F' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array float[10]" ) ; } System.out.println( " F : ok " ); // }}} // {{{ Object[][] = new Object[10][10] ; Object[][] ob = new Object[10][10] ; System.out.print( " new Object[10][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( ob ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName(Object[][]) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][10][10] ; Object[][][] obj = new Object[10][10][10] ; System.out.print( " new Object[10][10][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][10][10] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][10]" ) ; } System.out.println( " 1000 : ok " ); // }}} // }}} // {{{ zeroes System.out.println( " >> zeroes " ) ; // {{{ int[] o = new int[0] ; int[] o = new int[0] ; System.out.print( " int[] o = new int[0] ;" ) ; try{ res = RJavaArrayTools.getObjectTypeName( o ) ; if( !res.equals("I") ){ throw new TestException( "getObjectTypeName(int[0]) != 'I' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array int[0]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][10][0] ; obj = new Object[10][10][0] ; System.out.print( " new Object[10][10][0]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][10][0] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][10][0]" ) ; } System.out.println( " : ok " ); // }}} // {{{ Object[][] = new Object[10][0][10] ; obj = new Object[10][0][10] ; System.out.print( " new Object[10][0][10]" ) ; try{ res = RJavaArrayTools.getObjectTypeName( obj ) ; if( !res.equals("java.lang.Object") ){ throw new TestException( "getObjectTypeName( Object[10][0][0] ) != 'java.lang.Object' " ); } } catch( NotAnArrayException e){ throw new TestException( "not an array Object[10][0][10]" ) ; } System.out.println( " 0 : ok " ); // }}} // }}} // {{{ Object System.out.println( " >> Object" ) ; System.out.print( " new Double('10.2') " ) ; boolean ok = false; try{ res = RJavaArrayTools.getObjectTypeName( Double.valueOf(10.3) ) ; } catch( NotAnArrayException e){ ok = true ; } if( !ok ){ throw new TestException( "getObjectTypeName(Double) did not throw exception" ); } System.out.println( " -> NotAnArrayException : ok " ); // }}} // {{{ primitives System.out.println( " >> Testing primitive types" ) ; // {{{ int System.out.print( " getObjectTypeName( int )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( int ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ boolean System.out.print( " getObjectTypeName( boolean )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( true ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( boolean ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ byte System.out.print( " getObjectTypeName( byte )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (byte)0 ) ; } catch( NotAnArrayException e){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( byte ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ long System.out.print( " getObjectTypeName( long )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (long)0 ); } catch( NotAnArrayException e){ ok = true; } if( !ok) throw new TestException( " getObjectTypeName( long ) not throwing exception" ); System.out.println( " ok" ) ; // }}} // {{{ short System.out.print( " getObjectTypeName( short )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( (double)0 ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( short ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ double System.out.print( " getObjectTypeName( double )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0.0 ); } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( double ) not throwing exception" ); System.out.println( " : ok" ) ; // }}} // {{{ char System.out.print( " getObjectTypeName( char )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 'a' ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( char ) not throwing exception " ); System.out.println( " : ok" ) ; // }}} // {{{ float System.out.print( " getObjectTypeName( float )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( 0.0f ) ; } catch( NotAnArrayException e ){ ok = true; } if( !ok ) throw new TestException( " getObjectTypeName( float ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} // }}} // {{{ null System.out.print( " getObjectTypeName( null )" ) ; ok = false; try{ RJavaArrayTools.getObjectTypeName( null ) ; } catch( NullPointerException e ){ ok = true; } catch( NotAnArrayException e ){ throw new TestException("getObjectTypeName( null ) throwing wrong kind of exception") ; } if( !ok ) throw new TestException( " getObjectTypeName( null ) not throwing exception " ) ; System.out.println( " : ok" ) ; // }}} } // }}} // {{{ isPrimitiveTypeName private static void isprim() throws TestException{ System.out.print( " isPrimitiveTypeName( 'I' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("I") ) throw new TestException("I not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'Z' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("Z") ) throw new TestException("Z not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'B' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("B") ) throw new TestException("B not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'J' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("J") ) throw new TestException("J not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'S' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("S") ) throw new TestException("S not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'D' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("D") ) throw new TestException("D not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'C' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("C") ) throw new TestException("C not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'F' ) " ) ; if( !RJavaArrayTools.isPrimitiveTypeName("F") ) throw new TestException("F not primitive") ; System.out.println( " true : ok " ); System.out.print( " isPrimitiveTypeName( 'java.lang.Object' ) " ) ; if( RJavaArrayTools.isPrimitiveTypeName("java.lang.Object") ) throw new TestException("Object primitive") ; System.out.println( " false : ok " ); } // }}} // {{{ rep private static void rep() throws TestException{ DummyPoint p = new DummyPoint(10, 10) ; DummyPoint[] res = null; System.out.print( " rep( DummyPoint, 10)" ); try{ res = (DummyPoint[])RJavaArrayTools.rep( p, 10 ); } catch( Throwable e){ throw new TestException( "rep(DummyPoint, 10) failed" ) ; } if( res.length != 10 ){ throw new TestException( "rep(DummyPoint, 10).length != 10" ) ; } if( res[5].getX() != 10.0 ){ throw new TestException( "rep(DummyPoint, 10)[5].getX() != 10" ) ; } System.out.println( ": ok " ); } /// }}} } rJava/inst/java/RectangularArrayExamples.java0000644000175100001440000001275015133274037021053 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Utility class that makes example rectangular java arrays of 2 and 3 dimensions * for all primitive types, String and Point (as an example of array of non primitive object) */ public class RectangularArrayExamples { // {{{ Example 2d rect arrays public static int[][] getIntDoubleRectangularArrayExample(){ int[][] x = new int[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k ; } } return x; } public static boolean[][] getBooleanDoubleRectangularArrayExample(){ boolean[][] x = new boolean[5][2]; boolean current = false; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, current = !current){ x[i][j] = current ; } } return x ; } public static byte[][] getByteDoubleRectangularArrayExample(){ byte[][] x = new byte[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (byte)k ; } } return x; } public static long[][] getLongDoubleRectangularArrayExample(){ long[][] x = new long[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (long)k ; } } return x; } public static short[][] getShortDoubleRectangularArrayExample(){ short[][] x = new short[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (short)k ; } } return x; } public static double[][] getDoubleDoubleRectangularArrayExample(){ double[][] x = new double[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k + 0.0 ; } } return x; } public static char[][] getCharDoubleRectangularArrayExample(){ char[][] x = new char[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = (char)k ; } } return x; } public static float[][] getFloatDoubleRectangularArrayExample(){ float[][] x = new float[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = k + 0.0f ; } } return x; } public static String[][] getStringDoubleRectangularArrayExample(){ String[][] x = new String[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = "" + k ; } } return x; } public static DummyPoint[][] getDummyPointDoubleRectangularArrayExample(){ DummyPoint[][] x = new DummyPoint[5][2]; int k= 0; for( int j=0; j<2; j++){ for( int i=0; i<5; i++, k++){ x[i][j] = new DummyPoint(k,k) ; } } return x; } // }}} // {{{ Example 3d rect arrays public static int[][][] getIntTripleRectangularArrayExample(){ int[][][] x = new int[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = current ; } } } return x; } public static boolean[][][] getBooleanTripleRectangularArrayExample(){ boolean[][][] x = new boolean[5][3][2]; boolean current = false ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current= !current){ x[i][j][k] = current ; } } } return x; } public static byte[][][] getByteTripleRectangularArrayExample(){ byte[][][] x = new byte[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (byte)current ; } } } return x; } public static long[][][] getLongTripleRectangularArrayExample(){ long[][][] x = new long[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (long)current ; } } } return x; } public static short[][][] getShortTripleRectangularArrayExample(){ short[][][] x = new short[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (short)current ; } } } return x; } public static double[][][] getDoubleTripleRectangularArrayExample(){ double[][][] x = new double[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = 0.0 + current ; } } } return x; } public static char[][][] getCharTripleRectangularArrayExample(){ char[][][] x = new char[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = (char)current ; } } } return x; } public static float[][][] getFloatTripleRectangularArrayExample(){ float[][][] x = new float[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = 0.0f + current ; } } } return x; } public static String[][][] getStringTripleRectangularArrayExample(){ String[][][] x = new String[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = ""+current ; } } } return x; } public static DummyPoint[][][] getDummyPointTripleRectangularArrayExample(){ DummyPoint[][][] x = new DummyPoint[5][3][2]; int current = 0 ; for( int k=0; k<2; k++){ for( int j=0; j<3; j++){ for( int i=0; i<5; i++, current++){ x[i][j][k] = new DummyPoint( current, current ) ; } } } return x; } // }}} } rJava/inst/java/RJavaArrayIterator.class0000644000175100001440000000314415133274037020003 0ustar hornikusersÊþº¾2F . / 01 2 3 4 5 6 7 8 9 : ;<=> dimensions[IndIindexdimprodarrayLjava/lang/Object; incrementpositionstartgetArray()Ljava/lang/Object;CodeLineNumberTablegetArrayClassName()Ljava/lang/String; getDimensions()[I()V([I)V StackMapTable(I)VnexthasNext()Z SourceFileRJavaArrayIterator.java  ?@A B  #$       #%C DERJavaArrayIteratorjava/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetNamejava/lang/reflect/Arrayget'(Ljava/lang/Object;I)Ljava/lang/Object;!*´° # *´¶¶°!"*´°#$E*·*µ*µ*µ*µ±  !"#%y*·*+µ*+¾µ*´¤Z**´d¼ µ**´d¼ µ=*´d¢6*´O*´š +.§+.*´d.hO**´.µ „§ÿÆ*µ *µ ±:$% &'(#)/*;+B,^-h*n0s1x2&8ÿ1'ÿ''ÿ ''ú#(( *¼ YO· ± 4 5)”*´L=*´¾¢=+*´.¸ Lš**´.µ §*Y´ *´.*´d.h`µ „§ÿÀ*´¾d=›5*´.`*´.  *´O§*´*´.`O§ „ÿ§ÿÍ*Y´ `µ +°>:;<=>,@D;JEVFgGqIJ‚EˆN’O&ý$úüú*+4*´ *´ ¢§¬S&@,-rJava/inst/java/RJavaArrayTools.class0000644000175100001440000004064215133274037017316 0ustar hornikusersÊþº¾2+ 9: 9£ •; <=> —;? @;¨ A;B C;¦ ’;D E;F G; H 1IJ K 1LMN ÂOP ÂQR STUVWXYZ[ (9 (\ (] Š^ (_ Š` <a <bc 1d Še Âf Âg Âh Šij 8k 8lmn ;S 1o pq pr Šs pt pu pv pw px py pz p{ Š| Š} Š~ РЀ Š Š‚ Šƒ Š„… S† p‡ pˆ p‰ pŠ p‹ pŒ p pŽ p Š Š‘ Š’ Š“ Š” Š• Š– Š— Š˜ Š™š h9 h h› hœ pž hŸ  1¡¢ rK Š£ ¤¥ ¦§ ¨ © hª« Ь ­ ®¯ ° 1±² ³ 1´µ L ¶ 1· Џ ’¹º€ •» —¼ ’½ÿ÷ÿÿÿÿÿÿ о¿ ŠÀ ’Á •ÃÄ —Å ŠÆð¢ ’ÇÈArrayDimensionMismatchException InnerClassesprimitiveClassesLjava/util/Map; NA_INTEGERI ConstantValueNA_REALDNA_bitsJ()VCodeLineNumberTableinitPrimitiveClasses()Ljava/util/Map;getObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String; StackMapTable Exceptions(I)I(Z)I(B)I(J)I(S)I(D)I(C)I(F)ImakeArraySignature'(Ljava/lang/String;I)Ljava/lang/String;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;ÉisSingleDimensionArray(Ljava/lang/Object;)ZÊisPrimitiveTypeName(Ljava/lang/String;)ZisRectangularArray Deprecated(I)Z(Z)Z(B)Z(J)Z(S)Z(D)Z(C)Z(F)ZgetDimensionLength(Ljava/lang/Object;)I getDimensions(Ljava/lang/Object;)[IË(I)[I(Z)[I(B)[I(J)[I(S)[I(D)[I(C)[I(F)[I getTrueLengthisArrayget((Ljava/lang/Object;[I)Ljava/lang/Object;getInt(Ljava/lang/Object;[I)I getBoolean(Ljava/lang/Object;[I)ZgetByte(Ljava/lang/Object;[I)BgetLong(Ljava/lang/Object;[I)JgetShort(Ljava/lang/Object;[I)S getDouble(Ljava/lang/Object;[I)DgetChar(Ljava/lang/Object;[I)CgetFloat(Ljava/lang/Object;[I)F'(Ljava/lang/Object;I)Ljava/lang/Object;(Ljava/lang/Object;I)I(Ljava/lang/Object;I)Z(Ljava/lang/Object;I)B(Ljava/lang/Object;I)J(Ljava/lang/Object;I)S(Ljava/lang/Object;I)D(Ljava/lang/Object;I)C(Ljava/lang/Object;I)FcheckDimensions(Ljava/lang/Object;[I)Vset)(Ljava/lang/Object;[ILjava/lang/Object;)V(Ljava/lang/Object;[II)V(Ljava/lang/Object;[IZ)V(Ljava/lang/Object;[IB)V(Ljava/lang/Object;[IJ)V(Ljava/lang/Object;[IS)V(Ljava/lang/Object;[ID)V(Ljava/lang/Object;[IC)V(Ljava/lang/Object;[IF)V((Ljava/lang/Object;ILjava/lang/Object;)V(Ljava/lang/Object;II)V(Ljava/lang/Object;IZ)V(Ljava/lang/Object;IB)V(Ljava/lang/Object;IJ)V(Ljava/lang/Object;IS)V(Ljava/lang/Object;ID)V(Ljava/lang/Object;IC)V(Ljava/lang/Object;IF)VgetArrayunique(([Ljava/lang/Object;)[Ljava/lang/Object;Ì duplicated([Ljava/lang/Object;)[Z anyDuplicated([Ljava/lang/Object;)Isort)([Ljava/lang/Object;Z)[Ljava/lang/Object;revcopygetIterableContent)(Ljava/lang/Iterable;)[Ljava/lang/Object;Írep((Ljava/lang/Object;I)[Ljava/lang/Object;ÎgetCloneMethod-(Ljava/lang/Class;)Ljava/lang/reflect/Method;Ï cloneObject&(Ljava/lang/Object;)Ljava/lang/Object; unboxDoubles([Ljava/lang/Double;)[DÐÑ unboxIntegers([Ljava/lang/Integer;)[IÒ unboxBooleans([Ljava/lang/Boolean;)[IÓisNA boxDoubles([D)[Ljava/lang/Double; boxIntegers([I)[Ljava/lang/Integer; boxBooleans([I)[Ljava/lang/Boolean; SourceFileRJavaArrayTools.java ©ªjava/util/HashMap ÔÕÖ ×ØZBÙÚSÛCÜFÝ Þß ÝàNotAnArrayException ©á âã\[+L? äå; æçprimitive type : int ©èprimitive type : boolean primitive type : byte primitive type : long primitive type : short primitive type : double primitive type : char primitive type : float java/lang/StringBuffer éê éë ÃÄ ìã  ¡ íÁ Þ$java/lang/Class îï ÝÁ ð³ ñò óÁ ÏÐ ArrayWrapper ©ô õàjava/lang/NullPointerException array is null öß÷ øÐ Þð ß àñ âò äó æô èõ êö ì÷ îø Þß àá âã äå æç èé êë ìí îï/RJavaArrayTools$ArrayDimensionMismatchException ©ù û ú û ü ý þ ÿ   ûü ûý ûþ ûÿ û û û û û ùújava/util/Vector Á ò [Ljava/lang/Object; java/lang/Comparable NotComparableException      à  java/lang/Cloneable  ! à java/lang/Throwable  $+java/lang/reflect/InvocationTargetException  clone  ß ¥¦  RJavaArrayTools !ò "à #$ §¨java/lang/Double /Ì %&java/lang/Integer %'java/lang/Boolean %( ­® )*java/lang/Object java/lang/ClassNotFoundExceptionjava/lang/String[I[Zjava/util/Iteratorjava/lang/reflect/Methodjava/lang/reflect/Method;[D[Ljava/lang/Double;[Ljava/lang/Integer;[Ljava/lang/Boolean;TYPELjava/lang/Class; java/util/Mapput8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;java/lang/Bytejava/lang/Longjava/lang/Shortjava/lang/Characterjava/lang/FloatgetClass()Ljava/lang/Class;()Z(Ljava/lang/Class;)VgetName()Ljava/lang/String; replaceFirst8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;replaceD(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;(Ljava/lang/String;)Vappend(C)Ljava/lang/StringBuffer;,(Ljava/lang/String;)Ljava/lang/StringBuffer;toString containsKeyforName=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; lastIndexOflength()Iequals(Ljava/lang/Object;)V isRectangulargetComponentTypejava/lang/reflect/Array getLength(II)VsetInt setBooleansetBytesetLongsetShort setDoublesetCharsetFloataddsize newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;toArrayisAssignableFrom(Ljava/lang/Class;)Zjava/util/Arrays([Ljava/lang/Object;)Vjava/lang/Iterableiterator()Ljava/util/Iterator;hasNextnext()Ljava/lang/Object;()[Ljava/lang/Object; isAccessible setAccessible(Z)Vinvoke9(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;castgetCause()Ljava/lang/Throwable;getDeclaredMethods()[Ljava/lang/reflect/Method;getParameterTypes()[Ljava/lang/Class; getSuperclass doubleValue()DintValue booleanValuedoubleToRawLongBits(D)JvalueOf(D)Ljava/lang/Double;(I)Ljava/lang/Integer;(Z)Ljava/lang/Boolean;longBitsToDouble(J)D!Š  ¡¢£¤‹¥¦§¨t©ª«*·±¬ ­®«¦j»Y·K*²¹W*²¹W* ² ¹W* ² ¹W* ²¹W*²¹W*²¹W*²¹W*°¬* %&' (,)8*D+P,\-h. ¯°«\**¶L+¶š »Y+·¿+¶M,¶¶°¬9:<=±ü1² ¯³«" »Y· ¿¬?² ¯´«" »Y!· ¿¬@² ¯µ«" »Y"· ¿¬A² ¯¶«" »Y#· ¿¬B² ¯·«" »Y$· ¿¬C² ¯¸«" »Y%· ¿¬D² ¯¹«" »Y&· ¿¬E² ¯º«" »Y'· ¿¬F² »¼«|5»(Y·)M>¢,[¶*W„§ÿñ,*¶+W*¸,š ,;¶*W,¶-°¬"LMNMP"Q)R0T± ý (ú ½¾«I ².*¹/™².*¹0À1°*+¸2°¬Z []±²¿ ÀÁ«[(*¸3š»Y*¶·¿*¶¶L+[¶4™¬¬¬cef&g± ü² ÃÄ«±d*¶5¤¬*¶6™¬*¶6™¬* ¶6™¬* ¶6™¬* ¶6™¬*¶6™¬*¶6™¬*¶6™¬¬¬* m no p+q6rAsLtWubv± ÅÁ«)*¸3š¬<*¸7 ¬»8Y*·9¶:<§M<¬ $!$¬"‚ ƒ …†!‰$‡%ˆ'б  ü NÆ ÅÇ«¬¬ ÅÈ«¬¬ ÅÉ«¬¬‘ ÅÊ«¬¬’ ÅË«¬¬“ ÅÌ«¬¬” ÅÍ«¬¬• ÅΫ¬¬– ÏЫ9*Ç »;Y<·=¿*¶L+¶š »Y+·¿=+¶™„+¶>L§ÿñ¬¬"¢£¤#¥%¦,§/¨7ª±ü1ü²; ϳ«" »Y· ¿¬­² Ï´«" »Y!· ¿¬®² ϵ«" »Y"· ¿¬¯² ϶«" »Y#· ¿¬°² Ï·«" »Y$· ¿¬±² ϸ«" »Y%· ¿¬²² Ϲ«" »Y&· ¿¬³² Ϻ«" »Y'· ¿¬´² ÑÒ«v*Ç »;Y<·=¿*¶L+¶š »Y+·¿*M*¸7>¼ :6+¶™),¸?6O„š§,¸@M+¶>L§ÿÖ¾¢O„§ÿï°¬NÀÂÃ#Ä%Æ*Ç/È2Ê9Ë?ÌFÍIÎNÏQÑWÒ_ÙgÚmÛsݱ&ü1ÿ1Óüú ²; ÑÔ«" »Y· ¿¬à² ÑÕ«" »Y!· ¿¬á² ÑÖ«" »Y"· ¿¬â² Ñ׫" »Y#· ¿¬ã² ÑØ«" »Y$· ¿¬ä² ÑÙ«" »Y%· ¿¬å² ÑÚ«" »Y&· ¿¬æ² ÑÛ«" »Y'· ¿¬ç² ÜЫ²Q*Ç »;Y<·=¿*¶L+¶š »Y+·¿*M>6+¶™!,¸?h>š¬„,¸@M+¶>L§ÿÞ¬¬6 óõö#÷%ù'ú*û1ü8ý>þAÿGO±ü1þ²; ܳ«" »Y· ¿¬² Ü´«" »Y!· ¿¬² ܵ«" »Y"· ¿¬² ܶ«" »Y#· ¿¬² Ü·«" »Y$· ¿¬ ² ܸ«" »Y%· ¿¬ ² ܹ«" »Y&· ¿¬ ² ܺ«" »Y'· ¿¬ ² ÝÁ«3*Ǭ*¶¶¬¬ ±Æ ÝÇ«¬¬ ÝÈ«¬¬ ÝÉ«¬¬ ÝÊ«¬¬ ÝË«¬¬ ÝÌ«¬¬! ÝÍ«¬¬" ÝΫ¬¬# Þß«'*+¸A++¾d.¸@°¬6²S àá«'*+¸A++¾d.¸B¬¬:²S âã«'*+¸A++¾d.¸C¬¬=²S äå«'*+¸A++¾d.¸D¬¬@²S æç«'*+¸A++¾d.¸E­¬C²S èé«'*+¸A++¾d.¸F¬¬F²S êë«'*+¸A++¾d.¸G¯¬I²S ìí«'*+¸A++¾d.¸H¬¬L²S îï«'*+¸A++¾d.¸I®¬O²S Þð«$ *¼ YO¸J°¬T²S àñ«$ *¼ YO¸K¬¬W²S âò«$ *¼ YO¸L¬¬Z²S äó«$ *¼ YO¸M¬¬]²S æô«$ *¼ YO¸N­¬`²S èõ«$ *¼ YO¸O¬¬c²S êö«$ *¼ YO¸P¯¬f²S ì÷«$ *¼ YO¸Q¬¬i²S îø«$ *¼ YO¸R®¬l²S ùú«M+¾=*¸7>¤ »SY·T¿±¬pqr su±ý²S ûü«,*+¸A++¾d.,¸U±¬ …†²S ûý«,*+¸A++¾d.¸V±¬ Š‹²S ûþ«,*+¸A++¾d.¸W±¬ ޲S ûÿ«,*+¸A++¾d.¸X±¬ ‘²S û«,*+¸A++¾d. ¸Y±¬ “”²S û«,*+¸A++¾d.¸Z±¬ –—²S û«,*+¸A++¾d.(¸[±¬ ™š²S û«,*+¸A++¾d.¸\±¬ œ²S û«,*+¸A++¾d.$¸]±¬ Ÿ ²S û«) *¼ YO,¸^±¬ ¤ ¥²S û«) *¼ YO¸_±¬ § ¨²S û«) *¼ YO¸`±¬ ª «²S û«) *¼ YO¸a±¬ ­ ®²S û «) *¼ YO ¸b±¬ ° ±²S û «) *¼ YO¸c±¬ ³ ´²S û «) *¼ YO(¸d±¬ ¶ ·²S û «) *¼ YO¸e±¬ ¹ º²S û «) *¼ YO$¸f±¬ ¼ ½²S ß«t+*+¸g+¾=*N6¤d¢-+.¸@N„§ÿì-°¬& ÂÃÅ Æ ÇÈÉ#Ê)ͱ þ²S «e £*¾<*¾¼M>*¾¢ ,T„§ÿó»hY·iN6¢^,3š§N*2:6`6¢9*2:,3™&¶j™š,T-¶kW6,T„§ÿÇ„§ÿ¢*¶¶>-¶l¸mÀn:-¶oW°¬^ØÙÚÛÚÞ"à+á5â;ã>åJæPçaèfékêrëuízå€à†ó™ô õ±L þ úþ hÿnhü0úÿnhù «Úd*¾<*¾¼M>*¾¢ ,T„§ÿó>¢D,3™§5*2:`6¢%*2:,3š¶j™,T„§ÿÛ„§ÿ½,°¬>ûüýþý!*/:@QV\b ± þ úü ý !ùú «9*¾<=¢0*2N`6¢*2:-¶j™¬„§ÿå„§ÿѬ¬*  (+17 ±ýý ùú «×i*¶¶>Mp,¶q™ »rY,·s¿*¾>*¸t:¸uš°¾l66¢)2:dd2SddS„§ÿÖ°¬>/0134#5(7,8/;6<@=G>U?`<fB±ü1ýnþ ø,²r «j+*¾<*¶¶>¸mÀnM>¢,dd*2S„§ÿî,°¬NOPQ#P)S± þnú «f'*¾<*¶¶>¸mÀnM>¢,*2S„§ÿò,°¬YZ[\[%^± þnú «e+»hY·iL*¹vM,¹w™+,¹x¶kW§ÿì+¶y°¬defg&i± ýh «N„*¶¸mÀnM*Ázš,°*¶¸{N-¶|6š-¶}§:66¢!*¶-*Àn¶¶€:,S„§ÿßš$-¶}§:¶‚¿:š -¶}¿,°(-0~5\j5\rjtr¬Zu vwz{#|(~-02€5…>†P‡V…\Œaj‰lŠrŒyŽ‚±8 ünÿn~üú#MG~þ ~ø²~  !««=M*Æ8*¶ƒL>+¾¢#+2M„,¶…¶6™ ,¶†¾š,°„§ÿÝ*¶‡K§ÿʰ¬* ”•– —˜™+š-—3;Ÿ±,ýÿ 1"úÿ1 #$«S*¶¸{L+¶|=š+¶}§N=N*¶+*Àn¶¶€Nš!+¶}§:¶‚¿:š+¶}¿-°~/;/C;EC¬F¥¦ §©¬ª«¯²/¶3·;³=´C¶I·N¸Qº±6ÿ~ÿG~ý ~ù²~ %&«”3*ǰ<*¾=¼N<¢-*2Ç ²ˆ§ *2¶‰R„§ÿã-°¬ÄÅ ÆÇ1ȱ3þ 'ÿ(''ÿ('' )*«“2*ǰ<*¾=¼ N<¢-*2Ç‹§ *2¶ŒO„§ÿä-°¬ÌÍ ÎÏ0б3þ Óÿ+ÓÓÿ+ÓÓ ,-«®:*ǰ<*¾=¼ N<¢%-*2Ç‹§*2¶™§O„§ÿÜ-°¬ÔÕ Ö×8رFþ Óÿ.ÓÓÿ .ÓÓÿ.ÓÓ /Ì«<&¸Ž²‘”š§¬¬Þ±@ 01«l1*ǰ<*¾=½’N<¢*1¸“š -*1¸”S„§ÿæ-°¬âã äå/æ± þ ( 23«k0*ǰ<*¾=½•N<¢*.‹Ÿ -*.¸–S„§ÿç-°¬êë ìí.î± þ + 45«š8*ǰ<*¾=½—N<¢"*.‹Ÿ-*.š§¸˜S„§ÿß-°¬òó ôõ6ö±4þ .ÿÓ..ÿÓ..6ª«<¸™³.š¸œ³ˆš¸œ¸Ž³‘±¬#ÀÁ78Ÿ SŠž rJava/inst/java/RectangularArrayBuilder.java0000644000175100001440000001462515133274037020666 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Array ; /** * Builds rectangular java arrays */ public class RectangularArrayBuilder extends RJavaArrayIterator { // {{{ constructors /** * constructor * * @param payload one dimensional array * @param dimensions target dimensions * @throws NotAnArrayException if payload is not an array */ public RectangularArrayBuilder( Object payload, int[] dimensions) throws NotAnArrayException, ArrayDimensionException { super( dimensions ) ; if( !RJavaArrayTools.isArray(payload) ){ throw new NotAnArrayException( payload.getClass() ) ; } if( !RJavaArrayTools.isSingleDimensionArray(payload)){ throw new ArrayDimensionException( "not a single dimension array : " + payload.getClass() ) ; } if( dimensions.length == 1 ){ array = payload ; } else{ String typeName = RJavaArrayTools.getObjectTypeName( payload ); Class clazz = null ; try{ clazz = RJavaArrayTools.getClassForSignature( typeName, payload.getClass().getClassLoader() ); } catch( ClassNotFoundException e){/* should not happen */} array = Array.newInstance( clazz , dimensions ) ; if( typeName.equals( "I" ) ){ fill_int( (int[])payload ) ; } else if( typeName.equals( "Z" ) ){ fill_boolean( (boolean[])payload ) ; } else if( typeName.equals( "B" ) ){ fill_byte( (byte[])payload ) ; } else if( typeName.equals( "J" ) ){ fill_long( (long[])payload ) ; } else if( typeName.equals( "S" ) ){ fill_short( (short[])payload ) ; } else if( typeName.equals( "D" ) ){ fill_double( (double[])payload ) ; } else if( typeName.equals( "C" ) ){ fill_char( (char[])payload ) ; } else if( typeName.equals( "F" ) ){ fill_float( (float[])payload ) ; } else{ fill_Object( (Object[])payload ) ; } } } public RectangularArrayBuilder( Object payload, int length ) throws NotAnArrayException, ArrayDimensionException{ this( payload, new int[]{ length } ) ; } // java < 1.5 kept happy public RectangularArrayBuilder(int x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public RectangularArrayBuilder(boolean x, int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public RectangularArrayBuilder(byte x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public RectangularArrayBuilder(long x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public RectangularArrayBuilder(short x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public RectangularArrayBuilder(double x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public RectangularArrayBuilder(char x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public RectangularArrayBuilder(float x , int[] dim ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } public RectangularArrayBuilder(int x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public RectangularArrayBuilder(boolean x, int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public RectangularArrayBuilder(byte x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public RectangularArrayBuilder(long x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public RectangularArrayBuilder(short x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public RectangularArrayBuilder(double x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public RectangularArrayBuilder(char x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public RectangularArrayBuilder(float x , int length ) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ fill_** private void fill_int( int[] payload ){ int k; while( hasNext() ){ int[] current = (int[])next() ; k = start ; for( int j=0; jinstances of the Number interface are treated specially, in order to * allow comparing Numbers of different classes, for example it is allowed * to compare a Double with an Integer. if the Numbers have the same class, * they are compared normally, otherwise they are first converted to Doubles * and then compared

* * @param a an object * @param b another object * * @return the result of a.compareTo(b) if this makes sense * @throws NotComparableException if the two objects are not comparable */ public static int compare( Object a, Object b ) throws NotComparableException{ int res ; if( a.equals( b ) ) return 0 ; // treat Number s separately if( a instanceof Number && b instanceof Number && !( a.getClass() == b.getClass() ) ){ Double _a = Double.valueOf( ((Number)a).doubleValue() ); Double _b = Double.valueOf( ((Number)b).doubleValue() ); return _a.compareTo( _b ); } if( ! ( a instanceof Comparable ) ) throw new NotComparableException( a ); if( ! ( b instanceof Comparable ) ) throw new NotComparableException( b ); try{ res = ( (Comparable)a ).compareTo( b ) ; } catch( ClassCastException e){ try{ res = - ((Comparable)b).compareTo( a ) ; } catch( ClassCastException f){ throw new NotComparableException( a, b ); } } return res ; } } rJava/inst/java/NotComparableException.java0000644000175100001440000000132515133274037020507 0ustar hornikusers/** * Exception generated when two objects cannot be compared * * Such cases happen when an object does not implement the Comparable * interface or when the comparison produces a ClassCastException */ public class NotComparableException extends Exception{ public NotComparableException(Object a, Object b){ super( "objects of class " + a.getClass().getName() + " and " + b.getClass().getName() + " are not comparable" ) ; } public NotComparableException( Object o){ this( o.getClass().getName() ) ; } public NotComparableException( Class cl){ this( cl.getName() ) ; } public NotComparableException( String type ){ super( "class " + type + " does not implement java.util.Comparable" ) ; } } rJava/inst/java/PrimitiveArrayException.class0000644000175100001440000000074415133274037021120 0ustar hornikusersÊþº¾2    (Ljava/lang/String;)VCodeLineNumberTable SourceFilePrimitiveArrayException.javajava/lang/StringBuilder :cannot convert to single dimension array of primitive type   PrimitiveArrayExceptionjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;!  4*»Y·¶+¶¶·±  rJava/inst/java/NotAnArrayException.class0000644000175100001440000000104415133274037020161 0ustar hornikusersÊþº¾2"     (Ljava/lang/Class;)VCodeLineNumberTable(Ljava/lang/String;)V SourceFileNotAnArrayException.javajava/lang/StringBuilder not an array :   ! NotAnArrayExceptionjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;java/lang/ClassgetName()Ljava/lang/String;toString!   7*»Y·¶+¶¶¶·±   "*+·±   rJava/inst/java/RectangularArrayBuilder.class0000644000175100001440000001170315133274037021044 0ustar hornikusersÊþº¾2Ò @o pqr Fs t puvw xy z { | } ?~ p H€ p‚ ƒ„… G†‡ ?ˆ‰Š ?‹Œ ?Ž ?‘’“ ?”•– ?—˜™ ?š›œ ?ž ?Ÿ ?  @x¡ }¢£¤¥¦§¨ ?© ?ª ?« ?¬­®(Ljava/lang/Object;[I)VCodeLineNumberTable StackMapTable¯°± Exceptions(Ljava/lang/Object;I)V(I[I)V(Z[I)V(B[I)V(J[I)V(S[I)V(D[I)V(C[I)V(F[I)V(II)V(ZI)V(BI)V(JI)V(SI)V(DI)V(CI)V(FI)Vfill_int([I)V fill_boolean([Z)V fill_byte([B)V fill_long([J)V fill_short([S)V fill_double([D)V fill_char([C)V fill_float([F)V fill_Object([Ljava/lang/Object;)V SourceFileRectangularArrayBuilder.java A\² ³´NotAnArrayException µ¶ A· ¸´ArrayDimensionExceptionjava/lang/StringBuilder A¹not a single dimension array : º» º¼ ½¾ A¿ ÀÁ Âà ÄÅ ÆÇ java/lang/ClassNotFoundExceptionÈ ÉÊI Ë´[I [\Z[Z ]^B[B _`J[J abS[S cdD[D efC[C ghF[F ij[Ljava/lang/Object; kl ABprimitive type : int primitive type : boolean primitive type : byte primitive type : long primitive type : short primitive type : double primitive type : char primitive type : float ÌÍ ÎÏ Ð… Ñ…RectangularArrayBuilderRJavaArrayIteratorjava/lang/Objectjava/lang/Stringjava/lang/ClassRJavaArrayToolsisArray(Ljava/lang/Object;)ZgetClass()Ljava/lang/Class;(Ljava/lang/Class;)VisSingleDimensionArray()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;-(Ljava/lang/Object;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;(Ljava/lang/String;)VarrayLjava/lang/Object;getObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;getClassLoader()Ljava/lang/ClassLoader;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;java/lang/reflect/Array newInstance'(Ljava/lang/Class;[I)Ljava/lang/Object;equalshasNext()Znext()Ljava/lang/Object;start increment!?@ABCë*,·+¸š»Y+¶·¿+¸š!»Y»Y·  ¶ +¶¶ ¶ ·¿,¾  *+µ§Ï+¸N:-+¶¶¸:§:*,¸µ-¶™*+À·§—-¶™*+À·§ƒ-¶™*+À·§o-¶™*+À ·!§[-"¶™*+À#·$§G-%¶™*+À&·'§3-(¶™*+À)·*§-+¶™*+À,·-§ *+À.·/±S`cDz =CK P!S#`$e&o'x(ƒ)Œ*—+ ,«-´.¿/È0Ó1Ü2ç3ð4û568<E9ÿ?F$ ÿ?FGHùIAJC) *+¼ YO·0±D > ?IAKC&*·1»Y2·3¿DBIALC&*·1»Y4·3¿DCIAMC&*·1»Y5·3¿DDIANC&*·1»Y6·3¿DEIAOC&*·1»Y7·3¿DFIAPC&*·1»Y8·3¿DGIAQC&*·1»Y9·3¿DHIARC&*·1»Y:·3¿DIIASC&*·1»Y2·3¿DKIATC&*·1»Y4·3¿DLIAUC&*·1»Y5·3¿DMIAVC&*·1»Y6·3¿DNIAWC&*·1»Y7·3¿DOIAXC&*·1»Y8·3¿DPIAYC&*·1»Y9·3¿DQIAZC&*·1»Y:·3¿DRI[\C6*¶;™1*¶<ÀN*´==6-¾¢-+.O„*´>`=§ÿè§ÿαD"XYZ[\%[2^5_Eþùú]^C6*¶;™1*¶<ÀN*´==6-¾¢-+3T„*´>`=§ÿè§ÿαD"cdefg%f2i5jEþùú_`C6*¶;™1*¶<ÀN*´==6-¾¢-+3T„*´>`=§ÿè§ÿαD"nopqr%q2t5uEþùúabC6*¶;™1*¶<À N*´==6-¾¢-+/P„*´>`=§ÿè§ÿαD"yz{|}%|25€Eþ ùúcdC6*¶;™1*¶<À#N*´==6-¾¢-+5V„*´>`=§ÿè§ÿαD"„…†‡ˆ%‡2Š5‹Eþ#ùúefC6*¶;™1*¶<À&N*´==6-¾¢-+1R„*´>`=§ÿè§ÿαD"‘’“%’2•5–Eþ&ùúghC6*¶;™1*¶<À)N*´==6-¾¢-+4U„*´>`=§ÿè§ÿαD"š›œž%2 5¡Eþ)ùúijC6*¶;™1*¶<À,N*´==6-¾¢-+0Q„*´>`=§ÿè§ÿαD"¥¦§¨©%¨2«5¬Eþ,ùúklC6*¶;™1*¶<À.N*´==6-¾¢-+2S„*´>`=§ÿè§ÿαD"°±²³´%³2¶5·Eþ.ùúmnrJava/inst/java/FlatException.class0000644000175100001440000000042215133274037017030 0ustar hornikusersÊþº¾2   ()VCodeLineNumberTable SourceFileFlatException.java#Can only flatten rectangular arrays  FlatExceptionjava/lang/Exception(Ljava/lang/String;)V!#*·±   rJava/inst/java/ObjectArrayException.class0000644000175100001440000000070115133274037020347 0ustar hornikusersÊþº¾2    (Ljava/lang/String;)VCodeLineNumberTable SourceFileObjectArrayException.javajava/lang/StringBuilder array is of primitive type :   ObjectArrayExceptionjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;toString()Ljava/lang/String;!  4*»Y·¶+¶¶·±  rJava/inst/java/ArrayDimensionException.java0000644000175100001440000000020415133274037020700 0ustar hornikuserspublic class ArrayDimensionException extends Exception{ public ArrayDimensionException(String message){ super( message ) ; } } rJava/inst/java/ArrayWrapper_Test.java0000644000175100001440000013225415133274037017526 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Test suite for ArrayWrapper */ public class ArrayWrapper_Test { // {{{ main public static void main(String[] args ){ try{ runtests() ; } catch( TestException e){ e.printStackTrace(); System.exit(1); } System.out.println( "\nALL PASSED\n" ) ; System.exit( 0 ); } // }}} // {{{ runtests public static void runtests() throws TestException { // {{{ multi dim array of primitives // {{{ flat_int System.out.println( "flatten int[]" ); flatten_int_1(); System.out.println( "PASSED" ); System.out.println( "flatten int[][]" ); flatten_int_2(); System.out.println( "PASSED" ); System.out.println( "flatten int[][][]" ); flatten_int_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_boolean System.out.println( "flatten boolean[]" ); flatten_boolean_1(); System.out.println( "PASSED" ); System.out.println( "flatten boolean[][]" ); flatten_boolean_2(); System.out.println( "PASSED" ); System.out.println( "flatten boolean[][][]" ); flatten_boolean_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_byte System.out.println( "flatten byte[]" ); flatten_byte_1(); System.out.println( "PASSED" ); System.out.println( "flatten byte[][]" ); flatten_byte_2(); System.out.println( "PASSED" ); System.out.println( "flatten byte[][][]" ); flatten_byte_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_long System.out.println( "flatten long[]" ); flatten_long_1(); System.out.println( "PASSED" ); System.out.println( "flatten long[][]" ); flatten_long_2(); System.out.println( "PASSED" ); System.out.println( "flatten long[][][]" ); flatten_long_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_long System.out.println( "flatten short[]" ); flatten_short_1(); System.out.println( "PASSED" ); System.out.println( "flatten short[][]" ); flatten_short_2(); System.out.println( "PASSED" ); System.out.println( "flatten short[][][]" ); flatten_short_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_double System.out.println( "flatten double[]" ); flatten_double_1(); System.out.println( "PASSED" ); System.out.println( "flatten double[][]" ); flatten_double_2(); System.out.println( "PASSED" ); System.out.println( "flatten double[][][]" ); flatten_double_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_char System.out.println( "flatten char[]" ); flatten_char_1(); System.out.println( "PASSED" ); System.out.println( "flatten char[][]" ); flatten_char_2(); System.out.println( "PASSED" ); System.out.println( "flatten char[][][]" ); flatten_char_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_float System.out.println( "flatten float[]" ); flatten_float_1(); System.out.println( "PASSED" ); System.out.println( "flatten float[][]" ); flatten_float_2(); System.out.println( "PASSED" ); System.out.println( "flatten float[][][]" ); flatten_float_3(); System.out.println( "PASSED" ); // }}} // }}} // {{{ multi dim array of Object // {{{ flat_String System.out.println( "flatten String[]" ); flatten_String_1(); System.out.println( "PASSED" ); System.out.println( "flatten String[][]" ); flatten_String_2(); System.out.println( "PASSED" ); System.out.println( "flatten String[][][]" ); flatten_String_3(); System.out.println( "PASSED" ); // }}} // {{{ flat_String System.out.println( "flatten Point[]" ); flatten_Point_1(); System.out.println( "PASSED" ); System.out.println( "flatten Point[][]" ); flatten_Point_2(); System.out.println( "PASSED" ); System.out.println( "flatten Point[][][]" ); flatten_Point_3(); System.out.println( "PASSED" ); // }}} // }}} } //}}} // {{{ flat multi dimen array of java primitives // {{{ flatten_int_1 private static void flatten_int_1() throws TestException{ int[] o = new int[5] ; for( int i=0;i<5;i++) o[i] = i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_int_2 private static void flatten_int_2() throws TestException{ int[][] o = RectangularArrayExamples.getIntDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[][]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_int_3 private static void flatten_int_3() throws TestException{ int[][][] o = RectangularArrayExamples.getIntTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( int[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(int[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(int[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("I") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'I'" ) ; } System.out.println( " I : ok" ); System.out.print( " >> flat_int()" ) ; int[] flat; try{ flat = wrapper.flat_int() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_1 private static void flatten_boolean_1() throws TestException{ boolean[] o = new boolean[5] ; boolean current = false; for( int i=0;i<5;i++){ o[i] = current ; current = !current ; } ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(boolean[]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(int[]) >> FlatException") ; } current = false ; for( int i=0; i<5; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_2 private static void flatten_boolean_2() throws TestException{ boolean[][] o = RectangularArrayExamples.getBooleanDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(boolean[][]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(boolean[][]) >> FlatException") ; } boolean current = false ; for( int i=0; i<10; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_boolean_3 private static void flatten_boolean_3() throws TestException{ boolean[][][] o = RectangularArrayExamples.getBooleanTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( boolean[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(boolean[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(boolean[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("Z") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'Z'" ) ; } System.out.println( " Z : ok" ); System.out.print( " >> flat_boolean()" ) ; boolean[] flat; try{ flat = wrapper.flat_boolean() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(boolean[][][]) >> FlatException") ; } boolean current = false ; for( int i=0; i<30; i++){ if( flat[i] != current ) throw new TestException( "flat[" + i + "] = " + flat [i] ); current = !current ; } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_1 private static void flatten_byte_1() throws TestException{ byte[] o = new byte[5] ; for( int i=0;i<5;i++) o[i] = (byte)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(byte[]).getObjectTypeName() != 'I'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_2 private static void flatten_byte_2() throws TestException{ byte[][] o = RectangularArrayExamples.getByteDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(byte[][]).getObjectTypeName() != 'B'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_byte_3 private static void flatten_byte_3() throws TestException{ byte[][][] o = RectangularArrayExamples.getByteTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( byte[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(byte[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(byte[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("B") ){ throw new TestException( "ArrayWrapper(int[][][]).getObjectTypeName() != 'B'" ) ; } System.out.println( " B : ok" ); System.out.print( " >> flat_byte()" ) ; byte[] flat; try{ flat = wrapper.flat_byte() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(byte[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (byte)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_1 private static void flatten_long_1() throws TestException{ long[] o = new long[5] ; for( int i=0;i<5;i++) o[i] = (long)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_2 private static void flatten_long_2() throws TestException{ long[][] o = RectangularArrayExamples.getLongDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[][]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_long_3 private static void flatten_long_3() throws TestException{ long[][][] o = RectangularArrayExamples.getLongTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( long[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(long[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(long[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("J") ){ throw new TestException( "ArrayWrapper(long[][][]).getObjectTypeName() != 'J'" ) ; } System.out.println( " J : ok" ); System.out.print( " >> flat_long()" ) ; long[] flat; try{ flat = wrapper.flat_long() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(long[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (long)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_1 private static void flatten_short_1() throws TestException{ short[] o = new short[5] ; for( int i=0;i<5;i++) o[i] = (short)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(long[]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_2 private static void flatten_short_2() throws TestException{ short[][] o = RectangularArrayExamples.getShortDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(short[][]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_short_3 private static void flatten_short_3() throws TestException{ short[][][] o = RectangularArrayExamples.getShortTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( short[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(short[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(short[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("S") ){ throw new TestException( "ArrayWrapper(short[][][]).getObjectTypeName() != 'S'" ) ; } System.out.println( " S : ok" ); System.out.print( " >> flat_short()" ) ; short[] flat; try{ flat = wrapper.flat_short() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(short[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (double)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_1 private static void flatten_double_1() throws TestException{ double[] o = new double[5] ; for( int i=0;i<5;i++) o[i] = i+0.0 ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_2 private static void flatten_double_2() throws TestException{ double[][] o = RectangularArrayExamples.getDoubleDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[][]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_double_3 private static void flatten_double_3() throws TestException{ double[][][] o = RectangularArrayExamples.getDoubleTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( double[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(double[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(double[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("D") ){ throw new TestException( "ArrayWrapper(double[][][]).getObjectTypeName() != 'D'" ) ; } System.out.println( " D : ok" ); System.out.print( " >> flat_double()" ) ; double[] flat; try{ flat = wrapper.flat_double() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(double[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_1 private static void flatten_char_1() throws TestException{ char[] o = new char[5] ; for( int i=0;i<5;i++) o[i] = (char)i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (char)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_2 private static void flatten_char_2() throws TestException{ char[][] o = RectangularArrayExamples.getCharDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[][]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_char_3 private static void flatten_char_3() throws TestException{ char[][][] o = RectangularArrayExamples.getCharTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( char[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(char[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(char[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("C") ){ throw new TestException( "ArrayWrapper(char[][][]).getObjectTypeName() != 'C'" ) ; } System.out.println( " C : ok" ); System.out.print( " >> flat_char()" ) ; char[] flat; try{ flat = wrapper.flat_char() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(char[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (char)i ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_1 private static void flatten_float_1() throws TestException{ float[] o = new float[5] ; for( int i=0;i<5;i++) o[i] = (float)(i+0.0) ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_2 private static void flatten_float_2() throws TestException{ float[][] o = RectangularArrayExamples.getFloatDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[][]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( flat[i] != (i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_float_3 private static void flatten_float_3() throws TestException{ float[][][] o = RectangularArrayExamples.getFloatTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( float[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(float[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( !wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(float[][][]) not primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("F") ){ throw new TestException( "ArrayWrapper(float[][][]).getObjectTypeName() != 'F'" ) ; } System.out.println( " F : ok" ); System.out.print( " >> flat_float()" ) ; float[] flat; try{ flat = wrapper.flat_float() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(float[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( flat[i] != (float)(i+0.0) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} // {{{ flat array of String // {{{ flatten_String_1 private static void flatten_String_1() throws TestException{ String[] o = new String[5] ; for( int i=0;i<5;i++) o[i] = ""+i ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(float[]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[]) >> FlatException") ; } for( int i=0; i<5; i++){ if( ! flat[i].equals(""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_String_2 private static void flatten_String_2() throws TestException{ String[][] o = RectangularArrayExamples.getStringDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[][]) is primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(float[][]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[][]) >> FlatException") ; } for( int i=0; i<10; i++){ if( ! flat[i].equals( ""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_String_3 private static void flatten_String_3() throws TestException{ String[][][] o = RectangularArrayExamples.getStringTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( String[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(String[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(String[][][]) is primitive" ) ; } System.out.println( " true : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("java.lang.String") ){ throw new TestException( "ArrayWrapper(String[][][]).getObjectTypeName() != 'java.lang.String'" ) ; } System.out.println( " java.lang.String : ok" ); System.out.print( " >> flat_String()" ) ; String[] flat; try{ flat = wrapper.flat_String() ; } catch( PrimitiveArrayException e){ throw new TestException( "PrimitiveArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(String[][][]) >> FlatException") ; } for( int i=0; i<30; i++){ if( !flat[i].equals( ""+i) ) throw new TestException( "flat[" + i + "] = " + flat [i] + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} // {{{ flat array of Point // {{{ flatten_Point_1 private static void flatten_Point_1() throws TestException{ DummyPoint[] o = new DummyPoint[5] ; for( int i=0;i<5;i++) o[i] = new DummyPoint(i,i) ; ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat ; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(DummyPoint[]) >> FlatException") ; } DummyPoint p ; for( int i=0; i<5; i++){ p = flat[i] ; if( p.x != i || p.y != i) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_Point_2 private static void flatten_Point_2() throws TestException{ DummyPoint[][] o = RectangularArrayExamples.getDummyPointDoubleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[][]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[][]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(DummyPoint[][]) >> FlatException") ; } DummyPoint p; for( int i=0; i<10; i++){ p = flat[i] ; if( p.x != i || p.y != i) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // {{{ flatten_Point_3 private static void flatten_Point_3() throws TestException{ DummyPoint[][][] o = RectangularArrayExamples.getDummyPointTripleRectangularArrayExample(); ArrayWrapper wrapper = null ; System.out.print( " >> new ArrayWrapper( DummyPoint[][][] ) " ); try{ wrapper = new ArrayWrapper(o); } catch( NotAnArrayException e){ throw new TestException("new ArrayWrapper(DummyPoint[][][]) >> NotAnArrayException ") ; } System.out.println( "ok"); System.out.print( " >> isPrimitive()" ) ; if( wrapper.isPrimitive() ){ throw new TestException( "ArrayWrapper(DummyPoint[][][]) is primitive" ) ; } System.out.println( " false : ok" ); System.out.print( " >> getObjectTypeName()" ) ; if( !wrapper.getObjectTypeName().equals("DummyPoint") ){ throw new TestException( "ArrayWrapper(DummyPoint[][][]).getObjectTypeName() != 'DummyPoint'" ) ; } System.out.println( " DummyPoint : ok" ); System.out.print( " >> flat_Object()" ) ; DummyPoint[] flat; try{ flat = (DummyPoint[])wrapper.flat_Object() ; } catch( ObjectArrayException e){ throw new TestException( "ObjectArrayException" ) ; } catch( FlatException e){ throw new TestException("new ArrayWrapper(Object[][][]) >> FlatException") ; } DummyPoint p; for( int i=0; i<30; i++){ p = flat[i]; if( p.x != i || p.y != i ) throw new TestException( "flat[" + i + "].x = " + p.x + "!=" + i); } System.out.println( " ok" ) ; } // }}} // }}} } rJava/inst/java/RectangularArraySummary.class0000644000175100001440000000716615133274037021123 0ustar hornikusersÊþº¾2… C D EF G EH I .J KL EM NO P Q RS T U V W X Y Z[ \ K] ^_ `a b KcdelengthItypeNameLjava/lang/String; isprimitiveZ componentTypeLjava/lang/Class;(Ljava/lang/Object;[I)VCodeLineNumberTable StackMapTablefg Exceptionsh(Ljava/lang/Object;I)Vmin(Z)Ljava/lang/Object;maxrange(Z)[Ljava/lang/Object;(([Ljava/lang/Object;Z)Ljava/lang/Object;)([Ljava/lang/Object;Z)[Ljava/lang/Object;checkComparableObjects()VcontainsComparableObjects()Zsmaller'(Ljava/lang/Object;Ljava/lang/Object;)Zbigger SourceFileRectangularArraySummary.java )i jkl mn #$ op %& qrs tu vw '( java/lang/ClassNotFoundException :; )* xg[Ljava/lang/Object; 38 y= z{ >? 58 @? 69java/lang/Comparable |} ~r € <=NotComparableException )‚ ƒ„RectangularArraySummaryRJavaArrayIteratorjava/lang/Object[INotAnArrayException([I)VarrayLjava/lang/Object;RJavaArrayToolsgetObjectTypeName&(Ljava/lang/Object;)Ljava/lang/String;isPrimitiveTypeName(Ljava/lang/String;)ZgetClass()Ljava/lang/Class;java/lang/ClassgetClassLoader()Ljava/lang/ClassLoader;getClassForSignature<(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class; dimensionshasNextnext()Ljava/lang/Object; compareTo(Ljava/lang/Object;)IgetComponentTypejava/lang/reflect/Array newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;(Ljava/lang/String;)VisAssignableFrom(Ljava/lang/Class;)Z! !"#$%&'( )*+8*,·*+µ*+¸µ**´¸µ**´+¶¶¸ µ §N*¶ ±/2 ," /3 7!-ÿ2./ 01)2+) *+¼ YO· ±, $ %0134+ä\*´™°M6*´¾ *´À¸°*¶™3*¶À¸N-Ç šÿè°š -M6§ÿÙ-,¸™ÿÑ-M§ÿÌ,°,B,- / 134#8*96::;@=E>G?M@UAZE-. þ.ÿ.. ÿ .54+ä\*´™°M6*´¾ *´À¸°*¶™3*¶À¸N-Ç šÿè°š -M6§ÿÙ-,¸™ÿÑ-M§ÿÌ,°,BOP S UWX#\*]6^:_@aEbGcMdUeZi-. þ.ÿ.. ÿ .67+v*´™°*´¾ *´À¸°M6*¶™M*¶À¸N-Ç šÿè°š -M6§ÿÙ-2,2¸™ ,-2S-2,2¸™ÿ»,-2S§ÿ²,°,Jst wx{ }#€*6‚:ƒ@…E†G‡M‰YŠ_Œkt“-0 þÿ ÿ 38+ÖI*¾=N66¢9*2:Ç š$°š N6§-À¹žN„§ÿÇ-°,:¡¢¤§¨©ª"¬'­*®0¯>°A§G´-;ÿ .ÿ.. ÿ. 58+ÖI*¾=N66¢9*2:Ç š$°š N6§-À¹œN„§ÿÇ-°,:¾¿ÁÄÅÆÇ"É'Ê*Ë0Ì>ÍAÄGÑ-;ÿ .ÿ.. ÿ. 69+v*¾=*¶¶¸ÀN66¢Y*2:Ç šD°š-S-S6§--2À¹œ-S-2À¹ž-S„§ÿ§-°,FÛÜÞáâ$ã)ä/æ4ç9è>éDìTíYðiñnát÷-<ÿÿ.ÿ:;+9*¶š»Y*´·¿±, üý-0<=+" *´ ¶¬, >?+6*À+¹œ§¬,-@ @?+6*À+¹ž§¬,-@ABrJava/inst/java/RJavaComparator.class0000644000175100001440000000203615133274037017321 0ustar hornikusersÊþº¾28      !"# $ %& '()()VCodeLineNumberTablecompare'(Ljava/lang/Object;Ljava/lang/Object;)I StackMapTable Exceptions SourceFileRJavaComparator.java  *+java/lang/Number ,- ./0 12 34java/lang/ComparableNotComparableException 5 36java/lang/ClassCastException 7RJavaComparatorjava/lang/Objectequals(Ljava/lang/Object;)ZgetClass()Ljava/lang/Class; doubleValue()Djava/lang/DoublevalueOf(D)Ljava/lang/Double; compareTo(Ljava/lang/Double;)I(Ljava/lang/Object;)V(Ljava/lang/Object;)I'(Ljava/lang/Object;Ljava/lang/Object;)V!*·± *+¶™¬*Á™3+Á™,*¶+¶¥!*À¶¸N+À¶¸:-¶¬*Áš » Y*· ¿+Áš » Y+· ¿*À+¹ =§N+À*¹ t=§:» Y*+· ¿¬alo p| > #. :!A$Q%a(l/o)p+|.,-‹0, 6M ÿ  ÿ  rJava/inst/java/TestException.class0000644000175100001440000000033615133274037017065 0ustar hornikusersÊþº¾2    (Ljava/lang/String;)VCodeLineNumberTable SourceFileTestException.java  TestExceptionjava/lang/Exception!*+·± rJava/inst/java/RJavaImport.java0000644000175100001440000001033015133274037016274 0ustar hornikusers import java.util.regex.Pattern ; import java.util.regex.Matcher ; import java.util.Vector; import java.util.HashMap; import java.util.Map; import java.util.Collection; import java.util.Set ; import java.util.Iterator ; import java.io.Serializable; /** * Utilities to manage java packages and how they are "imported" to R * databases. This is the back door of the javaImport * system in the R side * * @author Romain Francois <francoisromain@free.fr> */ public class RJavaImport implements Serializable { /** * Debug flag. Prints some messages if it is set to TRUE */ public static boolean DEBUG = false ; /** * list of imported packages */ /* TODO: vector is not good enough, we need to control the order in which the packages appear */ private Vector/**/ importedPackages ; /** * maps a simple name to a fully qualified name */ /* String -> java.lang.String */ /* should we cache the Class instead ? */ private Map/**/ cache ; /** * associated class loader */ public ClassLoader loader ; /** * Constructor. Initializes the imported package vector and the cache */ public RJavaImport( ClassLoader loader ){ this.loader = loader ; importedPackages = new Vector/**/(); cache = new HashMap/**/() ; } /** * Look for the class in the set of packages * * @param clazz the simple class name * * @return an instance of Class representing the actual class */ public Class lookup( String clazz){ Class res = lookup_(clazz) ; if( DEBUG ) System.out.println( " [J] lookup( '" + clazz + "' ) = " + (res == null ? " " : ("'" + res.getName() + "'" ) ) ) ; return res ; } private Class lookup_( String clazz ){ Class res = null ; if( cache.containsKey( clazz ) ){ try{ String fullname = (String)cache.get( clazz ) ; Class cl = Class.forName( fullname ) ; return cl ; } catch( Exception e ){ /* does not happen */ } } /* first try to see if the class does not exist verbatim */ try{ res = Class.forName( clazz ) ; } catch( Exception e){} if( res != null ) { cache.put( clazz, clazz ) ; return res; } int npacks = importedPackages.size() ; if( DEBUG ) System.out.println( " [J] " + npacks + " packages" ) ; if( npacks > 0 ){ for( int i=0; i*/ set = cache.keySet() ; int size = set.size() ; String[] res = new String[size]; set.toArray( res ); if( DEBUG ) System.out.println( " [J] getKnownClasses().length = " + res.length ) ; return res ; } public static Class lookup( String clazz , Set importers ){ Class res ; Iterator iterator = importers.iterator() ; while( iterator.hasNext()){ RJavaImport importer = (RJavaImport)iterator.next() ; res = importer.lookup( clazz ) ; if( res != null ) return res ; } return null ; } } rJava/inst/java/RectangularArraySummary.java0000644000175100001440000001366015133274037020733 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: import java.lang.reflect.Array ; /** * Utility class to extract something from a rectangular array */ public class RectangularArraySummary extends RJavaArrayIterator { private int length ; private String typeName ; private boolean isprimitive ; private Class componentType ; /** * Constructor * * @param array the array to check * @throws NotAnArrayException if array is not an array */ public RectangularArraySummary(Object array, int[] dimensions) throws NotAnArrayException, NotComparableException { super( dimensions ); this.array = array ; typeName = RJavaArrayTools.getObjectTypeName(array ); isprimitive = RJavaArrayTools.isPrimitiveTypeName( typeName ) ; try{ componentType = RJavaArrayTools.getClassForSignature( typeName , array.getClass().getClassLoader() ) ; } catch( ClassNotFoundException e){} checkComparableObjects() ; } public RectangularArraySummary(Object array, int length ) throws NotAnArrayException, NotComparableException{ this( array, new int[]{ length } ); } /** * Iterates over the array to find the minimum value * (in the sense of the Comparable interface) */ public Object min( boolean narm ) { if( isprimitive ){ return null ; // TODO :implement } Object smallest = null ; Object current ; boolean found = false ; if( dimensions.length == 1 ){ return( min( (Object[])array, narm ) ) ; } else{ /* need to iterate */ while( hasNext() ){ current = min( (Object[])next(), narm ) ; if( current == null ){ if( !narm ) return null ; } else{ if( !found ){ smallest = current ; found = true ; } else if( smaller( current, smallest ) ) { smallest = current ; } } } return smallest ; } } /** * Iterates over the array to find the maximum value * (in the sense of the Comparable interface) */ public Object max( boolean narm ) { if( isprimitive ){ return null ; // TODO :implement } Object biggest = null ; Object current ; boolean found = false ; if( dimensions.length == 1 ){ return( max( (Object[])array, narm ) ) ; } else{ /* need to iterate */ while( hasNext() ){ current = max( (Object[])next(), narm ) ; if( current == null ){ if( !narm ) return null ; } else{ if( !found ){ biggest = current ; found = true ; } else if( bigger( current, biggest) ){ biggest = current ; } } } return biggest ; } } /** * Iterates over the array to find the range of the java array * (in the sense of the Comparable interface) */ public Object[] range( boolean narm ) { if( isprimitive ){ return null ; // TODO :implement } if( dimensions.length == 1 ){ return( range( (Object[])array, narm ) ) ; } else{ Object[] range = null ; Object[] current ; boolean found = false ; /* need to iterate */ while( hasNext() ){ current = range( (Object[])next(), narm ) ; if( current == null ){ if( !narm ) return null ; } else{ if( !found ){ range = current ; found = true ; } else { if( bigger( current[1], range[1] ) ){ range[1] = current[1] ; } if( smaller( current[0], range[0] ) ){ range[0] = current[0] ; } } } } return range ; } } /** * returns the minimum (in the sense of Comparable) of the * objects in the one dimensioned array */ private static Object min( Object[] x, boolean narm ){ int n = x.length ; Object smallest = null ; Object current ; boolean found_min = false; // find somewhere to start from () for( int i=0; i 0 ) { smallest = current ; } } } return smallest ; } /** * returns the minimum (in the sense of Comparable) of the * objects in the one dimensioned array */ private static Object max( Object[] x, boolean narm ){ int n = x.length ; Object biggest = null ; Object current ; boolean found_min = false; // find somewhere to start from () for( int i=0; i 0 ) { range[0] = current ; } } } } return range ; } public void checkComparableObjects() throws NotComparableException { if( ! containsComparableObjects() ) throw new NotComparableException( typeName ) ; } public boolean containsComparableObjects(){ return Comparable.class.isAssignableFrom( componentType ) ; } // TODO : use these private static boolean smaller( Object x, Object y){ return ( (Comparable)x ).compareTo(y) < 0 ; } private static boolean bigger( Object x, Object y){ return ( (Comparable)x ).compareTo(y) > 0 ; } } rJava/inst/java/NotComparableException.class0000644000175100001440000000166115133274037020676 0ustar hornikusersÊþº¾23     !" # $ $%&'('(Ljava/lang/Object;Ljava/lang/Object;)VCodeLineNumberTable(Ljava/lang/Object;)V(Ljava/lang/Class;)V(Ljava/lang/String;)V SourceFileNotComparableException.javajava/lang/StringBuilder )objects of class *+, -./ 01 and  are not comparable 21 class ( does not implement java.util.ComparableNotComparableExceptionjava/lang/Exception()Vappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;java/lang/ObjectgetClass()Ljava/lang/Class;java/lang/ClassgetName()Ljava/lang/String;toString!V2*»Y·¶+¶¶¶¶,¶¶¶¶¶ · ±  . 1 ( *+¶¶· ±  % *+¶· ± 9*»Y· ¶+¶ ¶¶ · ± rJava/inst/java/ArrayDimensionException.class0000644000175100001440000000036615133274037021075 0ustar hornikusersÊþº¾2    (Ljava/lang/String;)VCodeLineNumberTable SourceFileArrayDimensionException.java ArrayDimensionExceptionjava/lang/Exception!"*+·±  rJava/inst/java/RJavaArrayIterator.java0000644000175100001440000000323215133274037017615 0ustar hornikusersimport java.lang.reflect.Array ; public abstract class RJavaArrayIterator { protected int[] dimensions; protected int nd ; protected int[] index ; protected int[] dimprod ; protected Object array ; protected int increment; protected int position ; protected int start ; public Object getArray(){ return array ; } /** * @return the class name of the array */ public String getArrayClassName(){ return array.getClass().getName(); } public int[] getDimensions(){ return dimensions; } public RJavaArrayIterator(){ dimensions = null; index = null ; dimprod = null ; array = null ; } public RJavaArrayIterator(int[] dimensions){ this.dimensions = dimensions ; nd = dimensions.length ; if( nd > 1){ index = new int[ nd-1 ] ; dimprod = new int[ nd-1 ] ; for( int i=0; i<(nd-1); i++){ index[i] = 0 ; dimprod[i] = (i==0) ? dimensions[i] : ( dimensions[i]*dimprod[i-1] ); increment = dimprod[i] ; } } position = 0 ; start = 0; } public RJavaArrayIterator(int d1){ this( new int[]{ d1} ) ; } protected Object next( ){ /* get the next array and the position of the first elemtn in the flat array */ Object o = array ; for( int i=0; i=0; i--){ if( (index[i] + 1) == dimensions[i] ){ index[i] = 0 ; } else{ index[i] = index[i] + 1 ; break; } } position++ ; return o; } protected boolean hasNext( ){ return position < increment ; } } rJava/inst/java/RectangularArrayBuilder_Test.java0000644000175100001440000005766115133274037021674 0ustar hornikusers// :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: /** * Test suite for RectangularArrayBuilder */ public class RectangularArrayBuilder_Test { private static int[] dim1d = {10} ; private static int[] dim2d = {5,2} ; private static int[] dim3d = {5,3,2} ; // {{{ main public static void main(String[] args ){ try{ runtests() ; } catch( TestException e){ e.printStackTrace(); System.exit(1); } System.out.println( "\nALL PASSED\n" ) ; System.exit( 0 ); } // }}} // {{{ runtests public static void runtests() throws TestException { // {{{ 1d System.out.println( " >> 1 d" ); System.out.print( "fill int[]" ); fill_int_1(); System.out.println( " : ok" ); System.out.print( "fill boolean[]" ); fill_boolean_1(); System.out.println( " : ok" ); System.out.print( "fill byte[]" ); fill_byte_1(); System.out.println( " : ok" ); System.out.print( "fill long[]" ); fill_long_1(); System.out.println( " : ok" ); System.out.print( "fill short[]" ); fill_short_1(); System.out.println( " : ok" ); System.out.print( "fill double[]" ); fill_double_1(); System.out.println( " : ok" ); System.out.print( "fill char[]" ); fill_char_1(); System.out.println( " : ok" ); System.out.print( "fill float[]" ); fill_float_1(); System.out.println( " : ok" ); System.out.print( "fill String[]" ); fill_String_1(); System.out.println( " : ok" ); System.out.print( "fill Point[]" ); fill_Point_1(); System.out.println( " : ok" ); // }}} // {{{ 2d System.out.println( " >> 2 d" ); System.out.print( "fill int[][]" ); fill_int_2(); System.out.println( " : ok" ); System.out.print( "fill boolean[][]" ); fill_boolean_2(); System.out.println( " : ok" ); System.out.print( "fill byte[][]" ); fill_byte_2(); System.out.println( " : ok" ); System.out.print( "fill long[][]" ); fill_long_2(); System.out.println( " : ok" ); System.out.print( "fill short[][]" ); fill_short_2(); System.out.println( " : ok" ); System.out.print( "fill double[][]" ); fill_double_2(); System.out.println( " : ok" ); System.out.print( "fill char[][]" ); fill_char_2(); System.out.println( " : ok" ); System.out.print( "fill float[][]" ); fill_float_2(); System.out.println( " : ok" ); System.out.print( "fill String[][]" ); fill_String_2(); System.out.println( " : ok" ); System.out.print( "fill Point[][]" ); fill_Point_2(); System.out.println( " : ok" ); // }}} // {{{ 3d System.out.println( " >> 3 d" ); System.out.print( "fill int[][][]" ); fill_int_3(); System.out.println( " : ok" ); System.out.print( "fill boolean[][][]" ); fill_boolean_3(); System.out.println( " : ok" ); System.out.print( "fill byte[][][]" ); fill_byte_3(); System.out.println( " : ok" ); System.out.print( "fill long[][][]" ); fill_long_3(); System.out.println( " : ok" ); System.out.print( "fill short[][][]" ); fill_short_3(); System.out.println( " : ok" ); System.out.print( "fill double[][][]" ); fill_double_3(); System.out.println( " : ok" ); System.out.print( "fill char[][][]" ); fill_char_3(); System.out.println( " : ok" ); System.out.print( "fill float[][][]" ); fill_float_3(); System.out.println( " : ok" ); System.out.print( "fill String[][][]" ); fill_String_3(); System.out.println( " : ok" ); System.out.print( "fill Point[][][]" ); fill_Point_3(); System.out.println( " : ok" ); // }}} } //}}} // {{{ 1d private static void fill_int_1() throws TestException{ RectangularArrayBuilder builder = null; try{ builder = new RectangularArrayBuilder( ints(10), dim1d ); } catch( NotAnArrayException e){ throw new TestException( "not an array int[10]" ) ; } catch( ArrayDimensionException e){ throw new TestException( "array dimensionexception" ) ; } int[] data = (int[])builder.getArray(); int current = 0; for( int i=0; i U?@ UA £BCD UE £FGH £IJK £LMN £OPQ £RST £UVW £XYZ[  \ £]^_ ¡` ¡ab £cdefghijklmno £pqrstuvwxyz{|}~€‚ƒ„…†‡ ¡ˆ‰Šdim1d[Idim2ddim3d()VCodeLineNumberTablemain([Ljava/lang/String;)V StackMapTableruntests Exceptions fill_int_1fill_boolean_1 fill_byte_1 fill_long_1 fill_short_1 fill_double_1 fill_char_1 fill_float_1 fill_String_1 fill_Point_1 fill_int_2fill_boolean_2 fill_byte_2 fill_long_2 fill_short_2 fill_double_2 fill_char_2 fill_float_2 fill_String_2 fill_Point_2 fill_int_3fill_boolean_3 fill_byte_3 fill_long_3 fill_short_3 fill_double_3 fill_char_3 fill_float_3 fill_String_3 fill_Point_3ints(I)[Ibooleans(I)[Zbytes(I)[Blongs(I)[Jshorts(I)[Sdoubles(I)[Dchars(I)[Cfloats(I)[Fstrings(I)[Ljava/lang/String;points(I)[LDummyPoint; SourceFile!RectangularArrayBuilder_Test.java ©ª °ª TestException ‹ªŒ Ž  ALL PASSED ‘ ’“ >> 1 d fill int[] ”“ ²ª : okfill boolean[] ³ª fill byte[] ´ª fill long[] µª fill short[] ¶ª fill double[] ·ª fill char[] ¸ª fill float[] ¹ª fill String[] ºª fill Point[] »ª >> 2 d fill int[][] ¼ªfill boolean[][] ½ª fill byte[][] ¾ª fill long[][] ¿ªfill short[][] Àªfill double[][] Áª fill char[][] ªfill float[][] êfill String[][] Īfill Point[][] Ū >> 3 dfill int[][][] ƪfill boolean[][][] Ǫfill byte[][][] Ȫfill long[][][] ɪfill short[][][] ʪfill double[][][] ˪fill char[][][] ̪fill float[][][] ͪfill String[][][] Ϊfill Point[][][] ϪRectangularArrayBuilder ÐÑ ¥¦ ©•NotAnArrayExceptionnot an array int[10] ©“ArrayDimensionExceptionarray dimensionexception –—java/lang/StringBuilderdata[ ˜™ ˜š] != ›œ ÒÓnot an array boolean[10][Z ˜ ÔÕnot an array byte[10][B Ö×not an array long[10][J ØÙnot an array short[10][S ÚÛnot an array double[10][D ÜÝnot an array char[10][C Þßnot an array float[10][F àánot an array String[10][Ljava/lang/String; žŸ âãnot an array DummyPoint[10] [LDummyPoint;  ¡ ¢¡].x != §¦[[I][[[Z[[B[[J[[S[[D[[C[[F[[Ljava/lang/String;not an array Point[10][[LDummyPoint; ¨¦not an array int[30][[[I] != not an array boolean[30][[[Znot an array byte[30][[[Bnot an array long[30][[[Jnot an array short[30][[[Snot an array double[30][[[Dnot an array char[30][[[Cnot an array float[30][[[Fnot an array String[30][[[Ljava/lang/String;not an array Point[30][[[LDummyPoint;java/lang/String DummyPoint ©£RectangularArrayBuilder_Testjava/lang/ObjectprintStackTracejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vprint(Ljava/lang/Object;[I)VgetArray()Ljava/lang/Object;append-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toString()Ljava/lang/String;(Z)Ljava/lang/StringBuilder;equals(Ljava/lang/Object;)ZxIy(II)V!£¤ ¥¦ §¦ ¨¦,©ª«*·±¬ ­®«e¸§ L+¶¸²¶¸±¬" ¯F °ª«ïS² ¶² ¶ ¸ ² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶²¶ ¸² ¶² ¶²!¶ ¸"² ¶²#¶ ¸$² ¶²%¶ ¸&² ¶²'¶ ¸(² ¶²)¶ ¸*² ¶²+¶ ¸,² ¶²-¶ ¸.² ¶²/¶ ¸0² ¶²1¶ ¸2² ¶²3¶ ¸4² ¶²5¶²6¶ ¸7² ¶²8¶ ¸9² ¶²:¶ ¸;² ¶²<¶ ¸=² ¶²>¶ ¸?² ¶²@¶ ¸A² ¶²B¶ ¸C² ¶²D¶ ¸E² ¶²F¶ ¸G² ¶²H¶ ¸I² ¶±¬Š". A!T"g#z$% &³'Æ+Î,á-ô./0-1@2S3f4y5Œ9”:§;º<Í=à>ó?@A,B?CRF± ²ª«÷uK»JY ¸K²L·MK§L»YO·P¿L»YR·P¿*¶SÀTL=>²L.¢7+.Ÿ'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿƱN Q¬:KMRNO P!Q+T3U5V@WGXkVt\¯ ÿJNJQ þ T3ú± ³ª«|K»JY ¸\²L·MK§L»Y]·P¿L»YR·P¿*¶SÀ^L=>²L.¢>+3Ÿ'»Y»UY·VW¶X¶YZ¶X¶_¶[·P¿„š§=§ÿ¿±N Q¬:_afbc d!e+h3i5k@lGmkk{q¯#ÿJNJQ þ ^3 @ú± ´ª«÷uK»JY ¸`²L·MK§L»Ya·P¿L»YR·P¿*¶SÀbL=>²L.¢7+3Ÿ'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿƱN Q¬:tv{wx y!z+}3~5@€Gkt…¯ ÿJNJQ þ b3ú± µª«ùwK»JY ¸c²L·MK§L»Yd·P¿L»YR·P¿*¶SÀeL=>²L.¢9+/…”™'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿıN Q¬:ˆŠ‹Œ !Ž+‘3’5“@”I•m“v™¯ ÿJNJQ þ e5ú± ¶ª«÷uK»JY ¸f²L·MK§L»Yg·P¿L»YR·P¿*¶SÀhL=>²L.¢7+5Ÿ'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿƱN Q¬:œž£Ÿ  ¡!¢+¥3¦5§@¨G©k§t­¯ ÿJNJQ þ h3ú± ·ª«ùwK»JY ¸i²L·MK§L»Yj·P¿L»YR·P¿*¶SÀkL=>²L.¢9+1‡—™'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿıN Q¬:°²·³´ µ!¶+¹3º5»@¼I½m»vÁ¯ ÿJNJQ þ k5ú± ¸ª«÷uK»JY ¸l²L·MK§L»Ym·P¿L»YR·P¿*¶SÀnL=>²L.¢7+4Ÿ'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿƱN Q¬:ÄÆËÇÈ É!Ê+Í3Î5Ï@ÐGÑkÏtÕ¯ ÿJNJQ þ n3ú± ¹ª«ùwK»JY ¸o²L·MK§L»Yp·P¿L»YR·P¿*¶SÀqL=>²L.¢9+0†•™'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿıN Q¬:ØÚßÛÜ Ý!Þ+á3â5ã@äIåmãvé¯ ÿJNJQ þ q5ú± ºª«ŠK»JY ¸r²L·MK§L»Ys·P¿L»YR·P¿*¶SÀtL=>²L.¢L+2»UY·V¶Yu¶X¶[¶vš'»Y»UY·VW¶X¶YZ¶X¶Y¶[·P¿„„§ÿ±±N Q¬:ìîóïð ñ!ò+õ3ö5÷@ø\ù€÷‰ý¯"ÿJNJQ þ tûHú± »ª«…K»JY ¸w²L·MK§L»Yx·P¿L»YR·P¿*¶SÀyL=>²L.¢G+2:´z  ´{Ÿ'»Y»UY·VW¶X¶Y|¶X¶Y¶[·P¿„„§ÿ¶±N Q¬> !+ 3 5 @ E W{ „¯(ÿJNJQ þ yü¡ú#ú± ¼ª«(•K»JY ¸K²}·MK§L»YO·P¿L»YR·P¿*¶SÀ~L=>²}.¢W6²}.¢D+2.Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¸„§ÿ¦±N Q¬B !+!3"5#@$M%W&…$Ž#”+¯)ÿJNJQ þ ~ü ûAúú± ½ª«2œK»JY ¸\²}·MK§L»Y]·P¿L»YR·P¿*¶SÀ€L=>²}.¢^6²}.¢K+23Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶_¶[·P¿„š§=§ÿ±„§ÿŸ±N Q¬B.0512 3!4+73859@:M;W<…:•9›A¯, ÿJNJQ þ €ü ûA @úú± ¾ª«(•K»JY ¸`²}·MK§L»Ya·P¿L»YR·P¿*¶SÀL=>²}.¢W6²}.¢D+23Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¸„§ÿ¦±N Q¬BDFKGH I!J+M3N5O@PMQWR…PŽO”W¯)ÿJNJQ þ ü ûAúú± ¿ª«*—K»JY ¸c²}·MK§L»Yd·P¿L»YR·P¿*¶SÀ‚L=>²}.¢Y6²}.¢F+2/…”™1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¶„§ÿ¤±N Q¬BZ\a]^ _!`+c3d5e@fMgYh‡fe–m¯)ÿJNJQ þ ‚ü ûCúú± Àª«(•K»JY ¸f²}·MK§L»Yg·P¿L»YR·P¿*¶SÀƒL=>²}.¢W6²}.¢D+25Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¸„§ÿ¦±N Q¬Bprwst u!v+y3z5{@|M}W~…|Ž{”ƒ¯)ÿJNJQ þ ƒü ûAúú± Áª«*—K»JY ¸i²}·MK§L»Yj·P¿L»YR·P¿*¶SÀ„L=>²}.¢Y6²}.¢F+21‡—™1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¶„§ÿ¤±N Q¬B†ˆ‰Š ‹!Œ+35‘@’M“Y”‡’‘–™¯)ÿJNJQ þ „ü ûCúú± ª«(•K»JY ¸l²}·MK§L»Ym·P¿L»YR·P¿*¶SÀ…L=>²}.¢W6²}.¢D+24Ÿ1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¸„§ÿ¦±N Q¬Bœž£Ÿ  ¡!¢+¥3¦5§@¨M©Wª…¨Ž§”¯¯)ÿJNJQ þ …ü ûAúú± ê«*—K»JY ¸o²}·MK§L»Yp·P¿L»YR·P¿*¶SÀ†L=>²}.¢Y6²}.¢F+20†•™1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ¶„§ÿ¤±N Q¬B²´¹µ¶ ·!¸+»3¼5½@¾M¿YÀ‡¾½–ů)ÿJNJQ þ †ü ûCúú± Ī«=ªK»JY ¸r²}·MK§L»Ys·P¿L»YR·P¿*¶SÀ‡L=>²}.¢l6²}.¢Y+22»UY·V¶Yu¶X¶[¶vš1»Y»UY·VW¶X¶Y¶X¶YZ¶X¶Y¶[·P¿„„§ÿ£„§ÿ‘±N Q¬BÈÊÏËÌ Í!Î+Ñ3Ò5Ó@ÔMÕlÖšÔ£Ó©Û¯)ÿJNJQ þ ‡ü ûVúú± Ū«B¥K»JY ¸w²}·MK§L»Yˆ·P¿L»YR·P¿*¶SÀ‰L=>²}.¢g6²}.¢T+22:´z  ´{Ÿ1»Y»UY·VW¶X¶Y¶X¶Y|¶X¶Y¶[·P¿„„§ÿ¨„§ÿ–±N Q¬FÞàåáâ ã!ä+ç3è5é@êMëUìgí•êžé¤ò¯/ ÿJNJQ þ ‰ü ü#¡ú-úú± ƪ«WµK»JY¸K²Š·MK§L»Y‹·P¿L»YR·P¿*¶SÀŒL=>²Š.¢w6²Š.¢d6²Š.¢Q+22.Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ«„§ÿ˜„§ÿ†±N Q¬Jøúÿûü ý!þ+35@MZgŸ¨®´ ¯0 ÿJNJQ þ Œü ü ûNúúú± Ǫ«a¼K»JY¸\²Š·MK§L»YŽ·P¿L»YR·P¿*¶SÀL=>²Š.¢~6²Š.¢k6²Š.¢X+223Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶_¶[·P¿„š§=§ÿ¤„§ÿ‘„§ÿ±N Q¬J !+35@MZgŸ¯µ»$¯3 ÿJNJQ þ ü ü ûN @úúú± Ȫ«WµK»JY¸`²Š·MK§L»Y·P¿L»YR·P¿*¶SÀ‘L=>²Š.¢w6²Š.¢d6²Š.¢Q+223Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ«„§ÿ˜„§ÿ†±N Q¬J').*+ ,!-+03152@3M4Z5g6Ÿ4¨3®2´;¯0 ÿJNJQ þ ‘ü ü ûNúúú± ɪ«Y·K»JY¸c²Š·MK§L»Y’·P¿L»YR·P¿*¶SÀ“L=>²Š.¢y6²Š.¢f6²Š.¢S+22/…”™;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ©„§ÿ–„§ÿ„±N Q¬J>@EAB C!D+G3H5I@JMKZLiM¡KªJ°I¶R¯0 ÿJNJQ þ “ü ü ûPúúú± ʪ«WµK»JY¸f²Š·MK§L»Y”·P¿L»YR·P¿*¶SÀ•L=>²Š.¢w6²Š.¢d6²Š.¢Q+225Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ«„§ÿ˜„§ÿ†±N Q¬JUW\XY Z![+^3_5`@aMbZcgdŸb¨a®`´i¯0 ÿJNJQ þ •ü ü ûNúúú± ˪«Y·K»JY¸i²Š·MK§L»Y–·P¿L»YR·P¿*¶SÀ—L=>²Š.¢y6²Š.¢f6²Š.¢S+221‡—™;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ©„§ÿ–„§ÿ„±N Q¬Jlnsop q!r+u3v5w@xMyZzi{¡yªx°w¶€¯0 ÿJNJQ þ —ü ü ûPúúú± ̪«WµK»JY¸l²Š·MK§L»Y˜·P¿L»YR·P¿*¶SÀ™L=>²Š.¢w6²Š.¢d6²Š.¢Q+224Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ«„§ÿ˜„§ÿ†±N Q¬Jƒ…І‡ ˆ!‰+Œ35Ž@MZ‘g’Ÿ¨®Ž´—¯0 ÿJNJQ þ ™ü ü ûNúúú± ͪ«Y·K»JY¸o²Š·MK§L»Yš·P¿L»YR·P¿*¶SÀ›L=>²Š.¢y6²Š.¢f6²Š.¢S+220†•™;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ©„§ÿ–„§ÿ„±N Q¬Jšœ¡ž Ÿ! +£3¤5¥@¦M§Z¨i©¡§ª¦°¥¶®¯0 ÿJNJQ þ ›ü ü ûPúúú± Ϊ«lÊK»JY¸r²Š·MK§L»Yœ·P¿L»YR·P¿*¶SÀL=>²Š.¢Œ6²Š.¢y6²Š.¢f+222»UY·V¶Yu¶X¶[¶vš;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y¶X¶Y¶[·P¿„„§ÿ–„§ÿƒ„§ÿq±N Q¬J±³¸´µ ¶!·+º3»5¼@½M¾Z¿|À´¾½½Ã¼Éů0 ÿJNJQ þ ü ü ûcúúú± Ϫ«qÅK»JY¸w²Š·MK§L»Yž·P¿L»YR·P¿*¶SÀŸL=>²Š.¢‡6²Š.¢t6²Š.¢a+222:´z  ´{Ÿ;»Y»UY·VW¶X¶Y¶X¶Y¶X¶Y|¶X¶Y¶[·P¿„„§ÿ›„§ÿˆ„§ÿv±N Q¬NÈÊÏËÌ Í!Î+Ñ3Ò5Ó@ÔMÕZÖe×wدÕ¸Ô¾ÓÄݯ6 ÿJNJQ þ Ÿü ü ü&¡ú7úúú± ÐÑ«Q¼ L=¢ +O„§ÿô+°¬âã äãæ¯ ýTú ÒÓ«e#¼L=>¢+T„š§=§ÿê+°¬êëì íì!ï¯þ^@ú ÔÕ«R¼L=¢+‘T„§ÿó+°¬óô õô÷¯ ýbú Ö׫R¼ L=¢+…P„§ÿó+°¬ûü ýüÿ¯ ýeú ØÙ«R¼ L=¢+“V„§ÿó+°¬ ¯ ýhú ÚÛ«T¼L=¢+‡cR„§ÿñ+°¬    ¯ ýkú ÜÝ«R¼L=¢+’U„§ÿó+°¬ ¯ ýnú Þß«T¼L=¢+ †bQ„§ÿñ+°¬ ¯ ýqú àá«d*½ L=¢+»UY·Vu¶X¶Y¶[S„§ÿâ+°¬#$ %"$('¯ ýtú âã«Z ½¡L=¢+»¡Y·¢S„§ÿì+°¬+, -,/¯ ýyú䪫L,¼ Y O³L¼ YOYO³}¼ YOYOYO³Š±¬  åærJava/inst/java/RJavaTools.java0000644000175100001440000005250415133274037016133 0ustar hornikusers// RJavaTools.java: rJava - low level R to java interface // // Copyright (C) 2009 - 2010 Simon Urbanek and Romain Francois // // This file is part of rJava. // // rJava is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // rJava is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with rJava. If not, see . import java.lang.reflect.Method ; import java.lang.reflect.Field ; import java.lang.reflect.Constructor ; import java.lang.reflect.InvocationTargetException ; import java.lang.reflect.Modifier ; import java.lang.reflect.Member ; import java.util.Vector ; /** * Tools used internally by rJava. * * The method lookup code is heavily based on ReflectionTools * by Romain Francois <francoisromain@free.fr> licensed under GPL v2 or higher. */ public class RJavaTools { /** * Returns an inner class of the class with the given simple name * * @param cl class * @param name simple name of the inner class * @param staticRequired boolean, if true the inner class is required to be static */ public static Class getClass(Class cl, String name, boolean staticRequired){ Class[] clazzes = cl.getClasses(); for( int i=0; iFor fields, it just returns the name of the fields * *

For methods, this returns the name of the method * plus a suffix that depends on the number of arguments of the method. * *

The string "()" is added * if the method has no arguments, and the string "(" is added * if the method has one or more arguments. */ public static String getCompletionName(Member m){ if( m instanceof Field ) return m.getName(); if( m instanceof Method ){ String suffix = ( ((Method)m).getParameterTypes().length == 0 ) ? ")" : "" ; return m.getName() + "(" + suffix ; } return "" ; } /** * Indicates if a member of a Class (field, method ) is static * * @param member class member * @return true if the member is static */ public static boolean isStatic( Member member ){ return (member.getModifiers() & Modifier.STATIC) != 0 ; } /** * Checks if the class of the object has the given field. The * getFields method of Class is used so only public fields are * checked * * @param o object * @param name name of the field * * @return true if the class of o has the field name */ public static boolean hasField(Object o, String name) { return classHasField(o.getClass(), name, false); } /** * Checks if the class of the object has the given inner class. The * getClasses method of Class is used so only public classes are * checked * * @param o object * @param name (simple) name of the inner class * * @return true if the class of o has the class name */ public static boolean hasClass(Object o, String name) { return classHasClass(o.getClass(), name, false); } /** * Checks if the specified class has the given field. The * getFields method of Class is used so only public fields are * checked * * @param cl class object * @param name name of the field * @param staticRequired if true then the field is required to be static * * @return true if the class cl has the field name */ public static boolean classHasField(Class cl, String name, boolean staticRequired) { Field[] fields = cl.getFields(); for (int i = 0; i < fields.length; i++) if(name.equals(fields[i].getName()) && (!staticRequired || ((fields[i].getModifiers() & Modifier.STATIC) != 0))) return true; return false; } /** * Checks if the specified class has the given method. The * getMethods method of Class is used so only public methods are * checked * * @param cl class * @param name name of the method * @param staticRequired if true then the method is required to be static * * @return true if the class cl has the method name */ public static boolean classHasMethod(Class cl, String name, boolean staticRequired) { Method[] methodz = cl.getMethods(); for (int i = 0; i < methodz.length; i++) if (name.equals(methodz[i].getName()) && (!staticRequired || ((methodz[i].getModifiers() & Modifier.STATIC) != 0))) return true; return false; } /** * Checks if the specified class has the given inner class. The * getClasses method of Class is used so only public classes are * checked * * @param cl class * @param name name of the inner class * @param staticRequired if true then the method is required to be static * * @return true if the class cl has the field name */ public static boolean classHasClass(Class cl, String name, boolean staticRequired) { Class[] clazzes = cl.getClasses(); for (int i = 0; i < clazzes.length; i++) if (name.equals( getSimpleName(clazzes[i].getName()) ) && (!staticRequired || isStatic( clazzes[i] ) ) ) return true; return false; } /** * Checks if the class of the object has the given method. The * getMethods method of Class is used so only public methods are * checked * * @param o object * @param name name of the method * * @return true if the class of o has the field name */ public static boolean hasMethod(Object o, String name) { return classHasMethod(o.getClass(), name, false); } /** * Object creator. Find the best constructor based on the parameter classes * and invoke newInstance on the resolved constructor */ public static Object newInstance( Class o_clazz, Object[] args, Class[] clazzes ) throws Throwable { boolean[] is_null = new boolean[args.length]; for( int i=0; iFirst the appropriate method is resolved by getMethod and * then invokes the method */ public static Object invokeMethod( Class o_clazz, Object o, String name, Object[] args, Class[] clazzes) throws Throwable { Method m = getMethod( o_clazz, name, clazzes, arg_is_null(args) ); /* enforcing accessibility (workaround for bug 128) */ boolean access = m.isAccessible(); if (!access) { try { /* since JDK-17 this may fail */ m.setAccessible( true ); } catch (Throwable e) { access = true; /* nothing we can do, fail later with proper error ... */ } } Object out; try{ out = m.invoke( o, args ) ; } catch( InvocationTargetException e){ /* the target exception is much more useful than the reflection wrapper */ throw e.getTargetException() ; } finally{ if (!access) m.setAccessible( access ); } return out ; } /** * Attempts to find the best-matching constructor of the class * o_clazz with the parameter types arg_clazz * * @param o_clazz Class to look for a constructor * @param arg_clazz parameter types * @param arg_is_null indicates if each argument is null * * @return null if no constructor is found, or the constructor * */ public static Constructor getConstructor( Class o_clazz, Class[] arg_clazz, boolean[] arg_is_null) throws SecurityException, NoSuchMethodException { if (o_clazz == null) return null; Constructor cons = null ; /* if there is no argument, try to find a direct match */ if (arg_clazz == null || arg_clazz.length == 0) { cons = o_clazz.getConstructor( (Class[] )null ); return cons ; } /* try to find an exact match */ try { cons = o_clazz.getConstructor(arg_clazz); if (cons != null) return cons ; } catch (NoSuchMethodException e) { /* we catch this one because we want to further search */ } /* ok, no exact match was found - we have to walk through all methods */ cons = null; Constructor[] candidates = o_clazz.getConstructors(); for (int k = 0; k < candidates.length; k++) { Constructor c = candidates[k]; Class[] param_clazz = c.getParameterTypes(); if (arg_clazz.length != param_clazz.length) // number of parameters must match continue; int n = arg_clazz.length; boolean ok = true; for (int i = 0; i < n; i++) { if( arg_is_null[i] ){ /* then the class must not be a primitive type */ if( isPrimitive(arg_clazz[i]) ){ ok = false ; break ; } } else{ if (arg_clazz[i] != null && !param_clazz[i].isAssignableFrom(arg_clazz[i])) { ok = false; break; } } } // it must be the only match so far or more specific than the current match if (ok && (cons == null || isMoreSpecific(c, cons))) cons = c; } if( cons == null ){ throw new NoSuchMethodException( "No constructor matching the given parameters" ) ; } return cons; } static boolean isPrimitive(Class cl){ return cl.equals(Boolean.TYPE) || cl.equals(Integer.TYPE) || cl.equals(Double.TYPE) || cl.equals(Float.TYPE) || cl.equals(Long.TYPE) || cl.equals(Short.TYPE) || cl.equals(Character.TYPE) ; } /** * Attempts to find the best-matching method of the class o_clazz with the method name name and arguments types defined by arg_clazz. * The lookup is performed by finding the most specific methods that matches the supplied arguments (see also {@link #isMoreSpecific}). * * @param o_clazz class in which to look for the method * @param name method name * @param arg_clazz an array of classes defining the types of arguments * @param arg_is_null indicates if each argument is null * * @return null if no matching method could be found or the best matching method. */ public static Method getMethod(Class o_clazz, String name, Class[] arg_clazz, boolean[] arg_is_null) throws SecurityException, NoSuchMethodException { if (o_clazz == null) return null; /* if there is no argument, try to find a direct match */ if (arg_clazz == null || arg_clazz.length == 0) { return o_clazz.getMethod(name, (Class[])null); } /* try to find an exact match */ Method met; try { met = o_clazz.getMethod(name, arg_clazz); if (met != null) return met; } catch (NoSuchMethodException e) { /* we want to search further */ } /* ok, no exact match was found - we have to walk through all methods */ met = null; Method[] ml = o_clazz.getMethods(); for (int k = 0; k < ml.length; k++) { Method m = ml[k]; if (!m.getName().equals(name)) // the name must match continue; Class[] param_clazz = m.getParameterTypes(); if (arg_clazz.length != param_clazz.length) // number of parameters must match continue; int n = arg_clazz.length; boolean ok = true; for (int i = 0; i < n; i++) { if( arg_is_null[i] ){ /* then the class must not be a primitive type */ if( isPrimitive(arg_clazz[i]) ){ ok = false ; break ; } } else{ if (arg_clazz[i] != null && !param_clazz[i].isAssignableFrom(arg_clazz[i])) { ok = false; break; } } } if (ok && (met == null || isMoreSpecific(m, met))) // it must be the only match so far or more specific than the current match met = m; } if( met == null ){ throw new NoSuchMethodException( "No suitable method for the given parameters" ) ; } return met; } /** * Returns true if m1 is more specific than m2. * The measure used is described in the isMoreSpecific( Class[], Class[] ) method * * @param m1 method to compare * @param m2 method to compare * * @return true if m1 is more specific (in arguments) than m2. */ private static boolean isMoreSpecific(Method m1, Method m2) { Class[] m1_param_clazz = m1.getParameterTypes(); Class[] m2_param_clazz = m2.getParameterTypes(); return isMoreSpecific( m1_param_clazz, m2_param_clazz ); } /** * Returns true if cons1 is more specific than cons2. * The measure used is described in the isMoreSpecific( Class[], Class[] ) method * * @param cons1 constructor to compare * @param cons2 constructor to compare * * @return true if cons1 is more specific (in arguments) than cons2. */ private static boolean isMoreSpecific(Constructor cons1, Constructor cons2) { Class[] cons1_param_clazz = cons1.getParameterTypes(); Class[] cons2_param_clazz = cons2.getParameterTypes(); return isMoreSpecific( cons1_param_clazz, cons2_param_clazz ); } /** * Returns true if c1 is more specific than c2. * * The measure used is the sum of more specific arguments minus the sum of less specific arguments * which in total must be positive to qualify as more specific. * (More specific means the argument is a subclass of the other argument). * * Both set of classes must have signatures fully compatible in the arguments * (more precisely incompatible arguments are ignored in the comparison). * * @param c1 set of classes to compare * @param c2 set of classes to compare */ private static boolean isMoreSpecific( Class[] c1, Class[] c2){ int n = c1.length ; int res = 0; for (int i = 0; i < n; i++) if( c1[i] != c2[i]) { if( c1[i].isAssignableFrom(c2[i])) res--; else if( c2[i].isAssignableFrom(c2[i]) ) res++; } return res > 0; } /** * Returns the list of classes of the object * * @param o an Object */ public static Class[] getClasses(Object o){ Vector/*>*/ vec = new Vector(); Class cl = o.getClass(); while( cl != null ){ vec.add( cl ) ; cl = cl.getSuperclass() ; } Class[] res = new Class[ vec.size() ] ; vec.toArray( res) ; return res ; } /** * Returns the list of class names of the object * * @param o an Object */ public static String[] getClassNames(Object o){ Vector/**/ vec = new Vector(); Class cl = o.getClass(); while( cl != null ){ vec.add( cl.getName() ) ; cl = cl.getSuperclass() ; } String[] res = new String[ vec.size() ] ; vec.toArray( res) ; return res ; } /** * Returns the list of simple class names of the object * * @param o an Object */ public static String[] getSimpleClassNames(Object o, boolean addConditionClasses){ boolean hasException = false ; Vector/**/ vec = new Vector(); Class cl = o.getClass(); String name ; while( cl != null ){ name = getSimpleName( cl.getName() ) ; if( "Exception".equals( name) ){ hasException = true ; } vec.add( name ) ; cl = cl.getSuperclass() ; } if( addConditionClasses ){ if( !hasException ){ vec.add( "Exception" ) ; } vec.add( "error" ) ; vec.add( "condition" ) ; } String[] res = new String[ vec.size() ] ; vec.toArray( res) ; return res ; } /* because Class.getSimpleName is java 5 API */ private static String getSimpleClassName( Object o ){ return getSimpleName( o.getClass().getName() ) ; } private static String getSimpleName( String s ){ int lastsquare = s.lastIndexOf( '[' ) ; if( lastsquare >= 0 ){ if( s.charAt( s.lastIndexOf( '[' ) + 1 ) == 'L' ){ s = s.substring( s.lastIndexOf( '[' ) + 2, s.lastIndexOf( ';' ) ) ; } else { char first = s.charAt( 0 ); if( first == 'I' ) { s = "int" ; } else if( first == 'D' ){ s = "double" ; } else if( first == 'Z' ){ s = "boolean" ; } else if( first == 'B' ){ s = "byte" ; } else if( first == 'J' ){ s = "long" ; } else if( first == 'F' ){ s = "float" ; } else if( first == 'S' ){ s = "short" ; } else if( first == 'C' ){ s = "char" ; } } } int lastdollar = s.lastIndexOf( '$' ) ; if( lastdollar >= 0 ){ s = s.substring( lastdollar + 1); } int lastdot = s.lastIndexOf( '.' ) ; if( lastdot >= 0 ){ s = s.substring( lastdot + 1); } if( lastsquare >= 0 ){ StringBuffer buf = new StringBuffer( s ); int i ; for( i=0; i<=lastsquare; i++){ buf.append( "[]" ); } return buf.toString(); } else { return s ; } } /** * @param cl class * @param field name of the field * * @return the class name of the field of the class (or null) * if the class does not have the given field) */ public static String getFieldTypeName( Class cl, String field){ String res = null ; try{ res = cl.getField( field ).getType().getName() ; } catch( NoSuchFieldException e){ /* just return null */ res = null ; } return res ; } } rJava/inst/java/NotAnArrayException.java0000644000175100001440000000043615133274037020001 0ustar hornikusers/** * Exception indicating that an object is not a java array */ public class NotAnArrayException extends Exception{ public NotAnArrayException(Class clazz){ super( "not an array : " + clazz.getName() ) ; } public NotAnArrayException(String message){ super( message ) ; } } rJava/inst/java/FlatException.java0000644000175100001440000000032215133274037016643 0ustar hornikusers /** * Generated when one attemps to flatten an array that is not rectangular */ public class FlatException extends Exception{ public FlatException(){ super( "Can only flatten rectangular arrays" ); } } rJava/inst/java/RJavaTools_Test$TestException.class0000644000175100001440000000047015133274037022074 0ustar hornikusersÊþº¾2   (Ljava/lang/String;)VCodeLineNumberTable SourceFileRJavaTools_Test.java RJavaTools_Test$TestException TestException InnerClassesjava/lang/ExceptionRJavaTools_Test!"*+·±    rJava/inst/java/ArrayWrapper.class0000644000175100001440000001320215133274037016702 0ustar hornikusersÊþº¾2Ú wx By Az w{ A| w} A~ A A€ A A‚ Bƒ„… † ‡ˆ ‡‰I @Š‹Œ † ƒŽ A A A‘ A’D“”•–—˜™š›œžŸ ¡¢£¤¥¦ A§¨ 4†© 9ª r«¬ r­® ‡¯ r°±²³´µisRectZtypeNameLjava/lang/String; primitivelengthI(Ljava/lang/Object;)VCodeLineNumberTable StackMapTable Exceptions(I)V(Z)V(B)V(J)V(S)V(D)V(C)V(F)V isRectangular()ZisRectangular_(Ljava/lang/Object;I)ZgetObjectTypeName()Ljava/lang/String; isPrimitiveflat_int()[I flat_boolean()[Z flat_byte()[B flat_long()[J flat_short()[S flat_double()[D flat_char()[C flat_float()[F flat_Object()[Ljava/lang/Object;¶· flat_String()[Ljava/lang/String; SourceFileArrayWrapper.java¸ ¹º J» ¼½ \¾ EF ¿À GD ÁŽ CD Z[ HI JÂNotAnArrayExceptionprimitive type JÃÄ ÅÆ ÇÈ ÉÊPrimitiveArrayExceptionint FlatException[I ËY ÌÍ ÎI ÏIboolean[ZBbyte[BJlong[JSshort[SDdouble[DCchar[CFfloat[F ^YObjectArrayException[Ljava/lang/Object; ÐÑ ÒÓjava/lang/Object ÔÕ java/lang/ClassNotFoundException Ö× ØÙjava.lang.String[Ljava/lang/String;java/lang/String ArrayWrapperRJavaArrayIteratorjava/lang/ClassLoaderjava/lang/ClassRJavaArrayTools getDimensions(Ljava/lang/Object;)[I([I)VarrayLjava/lang/Object;&(Ljava/lang/Object;)Ljava/lang/String;isPrimitiveTypeName(Ljava/lang/String;)Z dimensions()V(Ljava/lang/String;)Vjava/lang/reflect/Array getLength(Ljava/lang/Object;)Iget'(Ljava/lang/Object;I)Ljava/lang/Object;equals(Ljava/lang/Object;)ZhasNextnext()Ljava/lang/Object;start incrementgetClass()Ljava/lang/Class;getClassLoader()Ljava/lang/ClassLoader;forName=(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; newInstance&(Ljava/lang/Class;I)Ljava/lang/Object;cast&(Ljava/lang/Object;)Ljava/lang/Object;!ABCDEFGDHIJKLãu*+¸·*+µ*+¸µ**´¸µ*´¾  *µ § **+· µ *´ š*µ*µ §(*µ =*´¾¢*Y´ *´.hµ „§ÿå±M>"# $% &)'1);,B-G.O0T1_2n1t5Nÿ1A9 üúO JPL&*· » Y·¿M8O JQL&*· » Y·¿M9O JRL&*· » Y·¿M:O JSL&*· » Y·¿M;O JTL&*· » Y·¿M<O JUL&*· » Y·¿M=O JVL&*· » Y·¿M>O JWL&*· » Y·¿M?O XYL*´ ¬MFZ[Lˆ?*´¾ ¬+¸>*´.Ÿ¬6¢*+¸`· 𬄧ÿå¬M"M NOP%Q5R7P=UN üüú\]L*´°M\^YL*´¬Mc_`LÛt*´¶š »Y·¿*´ š »Y·¿*´¾  *´À°*´ ¼ L*¶™1*¶ÀN*´=6-¾¢+-.O„*´`=§ÿè§ÿÎ+°M6 no%p.q6s=vDwLxQy[zbyo|r}NüþùúOabLÛt*´¶š »Y·¿*´ š »Y·¿*´¾  *´À °*´ ¼L*¶™1*¶À N*´=6-¾¢+-3T„*´`=§ÿè§ÿÎ+°M6 ‰Š%‹.Œ6Ž=‘D’L“Q”[•b”o—r˜Nü þ ùúOcdLÛt!*´¶š »Y"·¿*´ š »Y·¿*´¾  *´À#°*´ ¼L*¶™1*¶À#N*´=6-¾¢+-3T„*´`=§ÿè§ÿÎ+°M6 ¤¥%¦.§6©=«D¬L­Q®[¯b®o±r²Nü#þ#ùúOefLÛt$*´¶š »Y%·¿*´ š »Y·¿*´¾  *´À&°*´ ¼ L*¶™1*¶À&N*´=6-¾¢+-/P„*´`=§ÿè§ÿÎ+°M6 ¿À%Á.Â6Ä=ÆDÇLÈQÉ[ÊbÉoÌrÍNü&þ&ùúOghLÛt'*´¶š »Y(·¿*´ š »Y·¿*´¾  *´À)°*´ ¼ L*¶™1*¶À)N*´=6-¾¢+-5V„*´`=§ÿè§ÿÎ+°M6 ÚÛ%Ü.Ý6ß=áDâLãQä[åbäoçrèNü)þ)ùúOijLÛt**´¶š »Y+·¿*´ š »Y·¿*´¾  *´À,°*´ ¼L*¶™1*¶À,N*´=6-¾¢+-1R„*´`=§ÿè§ÿÎ+°M6 ôõ%ö.÷6ù=ûDüLýQþ[ÿbþorNü,þ,ùúOklLÛt-*´¶š »Y.·¿*´ š »Y·¿*´¾  *´À/°*´ ¼L*¶™1*¶À/N*´=6-¾¢+-4U„*´`=§ÿè§ÿÎ+°M6 %.6=DLQ[borNü/þ/ùúOmnLÛt0*´¶š »Y1·¿*´ š »Y·¿*´¾  *´À2°*´ ¼L*¶™1*¶À2N*´=6-¾¢+-0Q„*´`=§ÿè§ÿÎ+°M6 *+%,.-6/=1D2L3Q4[5b4o7r8Nü2þ2ùúOopL9¦*¶3™»4Y*´·5¿*´ š »Y·¿*´¾  *´À6°*´¶7¶8L9M*´*´¶7¶8¸:M§N,*´ ¸<À6N*¶™<*¶À6:*´66¾¢-,2¶=S„*´`6§ÿß§ÿÃ-°ATW;MF@A"B+C3E>FAHTIXKdMkNtOzP…Q’P¡S¤TN- ÿ#Aqr;ü 6þ6ù#úO4stLÜu>*´¶š »Y>·¿*´ š »Y·¿*´¾  *´À?°*´ ½@L*¶™1*¶À?N*´=6-¾¢+-2S„*´`=§ÿè§ÿÎ+°M6 bc%d.e6g>iEjMkRl\mclpospNü?þ?ùúOuvrJava/inst/java/RJavaArrayTools.java0000644000175100001440000007067015133274037017136 0ustar hornikusers// RJavaTools.java: rJava - low level R to java interface // // :tabSize=2:indentSize=2:noTabs=false:folding=explicit:collapseFolds=1: // // Copyright (C) 2009 - 2010 Simon Urbanek and Romain Francois // // This file is part of rJava. // // rJava is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // rJava is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with rJava. If not, see . import java.lang.reflect.Array ; import java.util.Map; import java.util.HashMap; import java.util.Vector ; import java.util.Arrays ; import java.util.Iterator; import java.lang.reflect.Method ; import java.lang.reflect.InvocationTargetException ; public class RJavaArrayTools { // TODO: maybe factor this out of this class private static Map primitiveClasses = initPrimitiveClasses() ; private static Map initPrimitiveClasses(){ Map primitives = new HashMap(); primitives.put( "I", Integer.TYPE ); primitives.put( "Z", Boolean.TYPE ); primitives.put( "B", Byte.TYPE ); primitives.put( "J", Long.TYPE ); primitives.put( "S", Short.TYPE ); primitives.put( "D", Double.TYPE ); primitives.put( "C", Character.TYPE ); primitives.put( "F", Float.TYPE ); return primitives; } // {{{ getObjectTypeName /** * Get the object type name of an multi dimensional array. * * @param o object * @throws NotAnArrayException if the object is not an array */ public static String getObjectTypeName(Object o) throws NotAnArrayException { Class o_clazz = o.getClass(); if( !o_clazz.isArray() ) throw new NotAnArrayException( o_clazz ); String cl = o_clazz.getName(); return cl.replaceFirst("\\[+L?", "").replace(";", "") ; } public static int getObjectTypeName(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getObjectTypeName(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getObjectTypeName(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getObjectTypeName(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getObjectTypeName(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getObjectTypeName(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getObjectTypeName(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getObjectTypeName(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ makeArraySignature // TODO: test public static String makeArraySignature( String typeName, int depth ){ StringBuffer buffer = new StringBuffer() ; for( int i=0; i 1 ) return false; if( name.equals("I") ) return true ; if( name.equals("Z") ) return true ; if( name.equals("B") ) return true ; if( name.equals("J") ) return true ; if( name.equals("S") ) return true ; if( name.equals("D") ) return true ; if( name.equals("C") ) return true ; if( name.equals("F") ) return true ; return false; } // }}} // {{{ isRectangularArray /** * Indicates if o is a rectangular array * * @param o an array * @deprecated use new ArrayWrapper(o).isRectangular() instead */ public static boolean isRectangularArray(Object o) { if( !isArray(o) ) return false; boolean res = false; try{ if( getDimensionLength( o ) == 1 ) return true ; res = ( new ArrayWrapper(o) ).isRectangular() ; } catch( NotAnArrayException e){ res = false; } return res ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static boolean isRectangularArray(int x) { return false ; } public static boolean isRectangularArray(boolean x) { return false ; } public static boolean isRectangularArray(byte x) { return false ; } public static boolean isRectangularArray(long x) { return false ; } public static boolean isRectangularArray(short x) { return false ; } public static boolean isRectangularArray(double x) { return false ; } public static boolean isRectangularArray(char x) { return false ; } public static boolean isRectangularArray(float x) { return false ; } // }}} // {{{ getDimensionLength /** * Returns the number of dimensions of an array * * @param o an array * @throws NotAnArrayException if this is not an array */ public static int getDimensionLength( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; int n = 0; while( clazz.isArray() ){ n++ ; clazz = clazz.getComponentType() ; } return n ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int getDimensionLength(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getDimensionLength(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getDimensionLength(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getDimensionLength(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getDimensionLength(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getDimensionLength(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getDimensionLength(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getDimensionLength(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ getDimensions /** * Returns the dimensions of an array * * @param o an array * @throws NotAnArrayException if this is not an array * @return the dimensions of the array or null if the object is null */ public static int[] getDimensions( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; Object a = o ; int n = getDimensionLength( o ) ; int[] dims = new int[n] ; int i=0; int current ; while( clazz.isArray() ){ current = Array.getLength( a ) ; dims[i] = current ; i++; if( current == 0 ){ break ; // the while loop } else { a = Array.get( a, 0 ) ; clazz = clazz.getComponentType() ; } } /* in case of premature stop, we fill the rest of the array with 0 */ // this might not be true: // Object[][] = new Object[0][10] will return c(0,0) while( i < dims.length){ dims[i] = 0 ; i++ ; } return dims ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int[] getDimensions(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int[] getDimensions(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int[] getDimensions(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int[] getDimensions(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int[] getDimensions(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int[] getDimensions(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int[] getDimensions(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int[] getDimensions(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ getTrueLength /** * Returns the true length of an array (the product of its dimensions) * * @param o an array * @throws NotAnArrayException if this is not an array * @return the number of objects in the array (the product of its dimensions). */ public static int getTrueLength( Object o) throws NotAnArrayException, NullPointerException { if( o == null ) throw new NullPointerException( "array is null" ) ; Class clazz = o.getClass(); if( !clazz.isArray() ) throw new NotAnArrayException(clazz) ; Object a = o ; int len = 1 ; int i = 0; while( clazz.isArray() ){ len = len * Array.getLength( a ) ; if( len == 0 ) return 0 ; /* no need to go further */ i++; a = Array.get( a, 0 ) ; clazz = clazz.getComponentType() ; } return len ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static int getTrueLength(int x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : int ") ; } public static int getTrueLength(boolean x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : boolean ") ; } public static int getTrueLength(byte x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : byte ") ; } public static int getTrueLength(long x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : long ") ; } public static int getTrueLength(short x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : short ") ; } public static int getTrueLength(double x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : double ") ; } public static int getTrueLength(char x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : char ") ; } public static int getTrueLength(float x) throws NotAnArrayException { throw new NotAnArrayException("primitive type : float ") ; } // }}} // {{{ isArray /** * Indicates if a java object is an array * * @param o object * @return true if the object is an array * @deprecated use RJavaArrayTools#isArray */ public static boolean isArray(Object o){ if( o == null) return false ; return o.getClass().isArray() ; } // thoose below make java < 1.5 happy and me unhappy ;-) public static boolean isArray(int x){ return false ; } public static boolean isArray(boolean x){ return false ; } public static boolean isArray(byte x){ return false ; } public static boolean isArray(long x){ return false ; } public static boolean isArray(short x){ return false ; } public static boolean isArray(double x){ return false ; } public static boolean isArray(char x){ return false ; } public static boolean isArray(float x){ return false ; } // }}} // {{{ ArrayDimensionMismatchException public static class ArrayDimensionMismatchException extends Exception { public ArrayDimensionMismatchException( int index_dim, int actual_dim ){ super( "dimension of indexer (" + index_dim + ") too large for array (depth ="+ actual_dim+ ")") ; } } // }}} // {{{ get /** * Gets a single object from a multi dimensional array * * @param array java array * @param position */ public static Object get( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.get( getArray( array, position ), position[ position.length -1] ); } public static int getInt( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getInt( getArray( array, position ), position[ position.length -1] ); } public static boolean getBoolean( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getBoolean( getArray( array, position ), position[ position.length -1] ); } public static byte getByte( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getByte( getArray( array, position ), position[ position.length -1] ); } public static long getLong( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getLong( getArray( array, position ), position[ position.length -1] ); } public static short getShort( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getShort( getArray( array, position ), position[ position.length -1] ); } public static double getDouble( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getDouble( getArray( array, position ), position[ position.length -1] ); } public static char getChar( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getChar( getArray( array, position ), position[ position.length -1] ); } public static float getFloat( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException { return Array.getFloat( getArray( array, position ), position[ position.length -1] ); } public static Object get( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return get( array, new int[]{position} ) ; } public static int getInt( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getInt( array, new int[]{position} ) ; } public static boolean getBoolean( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getBoolean( array, new int[]{position} ) ; } public static byte getByte( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getByte( array, new int[]{position} ) ; } public static long getLong( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getLong( array, new int[]{position} ) ; } public static short getShort( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getShort( array, new int[]{position} ) ; } public static double getDouble( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getDouble( array, new int[]{position} ) ; } public static char getChar( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getChar( array, new int[]{position} ) ; } public static float getFloat( Object array, int position ) throws NotAnArrayException, ArrayDimensionMismatchException { return getFloat( array, new int[]{position} ) ; } private static void checkDimensions(Object array, int[] position) throws NotAnArrayException, ArrayDimensionMismatchException { int poslength = position.length ; int actuallength = getDimensionLength(array); if( poslength > actuallength ){ throw new ArrayDimensionMismatchException( poslength, actuallength ) ; } } // }}} // {{{ set /** * Replaces a single value of the array * * @param array array * @param position index * @param value the new value * * @throws NotAnArrayException if array is not an array * @throws ArrayDimensionMismatchException if the length of position is too big */ public static void set( Object array, int[] position, Object value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.set( getArray( array, position ), position[ position.length - 1], value ) ; } /* primitive versions */ public static void set( Object array, int[] position, int value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setInt( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, boolean value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setBoolean( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, byte value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setByte( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, long value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setLong( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, short value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setShort( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, double value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setDouble( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, char value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setChar( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int[] position, float value ) throws NotAnArrayException, ArrayDimensionMismatchException{ Array.setFloat( getArray( array, position ), position[ position.length - 1], value ) ; } public static void set( Object array, int position, Object value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, int value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, boolean value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, byte value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, long value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, short value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, double value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, char value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } public static void set( Object array, int position, float value ) throws NotAnArrayException, ArrayDimensionMismatchException{ set( array, new int[]{ position }, value ); } private static Object getArray( Object array, int[] position ) throws NotAnArrayException, ArrayDimensionMismatchException{ checkDimensions( array, position ) ; int poslength = position.length ; Object o = array ; int i=0 ; if( poslength > 1 ){ while( i< (poslength-1) ){ o = Array.get( o, position[i] ) ; i++ ; } } return o ; } // TODO: also have primitive types in value // }}} // {{{ unique // TODO: cannot use LinkedHashSet because it first was introduced in 1.4 // and code in this area needs to work on 1.2 jvm public static Object[] unique( Object[] array ){ int n = array.length ; boolean[] unique = new boolean[ array.length ]; for( int i=0; i?@ HAB íCDEFGH íIJKLMNOPQRSTU HVW ^X íYZ[\]^ í_`abcdefghijk Hlm ^n íopqrst íuvwxyz{|}~€ H‚ƒ ^„ í…†‡ˆ‰Š í‹ŒŽ‘’“”•–—˜™š H›œ 힟 ¡¢ í£¤¥¦§¨© "ª«¬­©®¯° H±²³³´ "µ "¶· í¸¹º»¼½ í¾¿ÀÁÂÃÄÅ()VCodeLineNumberTablemain([Ljava/lang/String;)V StackMapTableruntests Exceptions flatten_int_1Æ flatten_int_2Ç flatten_int_3Èflatten_boolean_1Éflatten_boolean_2Êflatten_boolean_3Ëflatten_byte_1Ìflatten_byte_2Íflatten_byte_3Îflatten_long_1Ïflatten_long_2Ðflatten_long_3Ñflatten_short_1Òflatten_short_2Óflatten_short_3Ôflatten_double_1Õflatten_double_2Öflatten_double_3×flatten_char_1Øflatten_char_2Ùflatten_char_3Úflatten_float_1Ûflatten_float_2Üflatten_float_3Ýflatten_String_1Þflatten_String_2ßflatten_String_3àflatten_Point_1flatten_Point_2áflatten_Point_3â SourceFileArrayWrapper_Test.java AB HB TestException ãBä åæ çè ALL PASSED é êë flatten int[] JBPASSEDflatten int[][] LBflatten int[][][] NBflatten boolean[] PBflatten boolean[][] RBflatten boolean[][][] TBflatten byte[] VBflatten byte[][] XBflatten byte[][][] ZBflatten long[] \Bflatten long[][] ^Bflatten long[][][] `Bflatten short[] bBflatten short[][] dBflatten short[][][] fBflatten double[] hBflatten double[][] jBflatten double[][][] lBflatten char[] nBflatten char[][] pBflatten char[][][] rBflatten float[] tBflatten float[][] vBflatten float[][][] xBflatten String[] zBflatten String[][] |Bflatten String[][][] ~Bflatten Point[] €Bflatten Point[][] Bflatten Point[][][] ƒB >> new ArrayWrapper( int[] ) ìë ArrayWrapper AíNotAnArrayException/new ArrayWrapper(int[]) >> NotAnArrayException Aëok >> isPrimitive() îï!ArrayWrapper(int[]) not primitive true : ok >> getObjectTypeName() ðñI òó.ArrayWrapper(int[]).getObjectTypeName() != 'I' I : ok >> flat_int() ôõPrimitiveArrayException FlatException(new ArrayWrapper(int[]) >> FlatExceptionjava/lang/StringBuilderflat[ ö÷ öø] = != ùñ okú ûü! >> new ArrayWrapper( int[][] ) 1new ArrayWrapper(int[][]) >> NotAnArrayException #ArrayWrapper(int[][]) not primitive0ArrayWrapper(int[][]).getObjectTypeName() != 'I'*new ArrayWrapper(int[][]) >> FlatException ýþ# >> new ArrayWrapper( int[][][] ) 3new ArrayWrapper(int[][][]) >> NotAnArrayException %ArrayWrapper(int[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'I',new ArrayWrapper(int[][][]) >> FlatException# >> new ArrayWrapper( boolean[] ) 3new ArrayWrapper(boolean[]) >> NotAnArrayException %ArrayWrapper(boolean[]) not primitiveZ2ArrayWrapper(boolean[]).getObjectTypeName() != 'Z' Z : ok >> flat_boolean() ÿ ö % >> new ArrayWrapper( boolean[][] ) 5new ArrayWrapper(boolean[][]) >> NotAnArrayException 'ArrayWrapper(boolean[][]) not primitive4ArrayWrapper(boolean[][]).getObjectTypeName() != 'Z'.new ArrayWrapper(boolean[][]) >> FlatException ' >> new ArrayWrapper( boolean[][][] ) 7new ArrayWrapper(boolean[][][]) >> NotAnArrayException )ArrayWrapper(boolean[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'Z'0new ArrayWrapper(boolean[][][]) >> FlatException >> new ArrayWrapper( byte[] ) 0new ArrayWrapper(byte[]) >> NotAnArrayException "ArrayWrapper(byte[]) not primitiveB/ArrayWrapper(byte[]).getObjectTypeName() != 'I' B : ok >> flat_byte() )new ArrayWrapper(byte[]) >> FlatException  " >> new ArrayWrapper( byte[][] ) 2new ArrayWrapper(byte[][]) >> NotAnArrayException $ArrayWrapper(byte[][]) not primitive1ArrayWrapper(byte[][]).getObjectTypeName() != 'B'+new ArrayWrapper(byte[][]) >> FlatException   $ >> new ArrayWrapper( byte[][][] ) 4new ArrayWrapper(byte[][][]) >> NotAnArrayException &ArrayWrapper(byte[][][]) not primitive2ArrayWrapper(int[][][]).getObjectTypeName() != 'B'-new ArrayWrapper(byte[][][]) >> FlatException >> new ArrayWrapper( long[] ) 0new ArrayWrapper(long[]) >> NotAnArrayException "ArrayWrapper(long[]) not primitiveJ/ArrayWrapper(long[]).getObjectTypeName() != 'J' J : ok >> flat_long()   )new ArrayWrapper(long[]) >> FlatException ö " >> new ArrayWrapper( long[][] ) 2new ArrayWrapper(long[][]) >> NotAnArrayException $ArrayWrapper(long[][]) not primitive1ArrayWrapper(long[][]).getObjectTypeName() != 'J'+new ArrayWrapper(long[][]) >> FlatException $ >> new ArrayWrapper( long[][][] ) 4new ArrayWrapper(long[][][]) >> NotAnArrayException &ArrayWrapper(long[][][]) not primitive3ArrayWrapper(long[][][]).getObjectTypeName() != 'J'-new ArrayWrapper(long[][][]) >> FlatException! >> new ArrayWrapper( short[] ) 1new ArrayWrapper(short[]) >> NotAnArrayException #ArrayWrapper(short[]) not primitiveS/ArrayWrapper(long[]).getObjectTypeName() != 'S' S : ok >> flat_short() *new ArrayWrapper(short[]) >> FlatException # >> new ArrayWrapper( short[][] ) 3new ArrayWrapper(short[][]) >> NotAnArrayException %ArrayWrapper(short[][]) not primitive2ArrayWrapper(short[][]).getObjectTypeName() != 'S',new ArrayWrapper(short[][]) >> FlatException % >> new ArrayWrapper( short[][][] ) 5new ArrayWrapper(short[][][]) >> NotAnArrayException 'ArrayWrapper(short[][][]) not primitive4ArrayWrapper(short[][][]).getObjectTypeName() != 'S'.new ArrayWrapper(short[][][]) >> FlatException" >> new ArrayWrapper( double[] ) 2new ArrayWrapper(double[]) >> NotAnArrayException $ArrayWrapper(double[]) not primitiveD1ArrayWrapper(double[]).getObjectTypeName() != 'D' D : ok >> flat_double() +new ArrayWrapper(double[]) >> FlatException ö $ >> new ArrayWrapper( double[][] ) 4new ArrayWrapper(double[][]) >> NotAnArrayException &ArrayWrapper(double[][]) not primitive3ArrayWrapper(double[][]).getObjectTypeName() != 'D'-new ArrayWrapper(double[][]) >> FlatException & >> new ArrayWrapper( double[][][] ) 6new ArrayWrapper(double[][][]) >> NotAnArrayException (ArrayWrapper(double[][][]) not primitive5ArrayWrapper(double[][][]).getObjectTypeName() != 'D'/new ArrayWrapper(double[][][]) >> FlatException >> new ArrayWrapper( char[] ) 0new ArrayWrapper(char[]) >> NotAnArrayException "ArrayWrapper(char[]) not primitiveC/ArrayWrapper(char[]).getObjectTypeName() != 'C' C : ok >> flat_char()  !)new ArrayWrapper(char[]) >> FlatException ö" #$" >> new ArrayWrapper( char[][] ) 2new ArrayWrapper(char[][]) >> NotAnArrayException $ArrayWrapper(char[][]) not primitive1ArrayWrapper(char[][]).getObjectTypeName() != 'C'+new ArrayWrapper(char[][]) >> FlatException %&$ >> new ArrayWrapper( char[][][] ) 4new ArrayWrapper(char[][][]) >> NotAnArrayException &ArrayWrapper(char[][][]) not primitive3ArrayWrapper(char[][][]).getObjectTypeName() != 'C'-new ArrayWrapper(char[][][]) >> FlatException! >> new ArrayWrapper( float[] ) 1new ArrayWrapper(float[]) >> NotAnArrayException #ArrayWrapper(float[]) not primitiveF0ArrayWrapper(float[]).getObjectTypeName() != 'F' F : ok >> flat_float() '(*new ArrayWrapper(float[]) >> FlatException ö) *+# >> new ArrayWrapper( float[][] ) 3new ArrayWrapper(float[][]) >> NotAnArrayException %ArrayWrapper(float[][]) not primitive2ArrayWrapper(float[][]).getObjectTypeName() != 'F',new ArrayWrapper(float[][]) >> FlatException ,-% >> new ArrayWrapper( float[][][] ) 5new ArrayWrapper(float[][][]) >> NotAnArrayException 'ArrayWrapper(float[][][]) not primitive4ArrayWrapper(float[][][]).getObjectTypeName() != 'F'.new ArrayWrapper(float[][][]) >> FlatExceptionjava/lang/String" >> new ArrayWrapper( String[] ) 2new ArrayWrapper(String[]) >> NotAnArrayException #ArrayWrapper(String[]) is primitive false : okjava.lang.String?ArrayWrapper(float[]).getObjectTypeName() != 'java.lang.String' java.lang.String : ok >> flat_String() ./+new ArrayWrapper(String[]) >> FlatException 01$ >> new ArrayWrapper( String[][] ) 4new ArrayWrapper(String[][]) >> NotAnArrayException %ArrayWrapper(String[][]) is primitiveAArrayWrapper(float[][]).getObjectTypeName() != 'java.lang.String'-new ArrayWrapper(String[][]) >> FlatException 23& >> new ArrayWrapper( String[][][] ) 6new ArrayWrapper(String[][][]) >> NotAnArrayException 'ArrayWrapper(String[][][]) is primitiveDArrayWrapper(String[][][]).getObjectTypeName() != 'java.lang.String'/new ArrayWrapper(String[][][]) >> FlatException DummyPoint A4& >> new ArrayWrapper( DummyPoint[] ) 6new ArrayWrapper(DummyPoint[]) >> NotAnArrayException 'ArrayWrapper(DummyPoint[]) is primitive>ArrayWrapper(DummyPoint[]).getObjectTypeName() != 'DummyPoint' DummyPoint : ok >> flat_Object() 56 [LDummyPoint;ObjectArrayException/new ArrayWrapper(DummyPoint[]) >> FlatException 7Ü 8Ü].x = 9:( >> new ArrayWrapper( DummyPoint[][] ) 8new ArrayWrapper(DummyPoint[][]) >> NotAnArrayException )ArrayWrapper(DummyPoint[][]) is primitive@ArrayWrapper(DummyPoint[][]).getObjectTypeName() != 'DummyPoint'1new ArrayWrapper(DummyPoint[][]) >> FlatException ;<* >> new ArrayWrapper( DummyPoint[][][] ) :new ArrayWrapper(DummyPoint[][][]) >> NotAnArrayException +ArrayWrapper(DummyPoint[][][]) is primitiveBArrayWrapper(DummyPoint[][][]).getObjectTypeName() != 'DummyPoint'/new ArrayWrapper(Object[][][]) >> FlatExceptionArrayWrapper_Testjava/lang/Object[I[[I[[[I[Z[[Z[[[Z[B[[B[[[B[J[[J[[[J[S[[S[[[S[D[[D[[[D[C[[C[[[C[F[[F[[[F[Ljava/lang/String;[[Ljava/lang/String;[[[Ljava/lang/String;[[LDummyPoint;[[[LDummyPoint;printStackTracejava/lang/Systemexit(I)VoutLjava/io/PrintStream;java/io/PrintStreamprintln(Ljava/lang/String;)Vprint(Ljava/lang/Object;)V isPrimitive()ZgetObjectTypeName()Ljava/lang/String;equals(Ljava/lang/Object;)Zflat_int()[Iappend-(Ljava/lang/String;)Ljava/lang/StringBuilder;(I)Ljava/lang/StringBuilder;toStringRectangularArrayExamples#getIntDoubleRectangularArrayExample()[[I#getIntTripleRectangularArrayExample()[[[I flat_boolean()[Z(Z)Ljava/lang/StringBuilder;'getBooleanDoubleRectangularArrayExample()[[Z'getBooleanTripleRectangularArrayExample()[[[Z flat_byte()[B$getByteDoubleRectangularArrayExample()[[B$getByteTripleRectangularArrayExample()[[[B flat_long()[J(J)Ljava/lang/StringBuilder;$getLongDoubleRectangularArrayExample()[[J$getLongTripleRectangularArrayExample()[[[J flat_short()[S%getShortDoubleRectangularArrayExample()[[S%getShortTripleRectangularArrayExample()[[[S flat_double()[D(D)Ljava/lang/StringBuilder;&getDoubleDoubleRectangularArrayExample()[[D&getDoubleTripleRectangularArrayExample()[[[D flat_char()[C(C)Ljava/lang/StringBuilder;$getCharDoubleRectangularArrayExample()[[C$getCharTripleRectangularArrayExample()[[[C flat_float()[F(F)Ljava/lang/StringBuilder;%getFloatDoubleRectangularArrayExample()[[F%getFloatTripleRectangularArrayExample()[[[F flat_String()[Ljava/lang/String;&getStringDoubleRectangularArrayExample()[[Ljava/lang/String;&getStringTripleRectangularArrayExample()[[[Ljava/lang/String;(II)V flat_Object()[Ljava/lang/Object;xy*getDummyPointDoubleRectangularArrayExample()[[LDummyPoint;*getDummyPointTripleRectangularArrayExample()[[[LDummyPoint;!?@!ABC*·±D EFCe¸§ L+¶¸²¶¸±D"   GF HBC»;² ¶¸ ² ¶² ¶¸ ² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶²¶¸² ¶² ¶¸!² ¶²"¶¸#² ¶²$¶¸%² ¶²&¶¸'² ¶²(¶¸)² ¶²*¶¸+² ¶²,¶¸-² ¶².¶¸/² ¶²0¶¸1² ¶²2¶¸3² ¶²4¶¸5² ¶²6¶¸7² ¶²8¶¸9² ¶²:¶¸;² ¶²<¶¸=² ¶²>¶¸?² ¶²@¶¸A² ¶²B¶¸C² ¶²D¶¸E² ¶±Dn[  !&#.$1%9)A*D+L-T.W/_1g2j3r7z8}9…;<=˜? @£A«E³F¶G¾IÆJÉKÑMÙNÜOäSìTïU÷WÿXY [\]a%b(c0e8f;gCiKjNkVo^paqisqttu|w„x‡y}—~š¢ª‚­ƒµ…½†À‡ÈÐŽÓÛ‘ã’æ“î•ö–ù—› œ Ÿ ¡'£/¤2¥:©I JBCÒ÷¼ K<¢ *O„§ÿôL²F¶G»HY*·IL§M»YK·L¿²M¶²N¶G+¶Oš »YP·L¿²Q¶²R¶G+¶ST¶Uš »YV·L¿²W¶²X¶G+¶YM§N»Y[·L¿N»Y]·L¿>¢?,.Ÿ2»Y»^Y·_`¶a¶bc¶a,.¶bd¶a¶b¶e·L¿„§ÿ²f¶±(+J’•Z’ \Dv±²´µ·(º+¸,¹6»>½F¾M¿WÁ_ÃgÄsÅ}Ç…É̒ѕ͖ΠϡЫӲÔèÓîÖöØG5 ýKúÿKHJ %WZJ\ü Kü:úI LBC´ç¸gKL²h¶G»HY*·IL§M»Yi·L¿²M¶²N¶G+¶Oš »Yj·L¿²Q¶²R¶G+¶ST¶Uš »Yk·L¿²W¶²X¶G+¶YM§N»Y[·L¿N»Yl·L¿> ¢?,.Ÿ2»Y»^Y·_`¶a¶bc¶a,.¶bd¶a¶b¶e·L¿„§ÿÁ²f¶±J|„Z|\DrÞàáãæäå%ç-é5ê<ëFíNïVðbñlótõ|øý„ù…úûüš¢ØÞæG+ ÿMHJ %WZJ\ü Kü;úI NBC´ç¸mKL²n¶G»HY*·IL§M»Yo·L¿²M¶²N¶G+¶Oš »Yp·L¿²Q¶²R¶G+¶ST¶Uš »Yq·L¿²W¶²X¶G+¶YM§N»Y[·L¿N»Yr·L¿>¢?,.Ÿ2»Y»^Y·_`¶a¶bc¶a,.¶bd¶a¶b¶e·L¿„§ÿÁ²f¶±J|„Z|\Dr  %-5<FNVbl t"|%*„&…'()š,¢-Ø,Þ/æ1G+ ÿOHJ %WZJ\ü Kü;úI PBC ¼K<=¢*Tš§<„§ÿêM²s¶G»HY*·IM§N»Yt·L¿²M¶²N¶G,¶Oš »Yu·L¿²Q¶²R¶G,¶Sv¶Uš »Yw·L¿²x¶²y¶G,¶zN§:»Y[·L¿:»Y]·L¿<6¢C-3Ÿ+»Y»^Y·_`¶a¶bc¶a-3¶{¶e·L¿š§<„§ÿ½²f¶±+47J™ž¡Z™ž­\DŽ#:;< =><!A#B+D4G7E8FBHJJRKYLcNkPsQR‰T‘V™Yž^¡Z£[­\¯]¹`»aÄbôcþae gG=þQ@úÿQHJ %WZK\ü Qü5@úI RBCÈï¸|KL²}¶G»HY*·IL§M»Y~·L¿²M¶²N¶G+¶Oš »Y·L¿²Q¶²R¶G+¶Sv¶Uš »Y€·L¿²x¶²y¶G+¶zM§N»Y[·L¿N»Y·L¿>6 ¢C,3Ÿ+»Y»^Y·_`¶a¶bc¶a,3¶{¶e·L¿š§>„§ÿ¼²f¶±J|„Z|\Dzmoprust%v-x5y<zF|N~Vb€l‚t„|‡Œ„ˆ…‰Š‹šŽœ¦Ö‘àæ“î•G/ ÿSHJ %WZJ\ü Qý6@úI TBCÈ︂KL²ƒ¶G»HY*·IL§M»Y„·L¿²M¶²N¶G+¶Oš »Y…·L¿²Q¶²R¶G+¶Sv¶Uš »Y†·L¿²x¶²y¶G+¶zM§N»Y[·L¿N»Y‡·L¿>6¢C,3Ÿ+»Y»^Y·_`¶a¶bc¶a,3¶{¶e·L¿š§>„§ÿ¼²f¶±J|„Z|\Dz›ž £¡¢%¤-¦5§<¨FªN¬V­b®l°t²|µº„¶…·¸¹š¼œ½¦¾Ö¿à½æÁîÃG/ ÿUHJ %WZJ\ü Qý6@úI VBCÔù¼K<¢*‘T„§ÿóL²ˆ¶G»HY*·IL§M»Y‰·L¿²M¶²N¶G+¶Oš »YŠ·L¿²Q¶²R¶G+¶S‹¶Uš »YŒ·L¿²¶²޶G+¶M§N»Y[·L¿N»Y·L¿>¢@,3‘Ÿ2»Y»^Y·_`¶a¶bc¶a,3¶bd¶a¶b¶e·L¿„§ÿÁ²f¶± ),JŽ“–ZŽ“¡\DvÌÍÏÐ Ò)Õ,Ó-Ô7Ö?ØGÙNÚXÜ`Þhßtà~â†äŽç“ì–è—é¡ê¢ë¬î³ïêîðñøóG5 ýWúÿWHJ %WZJ\ü Wü;úI XBCµ踑KL²’¶G»HY*·IL§M»Y“·L¿²M¶²N¶G+¶Oš »Y”·L¿²Q¶²R¶G+¶S‹¶Uš »Y•·L¿²¶²޶G+¶M§N»Y[·L¿N»Y–·L¿> ¢@,3‘Ÿ2»Y»^Y·_`¶a¶bc¶a,3¶bd¶a¶b¶e·L¿„§ÿÀ²f¶±J|„Z|\Drùüýÿ%-5<F N V b lt|„…š¢Ùßç!G+ ÿYHJ %WZJ\ü Wü<úI ZBCµ踗KL²˜¶G»HY*·IL§M»Y™·L¿²M¶²N¶G+¶Oš »Yš·L¿²Q¶²R¶G+¶S‹¶Uš »Y›·L¿²¶²޶G+¶M§N»Y[·L¿N»Yœ·L¿>¢@,3‘Ÿ2»Y»^Y·_`¶a¶bc¶a,3¶bd¶a¶b¶e·L¿„§ÿÀ²f¶±J|„Z|\Dr')*,/-.%0-253<4F6N8V9b:l<t>|AF„B…CDEšI¢JÙIßLçNG+ ÿ[HJ %WZJ\ü Wü<úI \BCÕú¼ K<¢*…P„§ÿóL²¶G»HY*·IL§M»Yž·L¿²M¶²N¶G+¶Oš »YŸ·L¿²Q¶²R¶G+¶S ¶Uš »Y¡·L¿²¢¶²£¶G+¶¤M§N»Y[·L¿N»Y¥·L¿>¢A,/…”™2»Y»^Y·_`¶a¶bc¶a,/¶¦d¶a¶b¶e·L¿„§ÿÀ²f¶± ),JŽ“–ZŽ“¡\DvUVXY [)^,\-]7_?aGbNcXe`ghhti~k†mŽp“u–q—r¡s¢t¬w³xëwñzù|G5 ý]úÿ]HJ %WZJ\ü ]ü<úI ^BC¶鸧KL²¨¶G»HY*·IL§M»Y©·L¿²M¶²N¶G+¶Oš »Yª·L¿²Q¶²R¶G+¶S ¶Uš »Y«·L¿²¢¶²£¶G+¶¤M§N»Y[·L¿N»Y¬·L¿> ¢A,/…”™2»Y»^Y·_`¶a¶bc¶a,/¶¦d¶a¶b¶e·L¿„§ÿ¿²f¶±J|„Z|\Dr‚…†ˆ‹‰Š%Œ-Ž5<F’N”V•b–l˜tš|¢„ž…Ÿ ¡š¥¢¦Ú¥à¨èªG+ ÿ_HJ %WZJ\ü ]ü=úI `BC¶鸭KL²®¶G»HY*·IL§M»Y¯·L¿²M¶²N¶G+¶Oš »Y°·L¿²Q¶²R¶G+¶S ¶Uš »Y±·L¿²¢¶²£¶G+¶¤M§N»Y[·L¿N»Y²·L¿>¢A,/…”™2»Y»^Y·_`¶a¶bc¶a,/¶¦d¶a¶b¶e·L¿„§ÿ¿²f¶±J|„Z|\Dr°²³µ¸¶·%¹-»5¼<½F¿NÁVÂbÃlÅtÇ|Êτ˅ÌÍΚÒ¢ÓÚÒàÕè×G+ ÿaHJ %WZJ\ü ]ü=úI bBCÖû¼ K<¢*“V„§ÿóL²³¶G»HY*·IL§M»Y´·L¿²M¶²N¶G+¶Oš »Yµ·L¿²Q¶²R¶G+¶S¶¶Uš »Y··L¿²¸¶²¹¶G+¶ºM§N»Y[·L¿N»Y»·L¿>¢B,5‡‡—™2»Y»^Y·_`¶a¶bc¶a,5¶bd¶a¶b¶e·L¿„§ÿ¿²f¶± ),JŽ“–ZŽ“¡\Dvßàâã å)è,æ-ç7é?ëGìNíXï`ñhòtó~õ†÷Žú“ÿ–û—ü¡ý¢þ¬³ìòúG5 ýcúÿcHJ %WZJ\ü cü=úI dBC·긼KL²½¶G»HY*·IL§M»Y¾·L¿²M¶²N¶G+¶Oš »Y¿·L¿²Q¶²R¶G+¶S¶¶Uš »YÀ·L¿²¸¶²¹¶G+¶ºM§N»Y[·L¿N»YÁ·L¿> ¢B,5‡‡—™2»Y»^Y·_`¶a¶bc¶a,5¶bd¶a¶b¶e·L¿„§ÿ¾²f¶±J|„Z|\Dr %-5<FNVb l"t$|',„(…)*+š/¢0Û/á2é4G+ ÿeHJ %WZJ\ü cü>úI fBC·ê¸ÂKL²öG»HY*·IL§M»YÄ·L¿²M¶²N¶G+¶Oš »YÅ·L¿²Q¶²R¶G+¶S¶¶Uš »YÆ·L¿²¸¶²¹¶G+¶ºM§N»Y[·L¿N»YÇ·L¿>¢B,5‡‡—™2»Y»^Y·_`¶a¶bc¶a,5¶bd¶a¶b¶e·L¿„§ÿ¾²f¶±J|„Z|\Dr:<=?B@A%C-E5F<GFINKVLbMlOtQ|TY„U…VWXš\¢]Û\á_éaG+ ÿgHJ %WZJ\ü cü>úI hBCÙþ¼K<¢*‡cR„§ÿñL²ȶG»HY*·IL§M»YÉ·L¿²M¶²N¶G+¶Oš »YÊ·L¿²Q¶²R¶G+¶S˶Uš »YÌ·L¿²Ͷ²ζG+¶ÏM§N»Y[·L¿N»YзL¿>¢C,1‡c—™2»Y»^Y·_`¶a¶bc¶a,1¶Ñd¶a¶b¶e·L¿„§ÿ¾²f¶±"+.J•˜Z•£\Dvijlm"o+r.p/q9sAuIvPwZyb{j|v}€ˆ„•‰˜…™†£‡¤ˆ®‹µŒï‹õŽýG5 ýiúÿiHJ %WZJ\ü iü>úI jBC¸ë¸ÒKL²Ó¶G»HY*·IL§M»YÔ·L¿²M¶²N¶G+¶Oš »YÕ·L¿²Q¶²R¶G+¶S˶Uš »YÖ·L¿²Ͷ²ζG+¶ÏM§N»Y[·L¿N»Y×·L¿> ¢C,1‡c—™2»Y»^Y·_`¶a¶bc¶a,1¶Ñd¶a¶b¶e·L¿„§ÿ½²f¶±J|„Z|\Dr–˜™›žœ%Ÿ-¡5¢<£F¥N§V¨b©l«t­|°µ„±…²³´š¸¢¹Ü¸â»ê½G+ ÿkHJ %WZJ\ü iü?úI lBC¸ë¸ØKL²Ù¶G»HY*·IL§M»YÚ·L¿²M¶²N¶G+¶Oš »YÛ·L¿²Q¶²R¶G+¶S˶Uš »YÜ·L¿²Ͷ²ζG+¶ÏM§N»Y[·L¿N»YÝ·L¿>¢C,1‡c—™2»Y»^Y·_`¶a¶bc¶a,1¶Ñd¶a¶b¶e·L¿„§ÿ½²f¶±J|„Z|\DrÃÅÆÈËÉÊ%Ì-Î5Ï<ÐFÒNÔVÕbÖlØtÚ|Ýâ„Þ…ßàášå¢æÜåâèêêG+ ÿmHJ %WZJ\ü iü?úI nBCÔù¼K<¢*’U„§ÿóL²Þ¶G»HY*·IL§M»Yß·L¿²M¶²N¶G+¶Oš »Yà·L¿²Q¶²R¶G+¶Sá¶Uš »Yâ·L¿²ã¶²ä¶G+¶åM§N»Y[·L¿N»Yæ·L¿>¢@,4’Ÿ2»Y»^Y·_`¶a¶bc¶a,4¶çd¶a¶b¶e·L¿„§ÿÁ²f¶± ),JŽ“–ZŽ“¡\Dvñòôõ ÷)ú,ø-ù7û?ýGþNÿX`ht~† Ž “– —¡¢¬³êðøG5 ýoúÿoHJ %WZJ\ü oü;úI pBC»ì¸èKL²é¶G»HY*·IL§M»Yê·L¿²M¶²N¶G+¶Oš »Yë·L¿²Q¶²R¶G+¶Sá¶Uš »Yì·L¿²ã¶²ä¶G+¶åM§N»Y[·L¿N»Yí·L¿> ¢D,4‡‡c—™2»Y»^Y·_`¶a¶bc¶a,4¶çd¶a¶b¶e·L¿„§ÿ¼²f¶±J|„Z|\Dr!"$'%&%(-*5+<,F.N0V1b2l4t6|9>„:…;<=šA¢BÝAãDëFG- ÿqHJ %WZJ\ü oüû@úI rBCµè¸îKL²ï¶G»HY*·IL§M»Yð·L¿²M¶²N¶G+¶Oš »Yñ·L¿²Q¶²R¶G+¶Sá¶Uš »Yò·L¿²ã¶²ä¶G+¶åM§N»Y[·L¿N»Yó·L¿>¢@,4’Ÿ2»Y»^Y·_`¶a¶bc¶a,4¶çd¶a¶b¶e·L¿„§ÿÀ²f¶±J|„Z|\DrLNOQTRS%U-W5X<YF[N]V^b_latc|fk„g…hijšn¢oÙnßqçsG+ ÿsHJ %WZJ\ü oü<úI tBCÛ¼K<¢*‡cQ„§ÿðL²ô¶G»HY*·IL§M»Yõ·L¿²M¶²N¶G+¶Oš »Yö·L¿²Q¶²R¶G+¶S÷¶Uš »Yø·L¿²ù¶²ú¶G+¶ûM§N»Y[·L¿N»Yü·L¿>¢D,0‡c—™2»Y»^Y·_`¶a¶bc¶a,0¶ýd¶a¶b¶e·L¿„§ÿ½²f¶±#,/J‘–™Z‘–¤\Dv{|~#,„/‚0ƒ:…B‡JˆQ‰[‹ckŽw‘‰“‘––›™—š˜¤™¥š¯¶žñ÷ ÿ¢G5 ýuúÿuHJ %WZJ\ü uü?úI vBC¿ð¸þKL²ÿ¶G»HY*·IL§M»Y·L¿²M¶²N¶G+¶Oš»Y·L¿²Q¶²R¶G+¶S÷¶Uš»Y·L¿²ù¶²ú¶G+¶ûM§N»Y[·L¿N»Y·L¿> ¢D,0‡c—™2»Y»^Y·_`¶a¶bc¶a,0¶ýd¶a¶b¶e·L¿„§ÿ¼²f¶±J„‡Z„’\Dr¨ª«­°®¯&±.³6´=µH·P¹Xºd»o½w¿„LJÈĒœƞʦËáÊçÍïÏG- ÿwHJ !&WZJ\ü uüû@úI xBCÀñ¸KL²¶G»HY*·IL§M»Y·L¿²M¶²N¶G+¶Oš»Y·L¿²Q¶²R¶G+¶S÷¶Uš»Y·L¿²ù¶²ú¶G+¶ûM§N»Y[·L¿N»Y ·L¿>¢D,0‡c•™2»Y»^Y·_`¶a¶bc¶a,0¶ýd¶a¶b¶e·L¿„§ÿ¼²f¶±J€…ˆZ€…“\DrÕרÚÝÛÜ'Þ/à7á>âIäQæYçeèpêxì€ï…ôˆð‰ñ“ò”óŸ÷§øâ÷èúðüG- ÿyHJ !&WZJ\ü uüû@úI zBC*½ K<¢ *»^Y·_ ¶a¶b¶eS„§ÿáL² ¶G»HY*·IL§M»Y ·L¿²M¶²N¶G+¶O™»Y·L¿²¶²R¶G+¶S¶Uš»Y·L¿²¶²¶G+¶M§N»Y[·L¿N»Y·L¿>¢U,2»^Y·_ ¶a¶b¶e¶Uš2»Y»^Y·_`¶a¶bc¶a,2¶ad¶a¶b¶e·L¿„§ÿ¬²f¶±4=@J©®±Z©®¼\Dv) + 4 =@ ALT\cnwŒ— ©!®&±"²#¼$½%È(Ï)(!+)-G7 ý{ú!ÿ{HJ !(YZJ\ü {üûPúI |BCÔ¸KL²¶G»HY*·IL§M»Y·L¿²M¶²N¶G+¶O™»Y·L¿²Q¶²R¶G+¶S¶Uš»Y·L¿²¶²¶G+¶M§N»Y[·L¿N»Y·L¿> ¢U,2»^Y·_ ¶a¶b¶e¶Uš2»Y»^Y·_`¶a¶bc¶a,2¶ad¶a¶b¶e·L¿„§ÿ«²f¶±Jƒˆ‹Zƒˆ–\Dr3568;9:'</>7?>@IBQDYEfFqHzJƒMˆR‹NŒO–P—Q¢UªVöUüXZG- ÿ}HJ !'YZJ\ü {üûQúI ~BCÔ¸KL²¶G»HY*·IL§M»Y·L¿²M¶²N¶G+¶O™»Y·L¿²Q¶²R¶G+¶S¶Uš»Y ·L¿²¶²¶G+¶M§N»Y[·L¿N»Y!·L¿>¢U,2»^Y·_ ¶a¶b¶e¶Uš2»Y»^Y·_`¶a¶bc¶a,2¶ad¶a¶b¶e·L¿„§ÿ«²f¶±Jƒˆ‹Zƒˆ–\Dr`bcehfg'i/k7l>mIoQqYrfsquzwƒzˆ‹{Œ|–}—~¢‚ªƒö‚ü…‡G- ÿHJ !'YZJ\ü {üûQúI €BC#½"K<¢*»"Y·#S„§ÿìL²$¶G»HY*·IL§M»Y%·L¿²M¶²N¶G+¶O™»Y&·L¿²¶²R¶G+¶S'¶Uš»Y(·L¿²)¶²*¶G+¶+À,M§N»Y.·L¿N»Y/·L¿6¢S,2N-´0  -´1Ÿ6»Y»^Y·_`¶a¶b2¶a-´0¶bd¶a¶b¶e·L¿„§ÿ­²f¶±)25Jž¦©-ž¦µ\Dz’ “)•2˜5–6—A™I›QœXcŸl¡t¢£Œ¥•§žª¦¯©«ª¬µ­¶®Á²Ê³Ï´²¶"¸GJ ý,úÿ,HJ !(\-K\ü ,ýÿ,H,"2ùI BCð ¸3KL²4¶G»HY*·IL§M»Y5·L¿²M¶²N¶G+¶O™»Y6·L¿²¶²R¶G+¶S'¶Uš»Y7·L¿²)¶²*¶G+¶+À,M§N»Y.·L¿N»Y8·L¿6 ¢S,2N-´0  -´1Ÿ6»Y»^Y·_`¶a¶b2¶a-´0¶bd¶a¶b¶e·L¿„§ÿ¬²f¶±J„Œ-„Œ›\Dv¾ÀÁÃÆÄÅ'Ç/É7Ê>ËIÍRÏZÐgÑrÓ{Õ„ØŒÝÙÚ›Ûœܧà±á¶âûàä æG@ ÿ‚HJ !(\-K\ü ,ýÿ‚H,"2ùI ƒBCð ¸9KL²:¶G»HY*·IL§M»Y;·L¿²M¶²N¶G+¶O™»Y<·L¿²¶²R¶G+¶S'¶Uš»Y=·L¿²)¶²*¶G+¶+À,M§N»Y.·L¿N»Y>·L¿6¢S,2N-´0  -´1Ÿ6»Y»^Y·_`¶a¶b2¶a-´0¶bd¶a¶b¶e·L¿„§ÿ¬²f¶±J„Œ-„Œ›\Dvìîïñôòó'õ/÷7ø>ùIûRýZþgÿr{„Œ › œ §±¶û G@ ÿ„HJ !(\-K\ü ,ýÿ„H,"2ùI…†rJava/tools/0000755000175100001440000000000015133274032012473 5ustar hornikusersrJava/tools/getsp.class0000644000175100001440000000242115133274032014643 0ustar hornikusersÊþº¾-Q%123CLADEFGH        ! " # $ 4( 4/ =. >) ?, @- I& K9 M/ N* O' P+ ()I()Ljava/lang/String;()V(I)C(II)Ljava/lang/String;&(Ljava/lang/Object;)Ljava/lang/String;(Ljava/lang/String;)I&(Ljava/lang/String;)Ljava/lang/String;,(Ljava/lang/String;)Ljava/lang/StringBuffer;(Ljava/lang/String;)V([Ljava/lang/String;)V-L-libs.Code ConstantValue ExceptionsLineNumberTableLjava/io/PrintStream;LocalVariables SGILineNumber SourceFileappendcharAt compareTo getPropertygetsp getsp.javajava.library.pathjava/io/PrintStreamjava/lang/Objectjava/lang/Stringjava/lang/StringBufferjava/lang/Systemlengthmainoutpath.separatorprintln substringtoStringvalueOf!  J05N Þ*ÆÜ*¾ž×*2¶šÀL*¾¤*2L¸M>6:¸::6ƶž ¶6,¶6§hŸ ,¶ U,¶: `6 ¶™=Ç» Y+¸· ¶¶§ » Y¸·¶+¶ ¶¶:„¤ÿ˜Æ²¶±²*2¸¶±8^ !' , / 6 : OUXhqv€º½ÃÐÑÝ;4(5*· ±8;<B;rJava/tools/install-sh0000755000175100001440000001440615133274032014504 0ustar hornikusers#!/bin/sh # # install - install a program, script, or datafile # # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 rJava/tools/getsp.java0000644000175100001440000000145015133274032014460 0ustar hornikuserspublic class getsp { public static void main(String[] args) { if (args!=null && args.length>0) { if (args[0].compareTo("-libs")==0) { String prefix="-L"; if (args.length>1) prefix=args[1]; String lp=System.getProperty("java.library.path"); // we're not using StringTokenizer in case the JVM is very crude int i=0,j,k=0; String r=null; String pss=System.getProperty("path.separator"); char ps=':'; if (pss!=null && pss.length()>0) ps=pss.charAt(0); j=lp.length(); while (i<=j) { if (i==j || lp.charAt(i)==ps) { String lib=lp.substring(k,i); k=i+1; if (lib.compareTo(".")!=0) r=(r==null)?(prefix+lib):(r+" "+prefix+lib); } i++; } if (r!=null) System.out.println(r); } else System.out.println(System.getProperty(args[0])); } } } rJava/configure0000755000175100001440000047636215133274037013271 0ustar hornikusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for rJava 0.8. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: Simon.Urbanek@r-project.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rJava' PACKAGE_TARNAME='rjava' PACKAGE_VERSION='0.8' PACKAGE_STRING='rJava 0.8' PACKAGE_BUGREPORT='Simon.Urbanek@r-project.org' PACKAGE_URL='' ac_unique_file="src/rJava.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" enable_option_checking=no ac_subst_vars='LTLIBOBJS LIBOBJS subdirs JAVAH JAVAC JAVA JAVA_HOME JAVA_CPPFLAGS JAVA_LIBS WANT_JRI_FALSE WANT_JRI_TRUE USE_DYNLOAD_FALSE USE_DYNLOAD_TRUE EGREP GREP CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC R_HOME target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_threads enable_jni_cache enable_jri enable_headless enable_Xrs enable_dynload enable_debug enable_mem_profile enable_callbacks ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' ac_subdirs_all='jri' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures rJava 0.8 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/rjava] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of rJava 0.8:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-threads enable the use of threads, i.e. Java is run on a separate thread. This is necessary for some implementations of AWT. This feature is highly experimental, becasue of synchronization issues, so use with care. [no] --enable-jni-cache enable support for caching of the JNI environment. With this option turned on, the JNI state is stored locally and re-used for subsequent calls. This will work *only* if no threads are used, because each thread has a separate JNI state. Enabling this option can give some performance boost for applications that call JNI very often. If used in a threaded environment, it is bound to crash, so use with care. [no] --enable-jri enable Java to R interface (JRI), which allows Java programs to embed R. [auto] --enable-headless enable initialization in headless mode. [auto] --enable-Xrs use -Xrs in Java initialization. [auto] --enable-dynload load JVM dynamically (without linking). [auto] --enable-debug enable debug flags and output. [no] --enable-mem-profile enable memory profiling. [debug] --enable-callbacks enable the support for callbacks from Java into R. This requires JRI and is currently experimental/incomplete. [no] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF rJava configure 0.8 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------ ## ## Report this to Simon.Urbanek@r-project.org ## ## ------------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by rJava $as_me 0.8, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers src/config.h" ac_aux_dir= for ac_dir in tools "$srcdir"/tools; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in tools \"$srcdir\"/tools" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # find R home and set CC/CFLAGS : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi RBIN="${R_HOME}/bin/R" CC=`"${RBIN}" CMD config CC`; CFLAGS=`"${RBIN}" CMD config CFLAGS` LIBS="${PKG_LIBS}" RLD=`"${RBIN}" CMD config --ldflags 2>/dev/null` has_R_shlib=no if test -n "$RLD"; then has_R_shlib=yes fi ## enable threads, i.e. Java is running is a separate thread # Check whether --enable-threads was given. if test "${enable_threads+set}" = set; then : enableval=$enable_threads; want_threads="${enableval}" else want_threads=no fi ## enable JNI-cache # Check whether --enable-jni-cache was given. if test "${enable_jni_cache+set}" = set; then : enableval=$enable_jni_cache; want_jni_cache="${enableval}" else want_jni_cache=no fi ## enable JRI # Check whether --enable-jri was given. if test "${enable_jri+set}" = set; then : enableval=$enable_jri; want_jri="${enableval}" else want_jri=auto fi ## enable headless # Check whether --enable-headless was given. if test "${enable_headless+set}" = set; then : enableval=$enable_headless; want_headless="${enableval}" else want_headless=auto fi ## enable -Xrs support # Check whether --enable-Xrs was given. if test "${enable_Xrs+set}" = set; then : enableval=$enable_Xrs; want_xrs="${enableval}" else want_xrs=auto fi ## enable dynloaded JVM # Check whether --enable-dynload was given. if test "${enable_dynload+set}" = set; then : enableval=$enable_dynload; want_dynload="${enableval}" else want_dynload=auto fi ## enable debug flags # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; want_debug="${enableval}" else want_debug=no fi ## enable memory profiling # Check whether --enable-mem-profile was given. if test "${enable_mem_profile+set}" = set; then : enableval=$enable_mem_profile; want_memprof="${enableval}" else want_memprof=debug fi ## enable callbacks (experimental) # Check whether --enable-callbacks was given. if test "${enable_callbacks+set}" = set; then : enableval=$enable_callbacks; want_callbacks="${enableval}" else want_callbacks=no fi # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Checks for libraries. # Checks for header files. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in string.h sys/time.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports static inline..." >&5 $as_echo "$as_me: checking whether ${CC} supports static inline..." >&6;} can_inline=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ static inline int foo(int a, int b); static int f = 1; static inline int foo(int a, int b) { return a+b; } int main(void) { return foo(f,-1); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : can_inline=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${can_inline}" >&5 $as_echo "${can_inline}" >&6; } if test "${can_inline}" = yes; then $as_echo "#define HAVE_STATIC_INLINE 1" >>confdefs.h fi ### from R m4/R.m4 - needed to hack R 2.9.x { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setjmp.h is POSIX.1 compatible" >&5 $as_echo_n "checking whether setjmp.h is POSIX.1 compatible... " >&6; } if ${r_cv_header_setjmp_posix+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { sigjmp_buf b; sigsetjmp(b, 0); siglongjmp(b, 1); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : r_cv_header_setjmp_posix=yes else r_cv_header_setjmp_posix=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $r_cv_header_setjmp_posix" >&5 $as_echo "$r_cv_header_setjmp_posix" >&6; } ac_fn_c_check_decl "$LINENO" "sigsetjmp" "ac_cv_have_decl_sigsetjmp" "#include " if test "x$ac_cv_have_decl_sigsetjmp" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SIGSETJMP $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "siglongjmp" "ac_cv_have_decl_siglongjmp" "#include " if test "x$ac_cv_have_decl_siglongjmp" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SIGLONGJMP $ac_have_decl _ACEOF if test "$ac_cv_have_decl_sigsetjmp" = no; then r_cv_header_setjmp_posix=no fi if test "$ac_cv_have_decl_siglongjmp" = no; then r_cv_header_setjmp_posix=no fi if test "${r_cv_header_setjmp_posix}" = yes; then $as_echo "#define HAVE_POSIX_SETJMP 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking Java support in R" >&5 $as_echo_n "checking Java support in R... " >&6; } R_JAVA_HOME=`"${RBIN}" CMD config JAVA_HOME` : ${JAVA_HOME="${R_JAVA_HOME}"} if test -z "${JAVA_HOME}"; then as_fn_error $? "absent R was configured without Java support. Please run R CMD javareconf as root to add Java support to R. If you do not have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava." "$LINENO" 5 fi : ${JAR=`"${RBIN}" CMD config JAR|sed 's/ERROR:.*//'`} : ${JAVA=`"${RBIN}" CMD config JAVA|sed 's/ERROR:.*//'`} : ${JAVAC=`"${RBIN}" CMD config JAVAC|sed 's/ERROR:.*//'`} : ${JAVAH=`"${RBIN}" CMD config JAVAH|sed 's/ERROR:.*//'`} : ${JAVA_CPPFLAGS=`"${RBIN}" CMD config JAVA_CPPFLAGS|sed 's/ERROR:.*//'`} : ${JAVA_LIBS=`"${RBIN}" CMD config JAVA_LIBS|sed 's/ERROR:.*//'`} { $as_echo "$as_me:${as_lineno-$LINENO}: result: present: interpreter : '${JAVA}' archiver : '${JAR}' compiler : '${JAVAC}' header prep.: '${JAVAH}' cpp flags : '${JAVA_CPPFLAGS}' java libs : '${JAVA_LIBS}'" >&5 $as_echo "present: interpreter : '${JAVA}' archiver : '${JAR}' compiler : '${JAVAC}' header prep.: '${JAVAH}' cpp flags : '${JAVA_CPPFLAGS}' java libs : '${JAVA_LIBS}'" >&6; } java_error='One or more Java configuration variables are not set.' if test -z "${JAVA}"; then java_error='Java interpreter is missing or not registered in R' fi if test -z "${JAVAC}"; then java_error='Java Development Kit (JDK) is missing or not registered in R' fi have_all_flags=no if test -n "${JAVA}" && test -n "${JAVAC}" && \ test -n "${JAVA_CPPFLAGS}" && test -n "${JAVA_LIBS}" && test -n "${JAR}"; then have_all_flags=yes; fi if test "${have_all_flags}" = no; then as_fn_error $? "${java_error} Make sure R is configured with full Java support (including JDK). Run R CMD javareconf as root to add Java support to R. If you don't have root privileges, run R CMD javareconf -e to set all Java-related variables and then install rJava. " "$LINENO" 5 fi if test `echo foo | sed -e 's:foo:bar:'` = bar; then JAVA_CPPFLAGS0=`echo ${JAVA_CPPFLAGS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` JAVA_LD_LIBRARY_PATH0=`echo ${JAVA_LD_LIBRARY_PATH} | sed -e 's:$(JAVA_HOME):'${JAVA_HOME}':g'` else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: sed is not working properly - the configuration may fail" >&5 $as_echo "$as_me: WARNING: sed is not working properly - the configuration may fail" >&2;} JAVA_CPPFLAGS0="${JAVA_CPPFLAGS}" JAVA_LIBS0="${JAVA_LIBS}" JAVA_LD_LIBRARY_PATH0="${JAVA_LD_LIBRARY_PATH}" fi OSNAME=`uname -s 2>/dev/null` LIBS="${LIBS} ${JAVA_LIBS0}" CFLAGS="${CFLAGS} ${JAVA_CPPFLAGS0}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${JAVA_LD_LIBRARY_PATH0}" if test "x$OSNAME" = xDarwin; then ## we need to pull that out of R in case re-export fails (which is does on 10.11) DYLD_FALLBACK_LIBRARY_PATH=`"${RBIN}" --slave --vanilla -e 'cat(Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH"))'` export DYLD_FALLBACK_LIBRARY_PATH fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Java run-time works" >&5 $as_echo_n "checking whether Java run-time works... " >&6; } if "$JAVA" -classpath tools getsp; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "Java interpreter '$JAVA' does not work" "$LINENO" 5 fi has_xrs="$want_xrs" if test x"$has_xrs" = xauto; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Xrs is supported" >&5 $as_echo_n "checking whether -Xrs is supported... " >&6; } if "$JAVA" -Xrs -classpath tools getsp; then has_xrs=yes else has_xrs=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${has_xrs}" >&5 $as_echo "${has_xrs}" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Xrs will be used" >&5 $as_echo_n "checking whether -Xrs will be used... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${has_xrs}" >&5 $as_echo "${has_xrs}" >&6; } if test x"$has_xrs" = xyes; then $as_echo "#define HAVE_XRS 1" >>confdefs.h fi use_dynload="$want_dynload" if test x"$use_dynload" = xauto; then if test "x$OSNAME" = xDarwin; then use_dynload=yes else use_dynload=no fi fi if test x"$use_dynload" != xyes; then use_dynload=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JVM will be loaded dynamically" >&5 $as_echo_n "checking whether JVM will be loaded dynamically... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${use_dynload}" >&5 $as_echo "${use_dynload}" >&6; } if test "x${use_dynload}" = xyes; then USE_DYNLOAD_TRUE= USE_DYNLOAD_FALSE='#' else USE_DYNLOAD_TRUE='#' USE_DYNLOAD_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JNI programs can be compiled" >&5 $as_echo_n "checking whether JNI programs can be compiled... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { jobject o; JNI_CreateJavaVM(0, 0, 0); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else as_fn_error $? "Cannot compile a simple JNI program. See config.log for details. Make sure you have Java Development Kit installed and correctly registered in R. If in doubt, re-run \"R CMD javareconf\" as root. " "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JNI programs run" >&5 $as_echo_n "checking whether JNI programs run... " >&6; } if test "$cross_compiling" = yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: don't know (cross-compiling)" >&5 $as_echo "don't know (cross-compiling)" >&6; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { jsize n; JNI_GetCreatedJavaVMs(NULL, 0, &n); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else as_fn_error $? "Unable to run a simple JNI program. Make sure you have configured R with Java support (see R documentation) and check config.log for failure reason." "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking JNI data types" >&5 $as_echo_n "checking JNI data types... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { return (sizeof(int)==sizeof(jint) && sizeof(long)==sizeof(long) && sizeof(jbyte)==sizeof(char) && sizeof(jshort)==sizeof(short) && sizeof(jfloat)==sizeof(float) && sizeof(jdouble)==sizeof(double))?0:1; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } else as_fn_error $? "One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this." "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test "${want_jri}" = auto; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JRI should be compiled (autodetect)" >&5 $as_echo_n "checking whether JRI should be compiled (autodetect)... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${has_R_shlib}" >&5 $as_echo "${has_R_shlib}" >&6; } want_jri=${has_R_shlib} fi if test "x${want_jri}" = xyes; then WANT_JRI_TRUE= WANT_JRI_FALSE='#' else WANT_JRI_TRUE='#' WANT_JRI_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether debugging output should be enabled" >&5 $as_echo_n "checking whether debugging output should be enabled... " >&6; } if test "${want_debug}" = yes; then JAVA_CPPFLAGS="-g -DRJ_DEBUG ${JAVA_CPPFLAGS}" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memory profiling is desired" >&5 $as_echo_n "checking whether memory profiling is desired... " >&6; } if test "${want_memprof}" = debug; then want_memprof="${want_debug}" fi if test "${want_memprof}" = yes; then $as_echo "#define MEMPROF 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi use_threads=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether threads support is requested" >&5 $as_echo_n "checking whether threads support is requested... " >&6; } if test "${want_threads}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether threads can be enabled" >&5 $as_echo_n "checking whether threads can be enabled... " >&6; } # check whether we can add THREADS support # we don't want to run full AC_CANONICAL_HOST, all we care about is OS X if test "x$OSNAME" = xDarwin; then use_threads=yes $as_echo "#define THREADS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${use_threads}" >&5 $as_echo "${use_threads}" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ## enable callbacks if desired { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether callbacks support is requested" >&5 $as_echo_n "checking whether callbacks support is requested... " >&6; } if test "${want_callbacks}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } if test "${want_jri}" != yes; then as_fn_error $? "Callbacks support can be only enabled if JRI is enabled as well." "$LINENO" 5 fi $as_echo "#define ENABLE_JRICB 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JNI cache support is requested" >&5 $as_echo_n "checking whether JNI cache support is requested... " >&6; } if test "${want_jni_cache}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } if test "${use_threads}" = yes; then as_fn_error $? "Threads and JNI cache cannot be used at the same time, because JNI cache is by definition not thread-safe. Please disable either option." "$LINENO" 5 fi $as_echo "#define JNI_CACHE 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether headless init is enabled" >&5 $as_echo_n "checking whether headless init is enabled... " >&6; } if test "${want_headless}" = auto; then want_headless=no ## only Darwin defaults to headless if test "x$OSNAME" = xDarwin; then want_headless=yes fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${want_headless}" >&5 $as_echo "${want_headless}" >&6; } if test "${want_headless}" = yes; then $as_echo "#define USE_HEADLESS_INIT 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether JRI is requested" >&5 $as_echo_n "checking whether JRI is requested... " >&6; } if test "${want_jri}" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } export R_HOME export JAVA_HOME JAVA_CPPFLAGS JAVA_LIBS JAVA_LD_LIBRARY_PATH JAVA JAVAC JAVAH JAR CONFIGURED=1 export CONFIGURED subdirs="$subdirs jri" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ac_config_files="$ac_config_files src/Makevars" ac_config_files="$ac_config_files R/zzz.R" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -z "${USE_DYNLOAD_TRUE}" && test -z "${USE_DYNLOAD_FALSE}"; then as_fn_error $? "conditional \"USE_DYNLOAD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WANT_JRI_TRUE}" && test -z "${WANT_JRI_FALSE}"; then as_fn_error $? "conditional \"WANT_JRI\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by rJava $as_me 0.8, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ rJava config.status 0.8 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; "R/zzz.R") CONFIG_FILES="$CONFIG_FILES R/zzz.R" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi # # CONFIG_SUBDIRS section. # if test "$no_recursion" != yes; then # Remove --cache-file, --srcdir, and --disable-option-checking arguments # so they do not pile up. ac_sub_configure_args= ac_prev= eval "set x $ac_configure_args" shift for ac_arg do if test -n "$ac_prev"; then ac_prev= continue fi case $ac_arg in -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \ | --c=*) ;; --config-cache | -C) ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) ;; --disable-option-checking) ;; *) case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_sub_configure_args " '$ac_arg'" ;; esac done # Always prepend --prefix to ensure using the same prefix # in subdir configurations. ac_arg="--prefix=$prefix" case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args" # Pass --silent if test "$silent" = yes; then ac_sub_configure_args="--silent $ac_sub_configure_args" fi # Always prepend --disable-option-checking to silence warnings, since # different subdirs can have different --enable and --with options. ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args" ac_popdir=`pwd` for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue # Do not complain, so a configure script can configure whichever # parts of a large source tree are present. test -d "$srcdir/$ac_dir" || continue ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)" $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5 $as_echo "$ac_msg" >&6 as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" # Check for guested configure; otherwise get Cygnus style configure. if test -f "$ac_srcdir/configure.gnu"; then ac_sub_configure=$ac_srcdir/configure.gnu elif test -f "$ac_srcdir/configure"; then ac_sub_configure=$ac_srcdir/configure elif test -f "$ac_srcdir/configure.in"; then # This should be Cygnus configure. ac_sub_configure=$ac_aux_dir/configure else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ac_dir" >&5 $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} ac_sub_configure= fi # The recursion is here. if test -n "$ac_sub_configure"; then # Make the cache file name correct relative to the subdirectory. case $cache_file in [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;; *) # Relative name. ac_sub_cache_file=$ac_top_build_prefix$cache_file ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;} # The eval makes quoting arguments work. eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \ --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" || as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5 fi cd "$ac_popdir" done fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi rJava/man/0000755000175100001440000000000015133274032012106 5ustar hornikusersrJava/man/jgc.Rd0000644000175100001440000000117215133274032013141 0ustar hornikusers\name{.jgc} \alias{.jgc} \title{ Invoke Java Garbage Collection } \description{ \code{.jgc} invokes the R and Java garbage collectors. } \usage{ .jgc(R.gc = TRUE, ...) } \arguments{ \item{R.gc}{logical, if \code{TRUE} then \code{gc(\dots)} is called first, if \code{FALSE} only Java garbage collector is called} \item{\dots}{any additional parameters passed to \code{gc()}} } \details{ \code{.jgc} invokes the R garbage collector (unless \code{R.gc=FALSE}) which removes any unused Java references and then invokes the Java garbage collector to reclaim Java heap space. } \author{ Simon Urbanek } \keyword{interface} rJava/man/jnull.Rd0000644000175100001440000000343115133274032013522 0ustar hornikusers\name{jnull} \alias{.jnull} \alias{is.jnull} \title{ Java null object reference } \description{ \code{.jnull} returns a \code{null} reference of a specified class type. The resulting object is of the class \code{jobjRef}. \code{is.jnull} is an extension of \code{is.null} that also returns \code{TRUE} if the supplied object is a \code{null} Java reference. } \usage{ .jnull(class = "java/lang/Object") is.jnull(x) } \arguments{ \item{class}{fully qualified target class name in JNI notation (e.g. \code{"java/lang/String"}).} \item{x}{object to check} } \value{ \code{.jnull} returns a Java object reference (\code{jobjRef}) of a \code{null} object having the specified object class. \code{is.jnull} returns \code{TRUE} if \code{is.null(x)} is \code{TRUE} or if \code{x} is a Java \code{null} reference. } \details{ \code{.jnull} is necessary if \code{null} is to be passed as an argument of \code{\link{.jcall}} or \code{\link{.jnew}}, in order to be able to find the correct method/constructor. Example: given the following method definitions of the class \code{A}: \itemize{ \item \code{public static void run(String a);} \item \code{public static void run(Double n);} } Calling \code{.jcall("A",,"run",NULL)} is ambiguous, because it is unclear which method is to be used. Therefore rJava requires class information with each argument to \code{\link{.jcall}}. If we wanted to run the String-version, we could use \code{.jcall("A",,"run",.jnull("java/lang/String"))}. \code{is.jnull} is a test that should be used to determine whether a given Java reference is a \code{null} reference. } \seealso{ \code{\link{.jcall}}, \code{\link{.jcast}} } \examples{ \dontrun{ .jcall("java/lang/System","I","identityHashCode",.jnull()) } } \keyword{interface} rJava/man/jnew.Rd0000644000175100001440000000345415133274032013346 0ustar hornikusers\name{jnew} \alias{.jnew} \title{ Create a Java object } \description{ \code{.jnew} create a new Java object. } \usage{ .jnew(class, ..., check=TRUE, silent=!check, class.loader=NULL) } \arguments{ \item{class}{fully qualified class name in JNI notation (e.g. \code{"java/lang/String"}).} \item{...}{ Any parameters that will be passed to the corresponding constructor. The parameter types are determined automatically and/or taken from the \code{jobjRef} object. For details see \code{\link{.jcall}}. Note that all named parameters are discarded.} \item{check}{ If set to \code{TRUE} then \code{\link{.jcheck}} is invoked before and after the call to the constructor to clear any pending Java exceptions.} \item{silent}{ If set to \code{FALSE} then \code{.jnew} will fail with an error if the object cannot be created, otherwise a null-reference is returned instead. In addition, this flag is also passed to final \code{.jcheck} if \code{check} above is set to \code{TRUE}. Note that the error handling also clears exceptions, so \code{check=FALSE, silent=FALSE} is usually not a meaningful combination. } \item{class.loader}{optional class loader to force for loading the class. If not set, the rJava class loader is used first. The default Java class loader is always used as a last resort. Set to \code{.rJava.class.loader} inside a package if it uses its own class loader (see \code{\link{.jpackage}} for details).} } \value{ Returns the reference (\code{jobjRef}) to the newly created object or \code{null}-reference (see \code{\link{.jnull}}) if something went wrong. } \seealso{ \code{\link{.jcall}}, \code{\link{.jnull}} } \examples{ \dontrun{ f <- .jnew("java/awt/Frame","Hello") .jcall(f,,"setVisible",TRUE) } } \keyword{interface} rJava/man/jarray.Rd0000644000175100001440000000777315133274032013703 0ustar hornikusers\name{jarray} \alias{.jarray} \alias{.jevalArray} \title{ Java array handling functions } \description{ \code{.jarray} takes a vector (or a list of Java references) as its argument, creates a Java array containing the elements of the vector (or list) and returns a reference to such newly created array. \code{.jevalArray} takes a reference to a Java array and returns its contents (if possible). } \usage{ .jarray(x, contents.class = NULL, dispatch = FALSE) .jevalArray(obj, rawJNIRefSignature = NULL, silent = FALSE, simplify = FALSE) } \arguments{ \item{x}{vector or a list of Java references} \item{contents.class}{common class of the contained objects, see details} \item{obj}{Java object reference to an array that is to be evaluated} \item{rawJNIRefSignature}{JNI signature that would be used for conversion. If set to \code{NULL}, the signature is detected automatically.} \item{silent}{if set to true, warnings are suppressed} \item{dispatch}{logical. If \code{TRUE} the code attempts to dispatch to either a \code{jarrayRef} object for rugged arrays and \code{jrectRef} objects for rectangular arrays, creating possibly a multi-dimensional object in Java (e.g., when used with a matrix).} \item{simplify}{if set to \code{TRUE} more than two-dimensional arrays are converted to native objects (e.g., matrices) if their type and size matches (essentially the inverse for objects created with \code{dispatch=TRUE}).} } \value{ \code{.jarray} returns a Java array reference (\code{jarrayRef} or \code{jrectRef}) to an array created with the supplied contents. \code{.jevalArray} returns the contents of the array object. } \details{ \code{.jarray}: The input can be either a vector of some sort (such as numeric, integer, logical, ...) or a list of Java references. The contents is pushed to the Java side and a corresponding array is created. The type of the array depends on the input vector type. For example numeric vector creates \code{double[]} array, integer vector creates \code{int[]} array, character vector \code{String[]} array and so on. If \code{x} is a list, it must contain Java references only (or \code{NULL}s which will be treated as \code{NULL} references). The \code{contents.class} parameter is used only if \code{x} is a list of Java object references and it can specify the class that will be used for all objects in the array. If set to \code{NULL} no assumption is made and \code{java/lang/Object} will be used. Use with care and only if you know what you're doing - you can always use \code{\link{.jcast}} to cast the entire array to another type even if you use a more general object type. One typical use is to construct multi-dimensional arrays which mandates passing the array type as \code{contents.class}. The result is a reference to the newly created array. The inverse function which fetches the elements of an array reference is \code{.jevalArray}. \code{.jevalArray} currently supports only a subset of all possible array types. Recursive arrays are handled by returning a list of references which can then be evaluated separately. The only exception is \code{simplify=TRUE} in which case \code{.jevalArray} attempts to convert multi-dimensional arrays into native R type if there is a such. This only works for rectangular arrays of the same basic type (i.e. the length and type of each referenced array is the same - sometimes matrices are represented that way in Java). } \examples{ \dontshow{.jinit()} a <- .jarray(1:10) print(a) .jevalArray(a) b <- .jarray(c("hello","world")) print(b) c <- .jarray(list(a,b)) print(c) # simple .jevalArray will return a list of references print(l <- .jevalArray(c)) # to convert it back, use lapply lapply(l, .jevalArray) # two-dimensional array resulting in int[2][10] d <- .jarray(list(a,a),"[I") print(d) # use dispatch to convert a matrix to [[D e <- .jarray(matrix(1:12/2, 3), dispatch=TRUE) print(e) # simplify it back to a matrix .jevalArray(e, simplify=TRUE) } \keyword{interface} rJava/man/jcast.Rd0000644000175100001440000000305615133274032013505 0ustar hornikusers\name{jcast} \alias{.jcast} \title{ Cast a Java object to another class } \description{ \code{.jcast} returns a Java object reference cast to another Java class. } \usage{ .jcast(obj, new.class = "java/lang/Object", check = FALSE, convert.array = FALSE) } \arguments{ \item{obj}{a Java object reference} \item{new.class}{fully qualified class name in JNI notation (e.g. \code{"java/lang/String"}). } \item{check}{logical. If \code{TRUE}, it is checked that the object effectively is an instance of the new class. See \code{\link{\%instanceof\%}}. Using FALSE (the default) for this argument, rJava does not perform type check and this will cause an error on the first use if the cast is illegal.} \item{convert.array}{logical. If \code{TRUE} and the object is an array, it is converted into a \code{jarrayRef} reference. } } \value{ Returns a Java object reference (\code{jobjRef}) to the object \code{obj}, changing the object class. } \details{ This function is necessary if a argument of \code{\link{.jcall}} or \code{\link{.jnew}} is defined as the superclass of the object to be passed (see \code{\link{.jcall}}). The original object is not modified. The default values for the arguments \code{check} and \code{convert.array} is \code{FALSE} in order to guarantee backwards compatibility, but it is recommended to set the arguments to \code{TRUE} } \seealso{ \code{\link{.jcall}} } \examples{ \dontrun{ v <- .jnew("java/util/Vector") .jcall("java/lang/System","I","identityHashCode",.jcast(v, "java/lang/Object")) } } \keyword{interface} rJava/man/jobjRef-class.Rd0000644000175100001440000000212315133274032015057 0ustar hornikusers\name{jobjRef-class} \docType{class} \alias{jobjRef-class} \title{Class "jobjRef" - Reference to a Java object } \description{ This class describes a reference to an object held in a JavaVM. } \section{Objects from the Class}{ Objects of this class should *not* be created directly. Instead, the function \code{\link{.jnew}} should be use to create new Java objects. They can also be created as results of the \code{\link{.jcall}} function. } \section{Slots}{ \describe{ \item{\code{jobj}:}{Internal identifier of the object (external pointer to be precise)} \item{\code{jclass}:}{Java class name of the object (in JNI notation)} } Java-side attributes are not accessed via slots, but the \code{$} operator instead. } \section{Methods}{ This object's Java methods are not accessed directly. Instead, \code{\link{.jcall}} JNI-API should be used for invoking Java methods. For convenience the \code{$} operator can be used to call methods via reflection API. } \author{ Simon Urbanek } \seealso{ \code{\link{.jnew}}, \code{\link{.jcall}} or \code{\link{jarrayRef-class}} } \keyword{classes} rJava/man/javaImport.Rd0000644000175100001440000000235115133274032014512 0ustar hornikusers\name{javaImport} \alias{javaImport} \title{ Attach mechanism for java packages } \description{ The \code{javaImport} function creates an item on R's search that maps names to class names references found in one or several "imported" java packages. } \usage{ javaImport(packages = "java.lang") } \arguments{ \item{packages}{character vector containing java package paths} } \value{ An external pointer to a java specific \code{UserDefinedDatabase} object } \references{ \emph{User-Defined Tables in the R Search Path}. Duncan Temple Lang. December 4, 2001 \url{https://www.omegahat.net/RObjectTables/} } \author{ Romain Francois } \note{ Currently the list of objects in the imported package is populated as new objects are found, \emph{not} at creation time. } \section{Warning}{ This feature is experimental. Use with caution, and don't forget to detach. } \seealso{ \code{\link{attach}} } \examples{ \dontrun{ attach( javaImport( "java.util" ), pos = 2 , name = "java:java.util" ) # now we can just do something like this v <- new( Vector ) v$add( "foobar" ) ls( pos = 2 ) # or this m <- new( HashMap ) m$put( "foo", "bar" ) ls( pos = 2 ) # or even this : Collections$EMPTY_MAP } } \keyword{ programming } rJava/man/rJava-internal.Rd0000644000175100001440000000420715133274032015255 0ustar hornikusers\name{rJava-internal} \alias{rJava-internal} \alias{.jaddLibrary} \alias{.jclass} \alias{.jclass.boolean} \alias{.jclass.double} \alias{.jclass.float} \alias{.jclass.int} \alias{.jclass.void} \alias{.jclassClass} \alias{.jclassObject} \alias{.jclassRef} \alias{.jclassString} \alias{.jfindClass} \alias{.jfirst} \alias{.jidenticalRef} \alias{.jinherits} \alias{.jinit.merge.error} \alias{.jmergeClassPath} \alias{.jmkref} \alias{.jniInitialized} \alias{.joptions} \alias{.jproperty} \alias{.jrcall} \alias{.jrmLibrary} \alias{.jsetJConvertor} \alias{.jsetRConvertor} \alias{.jstrVal} \alias{.jzeroRef} \alias{.r2j} \alias{.rJava.base.path} \title{ Internal functions and constants } \description{ The following functions are either internal or are not officially part of the API and therefore may changes in the future. } \usage{ .jaddLibrary(name, path, class.loader = .rJava.class.loader) .jclass(o, true = TRUE) .jclassRef(x, silent = FALSE) .jfindClass(cl, silent = FALSE, class.loader = .rJava.class.loader) .jfirst(libname, pkgname) .jidenticalRef(a, b) .jinherits(o, cl, class.loader = .rJava.class.loader) .jmergeClassPath(cp) .jmkref(jobj, jclass = "java/lang/Object") .joptions(...) .jproperty(key) .jrcall(o, method, ..., simplify = TRUE, class.loader = .rJava.class.loader) .jrmLibrary(name) .jsetJConvertor(java.class, fn) .jsetRConvertor(r.class, fn) .jstrVal(obj) .r2j(x, engine = NULL, convert = TRUE) } \arguments{ \item{name}{string, name of the library} \item{path}{string, path} \item{class.loader}{class loader object} \item{o}{Java object} \item{x}{Java object} \item{cl}{string, class name (or Java class name object)} \item{libname}{string, library location} \item{pkgname}{string, package name} \item{a}{Java object} \item{b}{Java object} \item{cp}{string, class path} \item{jobj}{Java object} \item{simplify}{logical} \item{java.class}{string, class name} \item{fn}{convertor function} \item{r.class}{string, R class} \item{obj}{Java object} \item{engine}{Java engine object, if \code{NULL} uses the main engine} \item{convert}{logical} \item{\dots}{additional parameters} } \keyword{internal} rJava/man/jfloat-class.Rd0000644000175100001440000000364315133274032014765 0ustar hornikusers\name{jfloat-class} \docType{class} \alias{jfloat-class} \alias{jlong-class} \alias{jbyte-class} \alias{jchar-class} \title{Classes "jfloat", "jlong", "jbyte" and "jchar" specify Java native types that are not native in R} \description{ These classes wrap a numeric vector to be treated as \code{float} or \code{long} argument when passed to Java and an integer vector to be treated as \code{byte} or \code{char}. R doesn't distinguish between \code{double} and \code{float}, but Java does. In order to satisfy object types, numeric vectors that should be converted to floats or long on the Java side must be wrapped in this class. In addition \code{jbyte} must be used when passing scalar byte (but not byte arrays, those are mapped into RAW vectors). Finally \code{jchar} it used when mapping integer vectors into unicode Java character vectors.} \section{Objects from the Class}{ Objects can be created by calling \code{\link{.jfloat}}, \code{\link{.jlong}}, \code{\link{.jbyte}} or \code{\link{.jchar}} respectively. } \section{Slots}{ \describe{ \item{\code{.Data}:}{Payload} } } \section{Extends}{ "jfloat" and "jlong": Class \code{"numeric"}, from data part. Class \code{"vector"}, by class \code{"numeric"}. "jbyte" and "jchar": Class \code{"integer"}, from data part. Class \code{"vector"}, by class \code{"integer"}. } \section{Methods}{ "jfloat" and "jlong" have no methods other than those inherited from "numeric". "jbyte" and "jchar" have no methods other than those inherited from "integer". } %\references{ ~put references to the literature/web site here ~ } \author{ Simon Urbanek } %\note{ ~~further notes~~ } % ~Make other sections like Warning with \section{Warning }{....} ~ \seealso{ \code{\link{.jfloat}}, \code{\link{.jlong}}, \code{\link{.jbyte}}, \code{\link{.jchar}} and \code{\link{.jcall}} } %\examples{ %##---- Should be DIRECTLY executable !! ---- %} \keyword{classes} rJava/man/jreflection.Rd0000644000175100001440000000367015133274032014707 0ustar hornikusers\name{jreflection} \alias{.jmethods} \alias{.jfields} \alias{.jconstructors} \title{ Simple helper functions for Java reflection } \description{ \code{.jconstructors} returns a character vector with all constructors for a given class or object. \code{.jmethods} returns a character vector with all methods for a given class or object. \code{.jfields} returns a character vector with all fields (aka attributes) for a given class or object. } \usage{ .jconstructors(o, as.obj = FALSE, class.loader=.rJava.class.loader) .jmethods(o, name = NULL, as.obj = FALSE, class.loader=.rJava.class.loader) .jfields(o, name = NULL, as.obj = FALSE, class.loader=.rJava.class.loader) } \arguments{ \item{o}{Name of a class (either notation is fine) or an object whose class will be queried} \item{name}{string, regular expression of the method/field to look for} \item{as.obj}{if \code{TRUE} then a list of Java objects is returned, otherwise a character vector (obtained by calling \code{toString()} on each entry).} \item{class.loader}{optional, class loader to use for class look up if needed (i.e., if \code{o} is a string)} } \value{ Returns a character vector (if \code{as.obj} is \code{FALSE}) or a list of Java objects. Each entry corresponds to the \code{Constructor} resp. \code{Method} resp. \code{Field} object. The string result is constructed by calling \code{toString()} on the objects. } \details{ There first two functions are intended to help with finding correct signatures for methods and constructors. Since the low-level API in rJava doesn't use reflection automatically, it is necessary to provide a proper signature. That is somewhat easier using the above methods. } \seealso{ \code{\link{.jcall}}, \code{\link{.jnew}}, \code{\link{.jcast}} or \code{\link{$,jobjRef-method}} } \examples{ \dontrun{ .jconstructors("java.util.Vector") v <- .jnew("java.util.Vector") .jmethods(v, "add") } } \keyword{interface} rJava/man/accessOp.Rd0000644000175100001440000000613615133274032014143 0ustar hornikusers\name{JavaAccess} \alias{$,jobjRef-method} \alias{$,jclassName-method} \alias{$<-,jobjRef-method} \alias{$<-,jclassName-method} \alias{names,jobjRef-method} \alias{names,jclassName-method} \alias{names,jarrayRef-method} \alias{names,jrectRef-method} \alias{.DollarNames.jobjRef} \alias{.DollarNames.jclassName} \alias{.DollarNames.jarrayRef} \alias{.DollarNames.jrectRef} \title{ Field/method operator for Java objects } \description{ The \code{$} operator for \code{jobjRef} Java object references provides convenience access to object attributes and calling Java methods. } \usage{ \S3method{.DollarNames}{jobjRef} (x, pattern = "" ) \S3method{.DollarNames}{jarrayRef} (x, pattern = "" ) \S3method{.DollarNames}{jrectRef} (x, pattern = "" ) \S3method{.DollarNames}{jclassName}(x, pattern = "" ) } \arguments{ \item{x}{object to complete} \item{pattern}{pattern} } \section{Methods}{ \describe{ \item{\code{$}}{\code{signature(x = "jobjRef")}: ... } \item{\code{$}}{\code{signature(x = "jclassName")}: ... } \item{\code{$<-}}{\code{signature(x = "jobjRef")}: ... } \item{\code{$<-}}{\code{signature(x = "jclassName")}: ... } \item{\code{names}}{\code{signature(x = "jobjRef")}: ... } \item{\code{names}}{\code{signature(x = "jarrayRef")}: ... } \item{\code{names}}{\code{signature(x = "jrectRef")}: ... } \item{\code{names}}{\code{signature(x = "jclassName")}: ... } } } \details{ rJava provides two levels of API: low-level JNI-API in the form of \code{\link{.jcall}} function and high-level reflection API based on the \code{$} operator. The former is very fast, but inflexible. The latter is a convenient way to use Java-like programming at the cost of performance. The reflection API is build around the \code{$} operator on \code{\link{jobjRef-class}} objects that allows to access Java attributes and call object methods. \code{$} returns either the value of the attribute or calls a method, depending on which name matches first. \code{$<-} assigns a value to the corresponding Java attribute. \code{names} and \code{.DollarNames} returns all fields and methods associated with the object. Method names are followed by \code{(} or \code{()} depending on arity. This use of names is mainly useful for code completion, it is not intended to be used programmatically. This is just a convenience API. Internally all calls are mapped into \code{\link{.jcall}} calls, therefore the calling conventions and returning objects use the same rules. For time-critical Java calls \code{\link{.jcall}} should be used directly. } \seealso{ \code{\link{J}}, \code{\link{.jcall}}, \code{\link{.jnew}}, \code{\link{jobjRef-class}} } \examples{ \dontshow{.jinit()} v <- new(J("java.lang.String"), "Hello World!") v$length() v$indexOf("World") names(v) \dontshow{ stopifnot( v$length() == 12L ) stopifnot( v$indexOf("World") == 6L ) } J("java.lang.String")$valueOf(10) Double <- J("java.lang.Double") # the class pseudo field - instance of Class for the associated class # similar to java Double.class Double$class \dontshow{ stopifnot( Double$class$getName() == "java.lang.Double" ) } } \keyword{interface} rJava/man/java-tools.Rd0000644000175100001440000000127015133274032014454 0ustar hornikusers\name{java-tools} \alias{java-tools} \title{java tools used internally in rJava} \description{java tools used internally in rJava} \examples{ \dontshow{ # running the java unit tests from the R examples .jinit() J("RJavaTools_Test")$runtests() J("RJavaArrayTools_Test")$runtests() J("ArrayWrapper_Test")$runtests() J("RectangularArrayBuilder_Test")$runtests() p <- .jnew( "java/awt/Point" ) classes <- .Call( rJava:::RgetSimpleClassNames, p@jobj, TRUE ) stopifnot( all( c( "Point", "Point2D", "Object", "error", "condition" ) \%in\% classes ) ) classes <- .Call( rJava:::RgetSimpleClassNames, p@jobj, FALSE ) stopifnot( all( c( "Point", "Point2D", "Object" ) \%in\% classes ) ) } } rJava/man/show.Rd0000644000175100001440000000137115133274032013357 0ustar hornikusers\name{show} \alias{show,jobjRef-method} \alias{str,jobjRef-method} \alias{show,jarrayRef-method} \alias{show,jclassName-method} \title{Show a Java Object Reference} \description{ Display a Java object reference in a descriptive, textual form. The default implementation calls \code{toString} Java method to obtain object's printable value and uses calls \code{show} on the resulting string garnished with additional details. } \section{Methods}{ \describe{ \item{show}{\code{signature(object = "jobjRef")}: ... } \item{show}{\code{signature(object = "jarrayRef")}: ... } \item{show}{\code{signature(object = "jclassName")}: ... } \item{str}{\code{signature(object = "jobjRef")}: currently identical to show } } } \keyword{interface} rJava/man/jmemprof.Rd0000644000175100001440000000303715133274032014217 0ustar hornikusers\name{jmemprof} \alias{.jmemprof} \title{ rJava memory profiler } \description{ \code{.jmemprof} enables or disables rJava memory profiling. If rJava was compiled without memory profiling support, then a call to this function always causes an error. } \usage{ .jmemprof(file = "-") } \arguments{ \item{file}{file to write profiling information to or \code{NULL} to disable profiling} } \value{ Returns \code{NULL}. } \details{ The \code{file} parameter must be either a filename (which will be opened in append-mode) or "-" to use standard output or \code{NULL} to disable profiling. An empty string "" is equivalent to \code{NULL} in this context. Note that lots of finalizers are run only when R exists, so usually you want to enable profiling early and let R exit to get a sensible profile. Running gc may be helpful to get rid of references that can be collected in R. A simple perl script is provided to analyze the result of the profiler. Due to its simple text format, it is possible to capture entire stdout including the profiler information to have both the console context for the allocations and the profile. Memory profiling is also helpful if rJava debug is enabled. Note that memory profiling support must be compiled in rJava and it is by default compiled only if debug mode is enabled (which is not the case by default). } \examples{ ## memory profiling support is optional so only works when enabled tryCatch( .jmemprof("rJava.mem.profile.txt"), error=function(e) message(e)) } \keyword{interface} rJava/man/jcastToArray.Rd0000644000175100001440000000516715133274032015014 0ustar hornikusers\name{jcastToArray} \alias{.jcastToArray} \title{ Ensures that a given object is an array reference } \description{ \code{.jcastToArray} takes a Java object reference of any kind and returns Java array reference if the given object is a reference to an array. } \usage{ .jcastToArray(obj, signature=NULL, class="", quiet=FALSE) } \arguments{ \item{obj}{Java object reference to cast or a scalar vector} \item{signature}{array signature in JNI notation (e.g. \code{"[I"} for an array of integers). If set to \code{NULL} (the default), the signature is automatically determined from the object's class.} \item{class}{force the result to pose as a particular Java class. This has the same effect as using \code{\link{.jcast}} on the result and is provided for convenience only.} \item{quiet}{if set to \code{TRUE}, no failures are reported and the original object is returned unmodified.} } \value{ Returns a Java array reference (\code{jarrayRef}) on success. If \code{quiet} is \code{TRUE} then the result can also be the original object in the case of failure. } \details{ Sometimes a result of a method is by definition of the class \code{java.lang.Object}, but the actual referenced object may be an array. In that case the method returns a Java object reference instead of an array reference. In order to obtain an array reference, it is necessary to cast such an object to an array reference - this is done using the above \code{.jcastToArray} function. The input is an object reference that points to an array. Usually the signature should be left at \code{NULL} such that it is determined from the object's class. This is also a check, because if the object's class is not an array, then the functions fails either with an error (when \code{quiet=FALSE}) or by returning the original object (when \code{quiet=TRUE}). If the signature is set to anything else, it is not verified and the array reference is always created, even if it may be invalid and unusable. For convenience \code{.jcastToArray} also accepts non-references in which case it simply calls \code{\link{.jarray}}, ignoring all other parameters. } \examples{ \dontrun{ a <- .jarray(1:10) print(a) # let's create an array containing the array aa <- .jarray(list(a)) print(aa) ba <- .jevalArray(aa)[[1]] # it is NOT the inverse, because .jarray works on a list of objects print(ba) # so we need to cast the object into an array b <- .jcastToArray(ba) # only now a and b are the same array reference print(b) # for convenience .jcastToArray behaves like .jarray for non-references print(.jcastToArray(1:10/2)) } } \keyword{interface} rJava/man/toJava.Rd0000644000175100001440000000261115133274032013621 0ustar hornikusers\name{toJava} \alias{toJava} \title{ Convert R objects to REXP references in Java } \description{ \code{toJava} takes an R object and creates a reference to that object in Java. This reference can then be passed to Java methods such that they can refer to it back in R. This is commonly used to pass functions to Java such that Java code can call those functions later. } \usage{ toJava(x, engine = NULL) } \arguments{ \item{x}{R object to reference. It can be any R object and it will be retained at least for the duration of the reference on the Java side.} \item{engine}{REngine in which the reference is to be created. If null then the last created engine is used. This must be a Java object and a subclass of org.rosuda.REngine (and NOT the old org.rosuda.JRI.Rengine!). } } %\details{ %} \value{ There result is a Java reference (\code{jobjRef}) of the Java class \code{REXPReference}. } \examples{ \dontrun{ .jinit() # requires JRI and REngine classes .jengine(TRUE) f <- function() { cat("Hello!\n"); 1 } fref <- toJava(f) # to use this in Java you would use something like: # public static REXP call(REXPReference fn) throws REngineException, REXPMismatchException { # return fn.getEngine().eval(new REXPLanguage(new RList(new REXP[] { fn })), null, false); # } # .jcall("Call","Lorg/rosuda/REngine/REXP;","call", fref) } } \keyword{interface} rJava/man/jinit.Rd0000644000175100001440000001153715133274032013521 0ustar hornikusers\name{jinit} \alias{.jinit} \alias{.jvmState} \title{ Initialize Java VM } \description{ \code{.jinit} initializes the Java Virtual Machine (JVM). This function must be called before any rJava functions can be used. \code{.jvmState() returns the state of the current JVM.} } \usage{ .jinit(classpath = NULL, parameters = getOption("java.parameters", NA), ..., silent = FALSE, force.init = FALSE) .jvmState() } \arguments{ \item{classpath}{Any additional classes to include in the Java class paths (i.e. locations of Java classes to use). This path will be prepended to paths specified in the \code{CLASSPATH} environment variable. Do NOT set this system class path initializing a package, use \code{\link{.jpackage}} instead, see details.} \item{parameters}{character vector of parameters to be passed to the virtual machine. They are implementation dependent and apply to JDK version 1.2 or higher only. Please note that each parameter must be in a separate element of the array, you cannot use a space-separated string with multiple parameters. The value of \code{NA} means "use rJava default" which is \code{"-Xmx1g"} currently. \code{NULL} is equivalent to \code{character()}. } \item{...}{Other optional Java initialization parameters (implementation-dependent).} \item{silent}{If set to \code{TRUE} no warnings are issued.} \item{force.init}{If set to \code{TRUE} JVM is re-initialized even if it is already running.} } \value{ The return value is an integer specifying whether and how the VM was initialized. Negative values indicate failure, zero denotes successful initialization and positive values signify partially successful initilization (i.e. the VM is up, but parameters or class path could not be set due to an existing or incompatible VM). \code{.jvmState} returns a named list with at least the following elements: \item{initialized}{\code{TRUE} if rJava is initialized and has a runing JVM, \code{FALSE} otherwise.} \item{state}{string representing the current state of the JVM. One of the following values: \code{"none"} if there is no JVM, \code{"created"} if the current JVM has been created by rJava, \code{"attached"} if rJava attached into an existing JVM (typically when R is embedded into a running JVM via JRI), \code{"detached"} if there is a JVM (such as embedded R), but rJava has not been initialized to use it, \code{"dead"} if the process is about to die due to the JVM forcing en exit or \code{"destroyed"} if a JVM existed before, but was destroyed.} } \details{ Starting with version 0.5 rJava provides a custom class loader that can automatically track classes and native libraries that are provided in R packages. Therefore R packages should NOT use \code{.jinit}, but call \code{\link{.jpackage}} instead. In addition this allows the use of class path modifying function \code{\link{.jaddClassPath}}. Important note: if a class is found on the system class path (i.e. on the \code{classpath} specified to \code{.jinit}) then the system class loader is used instead of the rJava loader, which can lead to problems with reflection and native library support is not enabled. Therefore it is highly recommended to use \code{.jpackage} or \code{.jaddClassPath} instead of \code{classpath} (save for system classes). Stating with version 0.3-8 rJava is now capable of modifying the class path on the fly for certain Sun-based Java virtual machines, even when attaching to an existing VM. However, this is done by exploiting the way ClassLoader is implemented and may fail in the future. In general it is officially not possible to change the class path of a running VM. At any rate, it is impossible to change any other VM parameters of a running VM, so when using \code{.jinit} in a package, be generous with limits and don't use VM parameters to unnecessarily restrict resources (or preferably use \code{\link{.jpackage}} instead). JVM parameters can only be set if the initial state of the JVM is \code{"none"}. There is a subtle difference between \code{"initialized"} and the JVM state. It is in theory possible for \code{"initialized"} to be \code{FALSE} and still \code{"state"} to be \code{"created"} or \code{"attached"} in case where JVM was created but rJava has not been able to initialize for other reasons, although such state should be rare and problematic in either case. Behavior of rJava functions other than \code{.jinit} and \code{.jvmState} is undefined unless \code{.jvmState()$initialized} is \code{TRUE}. NOTE: \code{.jinit()} can be called implicitly by other functions such as \code{\link{.jpackage}} or \code{\link{J}}. } \seealso{ \code{\link{.jpackage}} } \examples{ \dontrun{ ## set heap size limit to 512MB (see java -X) .jinit(parameters="-Xmx512m") .jvmState() } } \keyword{interface} rJava/man/rep.Rd0000644000175100001440000000131215133274032013160 0ustar hornikusers\name{rep} \alias{rep,jarrayRef-method} \alias{rep,jobjRef-method} \alias{rep,jrectRef-method} \title{Creates java arrays by cloning} \description{ Creates a java array by cloning a reference several times } \section{Methods}{ \describe{ \item{rep}{\code{signature(object = "jobjRef")}: ... } \item{rep}{\code{signature(object = "jarrayRef")}: ... } \item{rep}{\code{signature(object = "jrectRef")}: ... } } } \seealso{ \code{\link[base]{rep}} or \code{\link{.jarray}} } \examples{ \dontshow{.jinit()} if (!nzchar(Sys.getenv("NOAWT"))) { p <- .jnew( "java.awt.Point" ) a <- rep( p, 10 ) stopifnot( dim(a) == c(10L ) ) a[[1]]$move( 10L, 50L ) stopifnot( a[[2]]$getX() == 0.0 ) } } rJava/man/jfloat.Rd0000644000175100001440000000502615133274032013657 0ustar hornikusers\name{jfloat} \alias{.jfloat} \alias{.jlong} \alias{.jbyte} \alias{.jchar} \alias{.jshort} \alias{jfloat} \alias{jlong} \alias{jbyte} \alias{jchar} \alias{jshort} \title{ Wrap numeric vector as flat Java parameter } \description{ \code{.jfloat} marks a numeric vector as an object that can be used as parameter to Java calls that require \code{float} parameters. Similarly, \code{.jlong} marks a numeric vector as \code{long} parameter, \code{.jshort} as \code{short} and \code{.jbyte} as \code{byte}. } \usage{ .jfloat(x) .jlong(x) .jbyte(x) .jchar(x) .jshort(x) } \arguments{ \item{x}{numeric vector} } \value{ Returns a numeric vector of the class \code{jfloat}, \code{jlong}, \code{jbyte}, \code{jshort} or \code{jchar} that can be used as parameter to Java calls that require \code{float}, \code{long}, \code{byte}, \code{short} or \code{char} parameters respectively. } \details{ R has no native \code{float} or \code{long} type. Numeric vectors are stored as \code{double}s, hence there is no native way to pass float numbers to Java methods. The \code{.jfloat} call marks a numeric vector as having the Java type \code{float} by wrapping it in the \code{jfloat} class. The class is still a subclass of \code{numeric}, therefore all regular R operations are unaffected by this. Similarly, \code{.jlong} is used to mark a numeric vector as a parameter of the \code{long} Java type. Please note that in general R has no native type that will hold a \code{long} value, so conversion between Java's \code{long} type and R's numeric is potentially lossy. \code{.jbyte} is used when a scalar byte is to be passed to Java. Note that byte arrays are natively passed as raw vectors, not as \code{.jbyte} arrays, although non-scalar \code{.jbyte} is equivalent except for using four-times as much memory. \code{.jchar} is strictly experimental and uses integer vector as storage class. The type \code{char} in Java represents 16-bit Unicode code points (not to be confused with \code{char} in C which is \code{byte} in Java!), see Java documentation for details. \code{x} can also be a non-\code{NA} string in which case \code{.jchar(x)} is just a shorthand for \code{.jnew("java.lang.String", x)$toCharArray()} and thus performs a Java call (unlike all other functions mentioned here). } \seealso{ \code{\link{.jcall}}, \code{\link{jfloat-class}} } %\examples{ %\dontrun{ %v <- .jnew("java/util/Vector") %.jcall("java/lang/System","I","identityHashCode",.jcast(v, "java/lang/Object")) %} %} \keyword{interface} rJava/man/jequals.Rd0000644000175100001440000001217215133274032014044 0ustar hornikusers\name{jequals} \alias{.jequals} \alias{.jcompare} \alias{!=,ANY,jobjRef-method} \alias{!=,jobjRef,jobjRef-method} \alias{!=,jobjRef,ANY-method} \alias{==,ANY,jobjRef-method} \alias{==,jobjRef,jobjRef-method} \alias{==,jobjRef,ANY-method} \alias{<,ANY,jobjRef-method} \alias{<,jobjRef,jobjRef-method} \alias{<,jobjRef,ANY-method} \alias{>,ANY,jobjRef-method} \alias{>,jobjRef,jobjRef-method} \alias{>,jobjRef,ANY-method} \alias{<=,ANY,jobjRef-method} \alias{<=,jobjRef,jobjRef-method} \alias{<=,jobjRef,ANY-method} \alias{>=,ANY,jobjRef-method} \alias{>=,jobjRef,jobjRef-method} \alias{>=,jobjRef,ANY-method} \title{ Comparing Java References } \description{ \code{.jequals} function can be used to determine whether two objects are equal. In addition, it allows mixed comparison of non-Java object for convenience, unless strict comparison is desired. The binary operators \code{==} and \code{!=} are mapped to (non-strict) call to \code{.jequals} for convenience. \code{.jcompare} compares two objects in the sense of the \code{java.lang.Comparable} interface. The binary operators \code{<}, \code{>}, \code{<=}, \code{>=} are mapped to calls to \code{.jcompare} for convenience } \usage{ .jequals(a, b, strict = FALSE) .jcompare( a, b ) } \arguments{ \item{a}{first object} \item{b}{second object} \item{strict}{when set to \code{TRUE} then non-references save for \code{NULL} are always treated as different, see details.} } \value{ \code{.jequals} returns \code{TRUE} if both object are considered equal, \code{FALSE} otherwise. \code{.jcompare} returns the result of the \code{compareTo} java method of the object a applied to b } \section{Methods}{ \describe{ \item{!=}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{!=}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{!=}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{==}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{==}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{==}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{<}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{<}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{<}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{>}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{>}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{>}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{>=}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{>=}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{>=}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } \item{<=}{\code{signature(e1 = "ANY", e2 = "jobjRef")}: ... } \item{<=}{\code{signature(e1 = "jobjRef", e2 = "jobjRef")}: ... } \item{<=}{\code{signature(e1 = "jobjRef", e2 = "ANY")}: ... } } } \details{ \code{.jequals} compares two Java objects by calling \code{equals} method of one of the objects and passing the other object as its argument. This allows Java objects to define the `equality' in object-dependent way. In addition, \code{.jequals} allows the comparison of Java object to other scalar R objects. This is done by creating a temporary Java object that corresponds to the R object and using it for a call to the \code{equals} method. If such conversion is not possible a warning is produced and the result it \code{FALSE}. The automatic conversion will be avoided if \code{strict} parameter is set to \code{TRUE}. \code{NULL} values in \code{a} or \code{b} are replaced by Java \code{null}-references and thus \code{.jequals(NULL,NULL)} is \code{TRUE}. If neither \code{a} and \code{b} are Java objects (with the exception of both being \code{NULL}) then the result is identical to that of \code{all.equal(a,b)}. Neither comparison operators nor \code{.jequals} supports vectors and returns \code{FALSE} in that case. A warning is also issued unless strict comparison was requested. } \note{ Don't use \code{x == NULL} to check for \code{null}-references, because \code{x} could be \code{NULL} and thus the result would be an empty vector. Use \code{\link{is.jnull}} instead. (In theory \code{is.jnull} and \code{x == .jnull()} are the the same, but \code{is.jnull} is more efficient.) } \seealso{ \code{\link{is.jnull}} } \examples{ \dontshow{.jinit()} s <- .jnew("java/lang/String", "foo") .jequals(s, "foo") # TRUE .jequals(s, "foo", strict=TRUE) # FALSE - "foo" is not a Java object t <- s .jequals(s, t, strict=TRUE) # TRUE s=="foo" # TRUE \dontshow{ stopifnot( .jequals(s, "foo"), !.jequals(s, "foo", strict=TRUE), .jequals(s, t, strict=TRUE), s == "foo" ) } Double <- J("java.lang.Double") d1 <- new( Double, 0.0 ) d2 <- new( Double, 1.0 ) d3 <- new( Double, 0.0 ) d1 < d2 d1 <= d3 d1 >= d3 d1 > d2 # cannot compare a Double and a String try( d1 < "foo" ) # but can compare a Double and an Integer d1 < 10L \dontshow{ stopifnot( d1 < d2 , d1 <= d3 , d1 >= d3 , ! (d1 > d2 ) , inherits( try( d1 < "foo", silent = TRUE ), "try-error" ), d1 < 10L ) } } \keyword{interface} rJava/man/jarrayRef-class.Rd0000644000175100001440000000510315133274032015424 0ustar hornikusers\name{jarrayRef-class} \docType{class} \alias{jarrayRef-class} \alias{[,jarrayRef-method} \alias{[[,jarrayRef-method} \alias{[[<-,jarrayRef-method} \alias{head,jarrayRef-method} \alias{tail,jarrayRef-method} \alias{length,jarrayRef-method} \alias{str,jarrayRef-method} \alias{unique,jarrayRef-method} \alias{duplicated,jarrayRef-method} \alias{anyDuplicated,jarrayRef-method} \alias{sort,jarrayRef-method} \alias{rev,jarrayRef-method} \alias{min,jarrayRef-method} \alias{max,jarrayRef-method} \alias{range,jarrayRef-method} \title{Class "jarrayRef" Reference to an array Java object } \description{ This class is a subclass of \link{jobjRef-class} and represents a reference to an array Java object. } \section{Objects from the Class}{ Objects cannot be created directly, but only as the return value of \code{\link{.jcall}} function. } \section{Slots}{ \describe{ \item{\code{jsig}:}{JNI signature of the array type} \item{\code{jobj}:}{Internal identifier of the object} \item{\code{jclass}:}{Inherited from \code{jobjRef}, but unspecified} } } \section{Methods}{ \describe{ \item{[}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{[[}{\code{signature(x = "jarrayRef")}: R indexing of java arrays } \item{[[<-}{\code{signature(x = "jarrayRef")}: replacement method } \item{\code{head}}{\code{signature(x = "jarrayRef")}: head of the java array } \item{\code{tail}}{\code{signature(x = "jarrayRef")}: tail of the java array } \item{length}{\code{signature(object = "jarrayRef")}: Number of java objects in the java array } \item{str}{\code{signature(object = "jarrayRef")}: ... } \item{unique}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{duplicated}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{anyDuplicated}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{sort}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{rev}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{min}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{max}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } \item{range}{\code{signature(x = "jarrayRef")}: \emph{not yet implemented} } } } \section{Extends}{ Class \code{"\linkS4class{jobjRef}"}, directly. } \author{ Simon Urbanek } \seealso{ \code{\link{.jcall}} or \code{\linkS4class{jobjRef}} \code{\linkS4class{jrectRef}} for rectangular arrays } % need to find examples of rugged arrays % \examples{ % \dontshow{.jinit()} % } \keyword{classes} rJava/man/with.Rd0000644000175100001440000000523315133274032013353 0ustar hornikusers\name{with.jobjRef} \alias{with.jobjRef} \alias{within.jobjRef} \alias{with.jarrayRef} \alias{within.jarrayRef} \alias{with.jclassName} \alias{within.jclassName} \title{ with and within methods for Java objects and class names } \description{ Convenience wrapper that allow calling methods of Java object and classes from within the object (or class). } \usage{ \S3method{with}{jobjRef}(data, expr, ...) \S3method{within}{jobjRef}(data, expr, ...) \S3method{with}{jarrayRef}(data, expr, ...) \S3method{within}{jarrayRef}(data, expr, ...) \S3method{with}{jclassName}(data, expr, ...) \S3method{within}{jclassName}(data, expr, ...) } \arguments{ \item{data}{ A Java object reference or a java class name. See \code{\link{J}} } \item{expr}{ R expression to evaluate } \item{\dots}{ ignored } } \details{ The expression is evaluated in an environment that contains a mapping between the public fields and methods of the object. The methods of the object are mapped to standard R functions in the environment. In case of classes, only static methods are used. The fields of the object are mapped to active bindings (see \link{makeActiveBinding}) so that they can be accessed and modified from within the environment. For classes, only static fields are used. } \value{ \code{with} returns the value of the expression and \code{within} returns the \code{data} argument } \author{ Romain Francois } \references{ the \code{java.lang.reflect} package: \url{https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/package-summary.html} } \examples{ \dontshow{.jinit()} if (!nzchar(Sys.getenv("NOAWT"))) { p <- .jnew( "java/awt/Point", 0L, 0L ) with( p, { # x and y and now 0 move( 10L, 10L ) # x and y are now 10 x <- x + y } ) f <- within( .jnew( "javax/swing/JFrame" ) , { layout <- .jnew( "java/awt/BorderLayout" ) setLayout( layout ) add( .jnew( "javax/swing/JLabel", "north" ), layout$NORTH ) add( .jnew( "javax/swing/JLabel", "south" ), layout$SOUTH ) add( .jnew( "javax/swing/JLabel", "west" ), layout$WEST ) add( .jnew( "javax/swing/JLabel", "east" ), layout$EAST ) setSize( .jnew( "java/awt/Dimension", 400L, 400L ) ) setVisible( TRUE ) } ) } Double <- J("java.lang.Double") with( Double, MIN_VALUE ) with( Double, parseDouble( "10.2" ) ) \dontrun{ # inner class example % TODO: find a better example HashMap <- J("java.util.HashMap") with( HashMap, new( SimpleEntry, "key", "value" ) ) with( HashMap, SimpleEntry ) } with( J("java.lang.System"), getProperty("java.home") ) \dontshow{ stopifnot( with( Double, parseDouble("10.0") ) == 10.0 ) d <- new( Double, "10.0") stopifnot( with( d, doubleValue() ) == 10.0 ) } } \keyword{ classes } rJava/man/Exceptions.Rd0000644000175100001440000000302415133274032014515 0ustar hornikusers\name{Exceptions} \alias{Exceptions} \alias{$.Throwable} \alias{$<-.Throwable} \title{Exception handling} \description{R handling of java exception} \usage{ \S3method{$}{Throwable}(x, name ) \S3method{$}{Throwable}(x, name ) <- value } \arguments{ \item{x}{condition} \item{name}{...} \item{value}{...} } \details{ Java exceptions are mapped to R conditions that are relayed by the \code{\link{stop}} function. The R condition contains the actual exception object as the \code{jobj} item. The class name of the R condition is made of a vector of simple java class names, the class names without their package path. This allows the R code to use direct handlers similar to direct exception handlers in java. See the example below. } \examples{ \dontshow{.jinit()} Integer <- J("java.lang.Integer") tryCatch( Integer$parseInt( "10.." ), NumberFormatException = function(e){ e$jobj$printStackTrace() } ) # the dollar method is also implemented for Throwable conditions, # so that syntactic sugar can be used on condition objects # however, in the example below e is __not__ a jobjRef object reference tryCatch( Integer$parseInt( "10.." ), NumberFormatException = function(e){ e$printStackTrace() } ) \dontshow{ tryCatch( Integer$parseInt( "10.." ), NumberFormatException = function(e){ classes <- class( e ) stopifnot( "NumberFormatException" \%in\% classes ) stopifnot( "Exception" \%in\% classes ) stopifnot( "Object" \%in\% classes ) stopifnot( "error" \%in\% classes ) stopifnot( "condition" \%in\% classes ) } ) } } rJava/man/jclassName.Rd0000644000175100001440000000252515133274032014461 0ustar hornikusers\name{jclassName-class} \docType{class} \alias{jclassName-class} \alias{as.character,jclassName-method} \title{Class "jclassName" - a representation of a Java class name } \description{ This class holds a name of a class in Java. } \section{Objects from the Class}{ Objects of this class should *not* be created directly. Instead, the function \code{\link{J}} should be used to create new objects of this class. } \section{Slots}{ \describe{ \item{\code{name}:}{Name of the class (in source code notation)} \item{\code{jobj}:}{Object representing the class in Java} } } \section{Methods}{ The objects of class \code{jclassName} are used indirectly to be able to create new Java objects via \code{new} such as \code{new(J("java.lang.String"), "foo")} or to use the \code{$} convenience operator on static classes, such as \code{J("java.lang.Double")$parseDouble("10.2")}. \describe{ \item{\code{as.character}}{\code{signature(x = "jclassName")}: returns the class name as a string vector of length one. } } } %\references{ ~put references to the literature/web site here ~ } \author{ Simon Urbanek } %\note{ ~~further notes~~ } % ~Make other sections like Warning with \section{Warning }{....} ~ \seealso{ \code{\link{J}}, \code{\link{new}} } %\examples{ %##---- Should be DIRECTLY executable !! ---- %} \keyword{classes} rJava/man/loader.Rd0000644000175100001440000000456615133274032013656 0ustar hornikusers\name{loader} \alias{.jaddClassPath} \alias{.jclassPath} \alias{.jclassLoader} \title{ Java Class Loader } \description{ \code{.jaddClassPath} adds directories or JAR files to the class path. \code{.jclassPath} returns a vector containing the current entries in the class path } \usage{ .jaddClassPath(path, class.loader=.rJava.class.loader) .jclassPath(class.loader=.rJava.class.loader) .jclassLoader(package=NULL) } \arguments{ \item{path}{character string vector listing the paths to add to the class path} \item{class.loader}{Java class loader to use for the query of madification. Defaults to global class loader.} \item{package}{string, name of a package or \code{NULL} for the global class loader} } \value{ \code{.jclassPath} returns a character vector listing the class path sequence. } \details{ Whenever a class needs to be instantiated in Java it is referred by name which is used to locate a file with the bytecode for the class. The mechanism to map a name to an actual bytecode to load ind instantiate is habdled by the Java class loader. It typically keeps a list of directories and JAR files to search for the class names. The \code{.jaddClassPath()} function allows the user to append new locations to the list of places which will be searched. The function \code{.jclassPath} retrieves the current sarch list from the loader. When rJava is initialized, it instantiates the global class loader which is responsible for finding classes in functions such as \code{.jnew()}. In addition to the global class loader, R packages can create their own class loaders to avoid conflicts between packages such that they can be sure to use their own files to look for classes. See \code{\link{.jpackage}} for details on how that works. If the \code{package} argument is supplied \code{.jclassLoader} will look in that package to see if it has a custom loader and will return it, otherwise it returns the global loader. Note that is will fail with an error when supplied a non-existing package name. If you want to trace issues related to missing classes, you can enable debugging in the class loader by using the \code{setDebug} method, for example: \code{.jclassLoader()$setDebug(1L)} } \seealso{ \code{\link{.jpackage}} } \examples{ \dontrun{ .jaddClassPath("/my/jars/foo.jar","/my/classes/") print(.jclassPath()) } } \keyword{interface} rJava/man/jcheck.Rd0000644000175100001440000000666215133274032013636 0ustar hornikusers\name{jcheck} \alias{.jcheck} \alias{.jthrow} \alias{.jclear} \alias{.jgetEx} \title{ Java exception handling } \description{ \code{.jcheck} checks the Java VM for any pending exceptions and clears them. \code{.jthrow} throws a Java exception. \code{.jgetEx} polls for any pending exceptions and returns the exception object. \code{.jclear} clears a pending exception. } \usage{ .jcheck(silent = FALSE) .jthrow(exception, message = NULL) .jgetEx(clear = FALSE) .jclear() } \arguments{ \item{silent}{If set to \code{FALSE} then Java is instructed to print the exception on \code{stderr}. Note that Windows Rgui doesn't show \code{stderr} so it will not appear there (as of rJava 0.5-1 some errors that the JVM prints using the vfprintf callback are passed to R. However, some parts are printed using \code{System.err} in which case the usual redirection using the \code{System} class can be used by the user).} \item{exception}{is either a class name of an exception to create or a throwable object reference that is to be thrown.} \item{message}{if \code{exception} is a class name then this parameter specifies the string to be used as the message of the exception. This parameter is ignored if \code{exception} is a reference.} \item{clear}{if set to \code{TRUE} then the returned exception is also cleared, otherwise the throwable is returned without clearing the cause.} } \value{ \code{.jcheck} returns \code{TRUE} if an exception occurred or \code{FALSE} otherwise. \code{.jgetEx} returns \code{NULL} if there are no pending exceptions or an object of the class "java.lang.Throwable" representing the current exception. } \details{ Please note that some functions (such as \code{\link{.jnew}} or \code{\link{.jcall}}) call \code{.jcheck} implicitly unless instructed to not do so. If you want to handle Java exceptions, you should make sure that those function don't clear the exception you may want to catch. The exception handling is still as a very low-level and experimental, because it requires polling of exceptions. A more elaborate system using constructs similar to \code{try} ... \code{catch} is planned for next major version of \code{rJava}. \emph{Warning:} When requesting exceptions to not be cleared automatically, please note that the \code{show} method (which is called by \code{print}) has a side-effect of making a Java call to get the string representation of a Java object. This implies that it will be impeded by any pending exceptions. Therefore exceptions obtained through \code{.jgetEx} can be stored, but should not be printed (or otherwise used in Java calls) until after the exception is cleared. In general, all Java calls will fail (possibly silently) until the exception is cleared. } \seealso{ \code{\link{.jcall}}, \code{\link{.jnew}} } \examples{ \donttest{ # we try to create a bogus object and # instruct .jnew to not clear the exception # this will raise an exception v <- .jnew("foo/bar", check=FALSE) # you can poll for the exception, but don't try to print it # (see details above) if (!is.null(e<-.jgetEx())) print("Java exception was raised") # expect TRUE result here because the exception was still not cleared print(.jcheck(silent=TRUE)) # next invocation will be FALSE because the exception is now cleared print(.jcheck(silent=TRUE)) # now you can print the actual expection (even after it was cleared) print(e) } } \keyword{interface} rJava/man/clone.Rd0000644000175100001440000000223315133274032013475 0ustar hornikusers\name{clone} \alias{clone} \alias{clone,jobjRef-method} \alias{clone,jarrayRef-method} \alias{clone,jrectRef-method} \title{ Object cloner } \description{ Generic function to clone objects } \usage{ clone(x, ...) } \section{Methods}{ \describe{ \item{clone}{\code{signature(x = "jobjRef")}: clone a java object reference (must implement Cloneable) } \item{clone}{\code{signature(x = "jarrayRef")}: clone a java rugged array (not yet implemented) } \item{clone}{\code{signature(x = "jrectRef")}: clone a java rectangular array (not yet implemented) } } } \arguments{ \item{x}{An object to clone} \item{\dots}{Further arguments, ignored} } \value{ A clone of the object } \section{Warning}{ The implementation of clone for java object references uses the clone method of the Object class. The reading of its description in the java help page is \emph{strongly} recommended. } \examples{ \dontshow{.jinit()} p1 <- .jnew("java/awt/Point" ) p2 <- clone( p1 ) p2$move( 10L, 10L ) p1$getX() # check that p1 and p2 are not references to the same java object stopifnot( p1$getX() == 0 ) stopifnot( p2$getX() == 10 ) } \keyword{ programming } rJava/man/jsimplify.Rd0000644000175100001440000000276015133274032014410 0ustar hornikusers\name{jsimplify} \alias{.jsimplify} \title{ Converts Java object to a simple scalar if possible } \description{ \code{.jsimplify} attempts to convert Java objects that represent simple scalars into corresponding scalar representation in R. } \usage{ .jsimplify(o, promote=FALSE) } \arguments{ \item{o}{arbitrary object} \item{promote}{logical, if \code{TRUE} then an ambiguous conversion where the native type value would map to \code{NA} (e.g., Java \code{int} type with value -2147483648) will be taken to represent an actual value and will be promoted to a larger type that can represent the value (in case of \code{int} promoted to \code{double}). If \code{FALSE} then such values are assumed to represent \code{NA}s.} } \value{ Simple scalar or \code{o} unchanged. } \details{ If \code{o} is not a Java object reference, \code{o} is returned as-is. If \code{o} is a reference to a scalar object (such as single integer, number, string or boolean) then the value of that object is returned as R vector of the corresponding type and length one. This function is used by \code{\link{.jfield}} to simplify the results of field access if required. Currently there is no function inverse to this, the usual way to wrap scalar values in Java references is to use \code{\link{.jnew}} as the corresponding constructor. } \seealso{ \code{\link{.jfield}} } \examples{ \dontrun{ i <- .jnew("java/lang/Integer", as.integer(10)) print(i) print(.jsimplify(i)) } } \keyword{interface} rJava/man/jcall.Rd0000644000175100001440000001167615133274032013475 0ustar hornikusers\name{jcall} \alias{.jcall} \title{ Call a Java method } \description{ \code{.jcall} calls a Java method with the supplied arguments. } \usage{ .jcall(obj, returnSig = "V", method, ..., evalArray = TRUE, evalString = TRUE, check = TRUE, interface = "RcallMethod", simplify = FALSE, use.true.class = FALSE) } \arguments{ \item{obj}{Java object (\code{jobjRef} as returned by \code{\link{.jcall}} or \code{\link{.jnew}}) or fully qualified class name in JNI notation (e.g. \code{"java/lang/String"}).} \item{returnSig}{Return signature in JNI notation (e.g. "V" for void, "[I" for \code{int[]} etc.). For convenience additional type \code{"S"} is supported and expanded to \code{"Ljava/lang/String;"}, re-mapping \code{"T"} to represent the type \code{short}.} \item{method}{The name of the method to be called} \item{...}{ Any parameters that will be passed to the Java method. The parameter types are determined automatically and/or taken from the \code{jobjRef} object. All named parameters are discarded.} \item{evalArray}{This flag determines whether the array return value is evaluated (\code{TRUE}) or passed back as Java object reference (\code{FALSE}).} \item{simplify}{If \code{evalArray} is \code{TRUE} then this argument is passed to \code{\link{.jevalArray}()}.} \item{evalString}{This flag determines whether string result is returned as characters or as Java object reference.} \item{check}{If set to \code{TRUE} then checks for exceptions are performed before and after the call using \code{\link{.jcheck}(silent=FALSE)}. This is usually the desired behavior, because all calls fail until an exception is cleared.} \item{interface}{This option is experimental and specifies the interface used for calling the Java method; the current implementation supports two interfaces: \describe{ \item{\code{"RcallMethod"}}{the default interface.} \item{\code{"RcallSyncMethod"}}{synchronized call of a method. This has similar effect as using \code{synchronize} in Java.} } } \item{use.true.class}{logical. If set to \code{TRUE}, the true class of the returned object will be used instead of the declared signature. \code{TRUE} allows for example to grab the actual class of an object when the return type is an interface, or allows to grab an array when the declared type is Object and the returned object is an array. Use \code{FALSE} for efficiency when you are sure about the return type. } } \value{ Returns the result of the method. } \details{ \code{.jcall} requires exact match of argument and return types. For higher efficiency \code{.jcall} doesn't perform any lookup in the reflection tables. This means that passing subclasses of the classes present in the method definition requires explicit casting using \code{\link{.jcast}}. Passing \code{null} arguments also needs a proper class specification with \code{\link{.jnull}}. Java types \code{long} and \code{float} have no corresponding types in R and therefore any such parameters must be flagged as such using \code{\link{.jfloat}} and \code{\link{.jlong}} functions respectively. Java also distinguishes scalar and array types whereas R doesn't have the concept of a scalar. In R a scalar is basically a vector (called array in Java-speak) of the length 1. Therefore passing vectors of the length 1 is ambiguous. \code{.jcall} assumes that any vector of the length 1 that corresponds to a native Java type is a scalar. All other vectors are passed as arrays. Therefore it is important to use \code{\link{.jarray}} if an arbitrary vector (including those of the length 1) is to be passed as an array parameter. \emph{Important note about encoding of character vectors:} Java interface always works with strings in UTF-8 encoding, therefore the safest way is to run R in a UTF-8 locale. If that is not possible for some reason, rJava can be used in non-UTF-8 locales, but care must be taken. Since R 2.7.0 it is possible to associate encoding with strings and rJava will flag all strings it produces with the appropriate UTF-8 tag. R will then perform corresponding appropriate conversions where possible (at a cost of speed and memory usage), but 3rd party code may not (e.g. older packages). Also rJava relies on correct encoding flags for strings passed to it and will attempt to perform conversions where necessary. If some 3rd party code produces strings incorrectly flagged, all bets are off. Finally, for performance reasons class, method and field names as well as signatures are not always converted and should not contain non-ASCII characters. } \seealso{ \code{\link{.jnew}}, \code{\link{.jcast}}, \code{\link{.jnull}}, \code{\link{.jarray}} } \examples{ \dontshow{.jinit()} .jcall("java/lang/System","S","getProperty","os.name") if (!nzchar(Sys.getenv("NOAWT"))) { f <- .jnew("java/awt/Frame","Hello") .jcall(f,,"setVisible",TRUE) } } \keyword{interface} rJava/man/jserialize.Rd0000644000175100001440000001054215133274032014540 0ustar hornikusers\name{jserialize} \alias{.jserialize} \alias{.junserialize} \alias{.jcache} \title{ Java object serialization } \description{ \code{.jserialize} serializes a Java object into raw vector using Java serialization. \code{.junserialize} re-constructs a Java object from its serialized (raw-vector) form. \code{.jcache} updates, retrieves or removes R-side object cache which can be used for persistent storage of Java objects across sessions. } \usage{ .jserialize(o) .junserialize(data) .jcache(o, update=TRUE) } \arguments{ \item{o}{Java object} \item{data}{serialized Java object as a raw vector} \item{update}{must be \code{TRUE} (cache is updated), \code{FALSE} (cache is retrieved) or \code{NULL} (cache is deleted).} } \value{ \code{.jserialize} returns a raw vector \code{.junserialize} returns a Java object or \code{NULL} if an error occurred (currently you may use \code{.jcheck()} to further investigate the error) \code{.jcache} returns the current cache (usually a raw vector) or \code{NULL} if there is no cache. } \details{ Not all Java objects support serialization, see Java documentation for details. Note that Java serialization and serialization of R objects are two entirely different mechanisms that cannot be interchanged. \code{.jserialize} and \code{.junserialize} can be used to access Java serialization facilities. \code{.jcache} manipulates the R-side Java object cache associated with a given Java reference: Java objects do not persist across sessions, because the Java Virtual Machine (JVM) is destroyed when R is closed. All saved Java object references will be restored as \code{null} references, since the corresponding objects no longer exist (see R documentation on serialization). However, it is possible to serialize a Java object (if supported by the object) and store its serialized form in R. This allows for the object to be deserialized when loaded into another active session (but see notes below!) R-side cache consists of a serialized form of the object as raw vector. This cache is attached to the Java object and thus will be saved when the Java object is saved. rJava provides an automated way of deserializing Java references if they are \code{null} references and have a cache attached. This is done on-demand basis whenever a reference to a Java object is required. Therefore packages can use \code{.jcache} to provide a way of creating Java references that persist across sessions. However, they must be very cautious in doing so. First, make sure the serialized form is not too big. Storing whole datasets in Java serialized form will hog immense amounts of memory on the R side and should be avoided. In addition, be aware that the cache is just a snapshot, it doesn't change when the referenced Java object is modified. Hence it is most useful only for references that are not modified outside R. Finally, internal references to other Java objects accessible from R are not retained (see below). Most common use of \code{.jcache} is with Java references that point to definitions of methods (e.g., models) and other descriptive objects which are then used by other, active Java classes to act upon. Caching of such active objects is not a good idea, they should be instantiated by functions that operate on the descriptive references instead. \emph{Important note:} the serialization of Java references does NOT take into account any dependencies on the R side. Therefore if you hold a reference to a Java object in R that is also referenced by the serialized Java object on the Java side, then this relationship cannot be retained upon restore. Instead, two copies of disjoint objects will be created which can cause confusion and erroneous behavior. The cache is attached to the reference external pointer and thus it is shared with all copies of the same reference (even when changed via \code{\link{.jcast}} etc.), but it is independent of other references to the object obtained separately (e.g., via \code{\link{.jcall}} or \code{\link{.jfield}}). Also note that deserialization (even automated one) requires a running virtual machine. Therefore you must make sure that either \code{\link{.jinit}} or \code{\link{.jpackage}} is used before any Java references are accessed. } %\seealso{ %} %\examples{ %\dontrun{ %} %} \keyword{interface} rJava/man/jfield.Rd0000644000175100001440000000420215133274032013630 0ustar hornikusers\name{jfield} \alias{.jfield} \alias{.jfield<-} \title{ Obtains the value of a field } \description{ \code{.jfield} returns the value of the specified field on an object. } \usage{ .jfield(o, sig = NULL, name, true.class = is.null(sig), convert = TRUE) `.jfield<-`(o, name, value) } \arguments{ \item{o}{Class name or object (Java reference) whose field is to be accessed. Static fields are supported both by specifying the class name or using an instance.} \item{sig}{signature (JNI type) of the field. If set to \code{NULL} rJava attempts to determine the signature using reflection. For efficiency it is recommended to specify the signature, because the reflection lookup is quite expensive.} \item{name}{name of the field to access} \item{true.class}{by default the class of the resulting object matches the signature of the field. Setting this flag to \code{TRUE} causes \code{.jfield} to use true class name of the resulting object instead. (this flag has no effect on scalar fields)} \item{convert}{when set to \code{TRUE} all references are converted to native types (where possible). Otherwise Java references are returned directly.} \item{value}{value to assign into the field. The field signature is determined from the value in the same way that parameter signatures are determined in \code{\link{.jcall}} - be sure to cast the value as necessary, no automatic conversion is done.} } \value{ \code{.jfield}: contents of the field, \code{.jfield<-}: modified object. } \details{ The detection of a field signature in \code{.jfield} using reflection is considerably expensive (more than 3 additional method calls have to be performed), therefore it is recommended for time-critical code to specify the field signature beforehand. NOTE: The sequence of arguments in \code{.jfield} has been changed since rJava 0.5 to be more consistent and match the sequence in \code{.jcall}. Also \code{.jsimplify} is no longer needed as primitive types are obtained directly. } \seealso{ \code{\link{.jcall}} } \examples{ \dontrun{ .jfield("java/lang/Boolean",, "TYPE") } } \keyword{interface} rJava/man/new.Rd0000644000175100001440000000140115133274032013162 0ustar hornikusers\name{new} \alias{new,jclassName-method} \title{ Create a new Java object } \description{ Creates a new Java object and invokes the constructor with given arguments. } \section{Methods}{ \describe{ \item{\code{new}}{\code{signature(Class = "jclassName")}: ... } } } \details{ The \code{new} method is used as the high-level API to create new Java objects (for low-level access see \code{\link{.jnew}}). It returns the newly created Java object. \code{...} arguments are passed to the constructor of the class specified as \code{J("class.name")}. } \seealso{ \code{\link{.jnew}}, \code{\link{jclassName-class}} } \examples{ \dontrun{ v <- new(J("java.lang.String"), "Hello World!") v$length() v$indexOf("World") names(v) } } \keyword{interface} rJava/man/J.Rd0000644000175100001440000000447215133274032012575 0ustar hornikusers\name{J} \alias{J} \title{ High level API for accessing Java } \description{ \code{J} creates a Java class reference or calls a Java method } \usage{ J(class, method, ..., class.loader=.rJava.class.loader) } \arguments{ \item{class}{ java object reference or fully qualified class name in JNI notation (e.g "java/lang/String" ) or standard java notation (e.g "java.lang.String") } \item{method}{ if present then \code{J} results in a method call, otherwise it just creates a class name reference. } \item{\dots}{ optional parameters that will be passed to the method (if the \code{method} argument is present) } \item{class.loader}{optional, custom loader to use if a class look-up is necessary (i.e., if \code{class} is a string)} } \details{ \code{J} is the high-level access to Java. If the \code{method} argument is missing then \code{code} must be a class name and \code{J} creates a class name reference that can be used either in a call to \code{new} to create a new Java object (e.g. \code{new(J("java.lang.String"), "foo")}) or with \code{$} operator to call a static method (e.g. \code{J("java.lang.Double")$parseDouble("10.2")}.) If the \code{method} argument is present then it must be a string vector of length one which defines the method to be called on the object. } \value{ If \code{method} is missing the the returned value is an object of the class \code{jclassName}. Otherwise the value is the result of the method invocation. In the latter case Java exceptions may be thrown and the function doesn't return. } \note{ \code{J} is a high-level API which is slower than \code{\link{.jnew}} or \code{\link{.jcall}} since it has to use reflection to find the most suitable method. } \seealso{ \code{\link{.jcall}}, \code{\link{.jnew}} } \examples{ \dontshow{.jinit()} if (!nzchar(Sys.getenv("NOAWT"))) { f <- new(J("java.awt.Frame"), "Hello") f$setVisible(TRUE) } J("java.lang.Double")$parseDouble("10.2") J("java.lang.Double", "parseDouble", "10.2" ) Double <- J("java.lang.Double") Double$parseDouble( "10.2") # String[] strings = new String[]{ "string", "array" } ; strings <- .jarray( c("string", "array") ) # this uses the JList( Object[] ) constructor # even though the "strings" parameter is a String[] l <- new( J("javax.swing.JList"), strings) } \keyword{interface} rJava/man/instanceof.Rd0000644000175100001440000000243615133274032014533 0ustar hornikusers\name{.jinstanceof} \Rdversion{1.1} \alias{\%instanceof\%} \alias{.jinstanceof} \title{ Is a java object an instance of a given java class } \description{ Is a java object an instance of a given java class } \usage{ o \%instanceof\% cl .jinstanceof( o, cl ) } \arguments{ \item{o}{java object reference} \item{cl}{java class. This can be a character vector of length one giving the name of the class, or another java object, or an instance of the Class class, or a object of class \code{jclassName}.} } \value{ TRUE if o is an instance of cl } \author{ Romain Francois } \examples{ \dontshow{ .jinit() } Double <- J("java.lang.Double") d <- new( Double, "10.2" ) # character d \%instanceof\% "java.lang.Double" d \%instanceof\% "java.lang.Number" # jclassName d \%instanceof\% Double # instance of Class Double.class <- Double@jobj d \%instanceof\% Double.class # other object other.double <- new( Double, 10.2 ) d \%instanceof\% other.double \dontshow{ % simple unit tests stopifnot( d \%instanceof\% "java.lang.Double" ) stopifnot( d \%instanceof\% "java.lang.Number" ) stopifnot( d \%instanceof\% "java.lang.Object" ) stopifnot( d \%instanceof\% Double.class ) stopifnot( d \%instanceof\% other.double ) stopifnot( d \%instanceof\% Double ) } } \keyword{ interface } rJava/man/jengine.Rd0000644000175100001440000000230415133274032014013 0ustar hornikusers\name{jengine} \alias{.jengine} \title{ Java callback engineCast a Java object to another class } \description{ \code{.jengine} obtains the current callback engine or starts it. } \usage{ .jengine(start=FALSE, silent=FALSE) } \arguments{ \item{start}{if set to \code{TRUE} then the callback engine is started if it is not yet active} \item{silent}{if set to \code{TRUE} then NULL is returned if there is no engine available. Otherwise an error is raised} } \value{ Returns a Java object reference (\code{jobjRef}) to the current Java callback engine. } \details{ \code{.jengine} can be used to detect whether the engine was started or to start the engine. Before any callbacks from Java into R can be performed, the Java callback engine must be initialized, loading Java/R Interface (JRI). If JRI was not started and \code{start} is set to \code{TRUE} then \code{.jengine} will load necessary classes and start it. Note that JRI is an optional part of rJava and requires R shared library at the moment. By default rJava will continue with installation even if JRI cannot be built. } \seealso{ \code{\link{.jcall}} } \examples{ \dontrun{ .jengine(TRUE) } } \keyword{interface} rJava/man/aslist.Rd0000644000175100001440000000266715133274032013707 0ustar hornikusers\name{aslist} \alias{as.list.jobjRef} \alias{as.list.jarrayRef} \alias{as.list.jrectRef} \title{ Converts java objects or arrays to R lists } \description{ \code{as.list} is implemented for java objects and java arrays to facilitate using \code{lapply} calls over elements of a java array or items of an Iterator associated with an Iterable object For java array references, \code{as.list} is mapped to \code{\link{.jevalArray}} For java objects that implement the Iterable interface, the list is created by iterating over the associated iterator } \usage{ \S3method{as.list}{jobjRef}(x, ...) \S3method{as.list}{jarrayRef}(x, ...) } \arguments{ \item{x}{java array or Iterable java object} \item{\dots}{ignored} } \value{ An R list, or vector. } \note{ The function is not intended to be called directly. It is implemented so that java arrays or Iterable java objects can be used as the first argument of \code{\link{lapply}} } \seealso{ \code{\link{.jevalArray}}, \code{\link{lapply}} } \examples{ \dontshow{.jinit()} # lapplying over a java array a <- .jarray( list( .jnew( "java/awt/Point", 10L, 10L ), .jnew( "java/awt/Point", 30L, 30L ) ) ) lapply( a, function(point){ with(point, { (x + y ) ^ 2 } ) } ) # lapply over a Vector (implements Iterable) v <- .jnew("java/util/Vector") v$add( "foo" ) v$add( .jnew("java/lang/Double", 10.2 ) ) sapply( v, function(item) item$getClass()$getName() ) } \keyword{ programming } rJava/man/jpackage.Rd0000644000175100001440000001150115133274032014140 0ustar hornikusers\name{jpackage} \alias{.jpackage} \title{ Initialize an R package containing Java code } \description{ \code{.jpackage} initializes the Java Virtual Machine (JVM) for an R package. In addition to starting the JVM it also registers Java classes and native code contained in the package with the JVM. function must be called before any rJava functions can be used. } \usage{ .jpackage(name, jars='*', morePaths='', nativeLibrary=FALSE, lib.loc=NULL, parameters = getOption("java.parameters"), own.loader = FALSE) } \arguments{ \item{name}{name of the package. It should correspond to the \code{pkgname} parameter of \code{.onLoad} or \code{.First.lib} function.} \item{jars}{Java archives in the \code{java} directory of the package that should be added to the class path. The paths must be relative to package's \code{java} directory. A special value of \code{'*'} adds all \code{.jar} files from the \code{java} the directory.} \item{morePaths}{vector listing any additional entries that should be added to the class path.} \item{nativeLibrary}{a logical determining whether rJava should look for native code in the R package's shared object or not.} \item{lib.loc}{a character vector with path names of R libraries, or \code{NULL} (see \code{\link{system.file}} and examples below).} \item{parameters}{optional JVM initialization parameters which will be used if JVM is not initilized yet (see \code{\link{.jinit}}).} \item{own.loader}{if \code{TRUE} then a new, separate class loader will be initilized for the package and assigned to the \code{.pkg.class.loader} variable in the package namespace. New packages should make use of this feature.} } \value{ The return value is an invisible TRUE if the initialization was successful. } \details{ \code{.jpackage} initializes a Java R package as follows: first the JVM is initialized via \code{\link{.jinit}} (if it is not running already). Then the \code{java} directory of the package is added to the class path. Then \code{.jpackage} prepends \code{jars} with the path to the \code{java} directory of the package and adds them to the class path (or all \code{.jar} files if \code{'*'} was specified). Finally the \code{morePaths} parameter (if set) is passed to a call to \code{\link{.jaddClassPath}}. Therefore the easiest way to create a Java package is to add \code{.jpackage(pkgname, lib.loc=libname)} in \code{.onLoad} or \code{.First.lib}, and copy all necessary classes to a JAR file(s) which is placed in the \code{inst/java/} directory of the source package. If a package needs special Java parameters, \code{"java.parameters"} option can be used to set them on initialization. Note, however, that Java parameters can only be used during JVM initialization and other package may have intialized JVM already. Since rJava 0.9-14 there is support of package-specific class loaders using the \code{own.loader=TRUE} option. This is important for packages that may be using classes that conflict with other packages are therefore is highly recommended for new packages. Before this feature, there was only one global class loader which means that the class path was shared for all class look ups. If two packages use the same (fully qualified) class name, even in a dependency, they are likely to clash with each if they don't use exactly the same version. Therefore it is safer for each package use use a private class loader for its classes to guarantee that the only the classes supplied with the package will be used. To do that, a package will set \code{own.loader=TRUE} which instructs rJava to not change the global loader, but instead create a separate one for the package and assign it to \code{.rJava.class.loader} in the package namespace. Then if package wants to instantiate a new class, it would use \code{.jnew("myClass", class.loader=.rJava.class.loader)} to use its own loader instead of the global one. The global loader's class path won't be touched, so it won't find the package's classes. It is possible to get the loader used in a package using \code{.jclassLoader(package="foo")} which will return the global one if the package has not registered its own. Similarly, to retrieve the class path used by a package, one would use \code{.jclassPath(.jclassLoader(package="foo"))}. Note that with the advent of multiple class loaders the value of the \code{java.class.path} property is no longer meaningful as it can reflect only one of the loaders. } \seealso{ \code{\link{.jinit}} } \examples{ \dontrun{ .onLoad <- function(libname, pkgname) { .jpackage(pkgname, lib.loc=libname, own.loader=TRUE) ## do not use, just an illustration of the concept: cat("my Java class path: ") print(.jclassPath(.jclassLoader(package=pkgname))) } } } \keyword{interface} rJava/man/jrectRef-class.Rd0000644000175100001440000002531315133274032015250 0ustar hornikusers\name{jrectRef-class} \Rdversion{1.1} \docType{class} \alias{jrectRef-class} \alias{[,jrectRef-method} \alias{length,jrectRef-method} \alias{str,jrectRef-method} \alias{dim,jrectRef-method} \alias{dim<-,jrectRef-method} \alias{unique,jrectRef-method} \alias{duplicated,jrectRef-method} \alias{anyDuplicated,jrectRef-method} \alias{sort,jrectRef-method} \alias{rev,jrectRef-method} \alias{min,jrectRef-method} \alias{max,jrectRef-method} \alias{range,jrectRef-method} \title{Rectangular java arrays} \description{References to java arrays that are guaranteed to be rectangular, i.e similar to R arrays} \section{Objects from the Class}{ Objects of this class should *not* be created directly. Instead, they usually come as a result of a java method call. } \section{Slots}{ \describe{ \item{\code{jsig}:}{JNI signature of the array type} \item{\code{jobj}:}{Internal identifier of the object} \item{\code{jclass}:}{Inherited from \code{jobjRef}, but unspecified} \item{\code{dimension}:}{dimension vector of the array} } } \section{Extends}{ Class \code{"\linkS4class{jarrayRef}"}, directly. Class \code{"\linkS4class{jobjRef}"}, by class "jarrayRef", distance 2. } \section{Methods}{ \describe{ \item{length}{\code{signature(x = "jrectRef")}: The number of elements in the array. Note that if the array has more than one dimension, it gives the number of arrays in the first dimension, and not the total number of atomic objects in the array (like R does). This gives what would be returned by \code{array.length} in java.} \item{str}{\code{signature(object = "jrectRef")}: ... } \item{[}{\code{signature(x = "jrectRef")}: R indexing of rectangular java arrays } \item{dim}{\code{signature(x = "jrectRef")}: extracts the dimensions of the array } \item{dim<-}{\code{signature(x = "jrectRef")}: sets the dimensions of the array } \item{unique}{\code{signature(x = "jrectRef")}: unique objects in the array} \item{duplicated}{\code{signature(x = "jrectRef")}: see \code{\link{duplicated}} } \item{anyDuplicated}{\code{signature(x = "jrectRef")}: see \code{\link{anyDuplicated}} } \item{sort}{\code{signature(x = "jrectRef")}: returns a \emph{new} array with elements from x in order } \item{rev}{\code{signature(x = "jrectRef")}: returns a \emph{new} array with elements from x reversed } \item{min}{\code{signature(x = "jrectRef")}: the smallest object in the array (in the sense of the Comparable interface) } \item{max}{\code{signature(x = "jrectRef")}: the biggest object in the array (in the sense of the Comparable interface) } \item{range}{\code{signature(x = "jrectRef")}: the range of the array (in the sense of the Comparable interface) } } } \examples{ \dontshow{ # these examples are only unit tests so far .jinit() } v <- new( J("java.util.Vector") ) v$add( "hello" ) v$add( "world" ) v$add( new( J("java.lang.Double"), "10.2" ) ) array <- v$toArray() array[ c(TRUE,FALSE,TRUE) ] array[ 1:2 ] array[ -3 ] # length length( array ) \dontshow{stopifnot(length(array) == 3L)} # also works as a pseudo field as in java array$length \dontshow{stopifnot(array$length == 3L)} \dontshow{ # # 2d dim2d <- c(5L, 2L) x <- .jcall( "RectangularArrayExamples", "[[Z", "getBooleanDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE) stopifnot( identical( typeof( x ), "logical" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), rep( c(FALSE,TRUE), 5 ) ) ) x <- .jcall( "RectangularArrayExamples", "[[I", "getIntDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), 0:9 ) ) x <- .jcall( "RectangularArrayExamples", "[[B", "getByteDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "raw" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.raw(0:9) ) ) x <- .jcall( "RectangularArrayExamples", "[[J", "getLongDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.numeric(0:9) ) ) x <- .jcall( "RectangularArrayExamples", "[[S", "getShortDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), 0:9 ) ) x <- .jcall( "RectangularArrayExamples", "[[D", "getDoubleDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.numeric(0:9) ) ) x <- .jcall( "RectangularArrayExamples", "[[C", "getCharDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), 0:9 ) ) x <- .jcall( "RectangularArrayExamples", "[[F", "getFloatDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.numeric(0:9) ) ) x <- .jcall( "RectangularArrayExamples", "[[Ljava/lang/String;", "getStringDoubleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "character" ) ) stopifnot( identical( dim(x) , dim2d ) ) stopifnot( identical( as.vector(x), as.character(0:9) ) ) # 3d dim3d <- c(5L, 3L, 2L) x <- .jcall( "RectangularArrayExamples", "[[[Z", "getBooleanTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE) stopifnot( identical( typeof( x ), "logical" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), rep( c(FALSE,TRUE), 15L ) ) ) x <- .jcall( "RectangularArrayExamples", "[[[I", "getIntTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), 0:29 ) ) x <- .jcall( "RectangularArrayExamples", "[[[B", "getByteTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "raw" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.raw(0:29) ) ) x <- .jcall( "RectangularArrayExamples", "[[[J", "getLongTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.numeric(0:29) ) ) x <- .jcall( "RectangularArrayExamples", "[[[S", "getShortTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), 0:29 ) ) x <- .jcall( "RectangularArrayExamples", "[[[D", "getDoubleTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.numeric(0:29) ) ) x <- .jcall( "RectangularArrayExamples", "[[[C", "getCharTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "integer" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), 0:29 ) ) x <- .jcall( "RectangularArrayExamples", "[[[F", "getFloatTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "double" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.numeric(0:29) ) ) x <- .jcall( "RectangularArrayExamples", "[[[Ljava/lang/String;", "getStringTripleRectangularArrayExample", evalArray = TRUE, simplify = TRUE ) stopifnot( identical( typeof( x ), "character" ) ) stopifnot( identical( dim(x) , dim3d ) ) stopifnot( identical( as.vector(x), as.character(0:29) ) ) # testing the indexing xj <- .jarray( x, dispatch = TRUE ) stopifnot( dim( xj[ ,, ] ) == c( 5L, 3L, 2L ) ) stopifnot( dim( xj[ ] ) == c( 5L, 3L, 2L ) ) stopifnot( dim( xj[ ,,1,drop= TRUE] ) == c( 5L, 3L ) ) stopifnot( dim( xj[ ,,1,drop= FALSE] ) == c( 5L, 3L, 1L ) ) stopifnot( dim( xj[ ,1,,drop= TRUE] ) == c( 5L, 2L ) ) stopifnot( dim( xj[ ,1,,drop= FALSE] ) == c( 5L, 1L, 2L ) ) stopifnot( dim( xj[ 1,,,drop= TRUE] ) == c( 3L, 2L ) ) stopifnot( dim( xj[ 1,,,drop= FALSE] ) == c( 1L, 3L, 2L ) ) stopifnot( dim( xj[ ,1,1,drop= TRUE] ) == c( 5L ) ) stopifnot( dim( xj[ ,1,1,drop= FALSE] ) == c( 5L, 1L, 1L ) ) stopifnot( dim( xj[ 1,1,1,drop= TRUE] ) == c( 1L ) ) stopifnot( dim( xj[ 1,1,1,drop= FALSE] ) == c( 1L, 1L, 1L ) ) # testing simplify stopifnot( identical( xj[simplify=TRUE], x) ) stopifnot( identical( xj[,1,,simplify=TRUE], x[,1,]) ) stopifnot( identical( xj[,1,-1,simplify=TRUE], x[,1,-1]) ) stopifnot( identical( xj[4,1,c(TRUE,FALSE),simplify=TRUE], x[4,1,c(TRUE,FALSE)]) ) stopifnot( identical( xj[1:10,simplify=TRUE], x[1:10]) ) # test dim<- dim( xj ) <- c( 15L, 2L ) stopifnot( xj@jsig == "[[Ljava/lang/String;" ) stopifnot( dim( xj ) == c(15L, 2L ) ) dim( xj ) <- NULL stopifnot( xj@jsig == "[Ljava/lang/String;" ) stopifnot( dim( xj ) == 30L ) # test unique # **** FIXME: this should really work even with dispatch=FALSE since # it's a vector but it does not! It applies to everything # below x <- .jarray( rep( 1:2, each = 5 ), dispatch = TRUE ) xu <- unique( x ) stopifnot( dim(xu) == 2L ) p1 <- .jnew( "java/awt/Point" ) p2 <- .jnew( "java/awt/Point" ) x <- .jarray( list( p1, p2 ), dispatch = TRUE ) xu <- unique( x ) stopifnot( dim( xu ) == 1L ) # test duplicated x <- .jarray( rep( 1:2, each = 5 ), dispatch = TRUE ) xd <- duplicated( x ) stopifnot( xd == rep( c( FALSE, TRUE, TRUE, TRUE, TRUE), 2L ) ) if (rJava:::.base.has.anyDuplicated) stopifnot( anyDuplicated( x ) == 2L ) p1 <- .jnew( "java/awt/Point" ) p2 <- .jnew( "java/awt/Point" ) x <- .jarray( list( p1, p2 ), dispatch = TRUE ) xd <- duplicated( x ) stopifnot( xd == c( FALSE, TRUE) ) if (rJava:::.base.has.anyDuplicated) stopifnot( anyDuplicated( x ) == 2L ) # test sort, rev d1 <- .jnew("java/lang/Double", 0) d2 <- .jnew("java/lang/Double", -1) a <- .jarray( list( d1, d2), dispatch = TRUE ) stopifnot( sort( a )[[1]]$doubleValue() == -1.0 ) stopifnot( rev( a )[[1]]$doubleValue() == -1.0 ) # test min, max, range Double <- J("java.lang.Double") a <- .jarray( list( new( Double, 10 ), new( Double, 4), new( Double, 5) ), "java/lang/Double", dispatch = TRUE ) stopifnot( min( a )$doubleValue() == 4 ) stopifnot( max( a )$doubleValue() == 10 ) stopifnot( range(a)[[1]]$doubleValue() == 4 ) stopifnot( range(a)[[2]]$doubleValue() == 10) } } \keyword{classes} rJava/DESCRIPTION0000644000175100001440000000160115133645240013042 0ustar hornikusersPackage: rJava Version: 1.0-14 Title: Low-Level R to Java Interface Author: Simon Urbanek [aut, cre, cph] (https://urbanek.nz, ORCID: ) Maintainer: Simon Urbanek Authors@R: person("Simon", "Urbanek", role=c("aut","cre","cph"), email="Simon.Urbanek@r-project.org", comment=c("https://urbanek.nz", ORCID="0000-0003-2297-1732")) Depends: R (>= 3.6.0), methods Description: Low-level interface to Java VM very much like .C/.Call and friends. Allows creation of objects, calling methods and accessing fields. License: LGPL-2.1 URL: http://www.rforge.net/rJava/ SystemRequirements: Java JDK 1.2 or higher (for JRI/REngine JDK 1.4 or higher), GNU make BugReports: https://github.com/s-u/rJava/issues NeedsCompilation: yes Packaged: 2026-01-19 00:17:35 UTC; rforge Repository: CRAN Date/Publication: 2026-01-20 09:28:00 UTC