136f55ffcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
336f55ffcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
436f55ffcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
536f55ffcSAndrew Rist  * distributed with this work for additional information
636f55ffcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
736f55ffcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
836f55ffcSAndrew Rist  * "License"); you may not use this file except in compliance
936f55ffcSAndrew Rist  * with the License.  You may obtain a copy of the License at
1036f55ffcSAndrew Rist  *
1136f55ffcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1236f55ffcSAndrew Rist  *
1336f55ffcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1436f55ffcSAndrew Rist  * software distributed under the License is distributed on an
1536f55ffcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1636f55ffcSAndrew Rist  * KIND, either express or implied.  See the License for the
1736f55ffcSAndrew Rist  * specific language governing permissions and limitations
1836f55ffcSAndrew Rist  * under the License.
1936f55ffcSAndrew Rist  *
2036f55ffcSAndrew Rist  *************************************************************/
2136f55ffcSAndrew Rist 
2236f55ffcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_jvmfwk.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "osl/thread.h"
28cdf0e10cSrcweir #include "sunjre.hxx"
29cdf0e10cSrcweir #include "sunversion.hxx"
30cdf0e10cSrcweir #include "diagnostics.h"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace std;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
35cdf0e10cSrcweir namespace jfw_plugin
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 
38696f238bSAriel Constenla-Haile rtl::Reference<VendorBase> SunInfo::createInstance()
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     return new SunInfo;
41cdf0e10cSrcweir }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir char const* const* SunInfo::getJavaExePaths(int * size)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir     static char const * ar[] = {
46cdf0e10cSrcweir #if defined(WNT) || defined(OS2)
47cdf0e10cSrcweir         "java.exe",
48cdf0e10cSrcweir         "bin/java.exe",
49cdf0e10cSrcweir         "jre/bin/java.exe"
50cdf0e10cSrcweir #elif UNX
51cdf0e10cSrcweir         "java",
52cdf0e10cSrcweir         "bin/java",
53cdf0e10cSrcweir         "jre/bin/java"
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir     };
56cdf0e10cSrcweir         *size = sizeof (ar) / sizeof (char*);
57cdf0e10cSrcweir     return ar;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir char const* const* SunInfo::getRuntimePaths(int * size)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     static char const* ar[]= {
63cdf0e10cSrcweir #if defined(WNT)
64cdf0e10cSrcweir         "/bin/client/jvm.dll",
65cdf0e10cSrcweir         "/bin/hotspot/jvm.dll",
663bdaae44SAriel Constenla-Haile         "/bin/classic/jvm.dll",
673bdaae44SAriel Constenla-Haile         "/bin/jrockit/jvm.dll"
68cdf0e10cSrcweir #elif defined(OS2)
69cdf0e10cSrcweir         "/bin/classic/jvm.dll",
700fff73caSYuri Dario         "/bin/client/jvm.dll",
713bdaae44SAriel Constenla-Haile         // TODO add jrockit here
72*83f1bc14SHerbert Dürr #elif defined(MACOSX)
73*83f1bc14SHerbert Dürr         "/lib/server/libjvm.dylib"
74*83f1bc14SHerbert Dürr #elif defined(UNX)
75cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/client/libjvm.so",
76cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/server/libjvm.so",
773bdaae44SAriel Constenla-Haile         "/lib/" JFW_PLUGIN_ARCH "/classic/libjvm.so",
783bdaae44SAriel Constenla-Haile         "/lib/" JFW_PLUGIN_ARCH "/jrockit/libjvm.so"
79cdf0e10cSrcweir #endif
80cdf0e10cSrcweir     };
81cdf0e10cSrcweir     *size = sizeof(ar) / sizeof (char*);
82cdf0e10cSrcweir     return ar;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir char const* const* SunInfo::getLibraryPaths(int* size)
86cdf0e10cSrcweir {
87696f238bSAriel Constenla-Haile #ifdef UNX
88cdf0e10cSrcweir     static char const * ar[] = {
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/client",
91cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH "/native_threads",
92cdf0e10cSrcweir         "/lib/" JFW_PLUGIN_ARCH
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     };
95cdf0e10cSrcweir     *size = sizeof(ar) / sizeof (char*);
96cdf0e10cSrcweir     return ar;
97cdf0e10cSrcweir #else
98cdf0e10cSrcweir     size = 0;
99cdf0e10cSrcweir     return NULL;
100cdf0e10cSrcweir #endif
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir int SunInfo::compareVersions(const rtl::OUString& sSecond) const
104cdf0e10cSrcweir {
105696f238bSAriel Constenla-Haile     rtl::OUString sFirst = getVersion();
106696f238bSAriel Constenla-Haile 
107cdf0e10cSrcweir     SunVersion version1(sFirst);
108cdf0e10cSrcweir     JFW_ENSURE(version1, OUSTR("[Java framework] sunjavaplugin"SAL_DLLEXTENSION
109cdf0e10cSrcweir                                " does not know the version: ")
110696f238bSAriel Constenla-Haile                + sFirst + OUSTR(" as valid for a SUN/Oracle JRE."));
111cdf0e10cSrcweir     SunVersion version2(sSecond);
112cdf0e10cSrcweir     if ( ! version2)
113cdf0e10cSrcweir         throw MalformedVersionException();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     if(version1 == version2)
116cdf0e10cSrcweir         return 0;
117cdf0e10cSrcweir     if(version1 > version2)
118cdf0e10cSrcweir         return 1;
119cdf0e10cSrcweir     else
120cdf0e10cSrcweir         return -1;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir }
125