1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_plugin.hxx"
26 
27 #include "osl/thread.h"
28 #include "sunjre.hxx"
29 #include "sunversion.hxx"
30 #include "diagnostics.h"
31 
32 using namespace std;
33 
34 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
35 namespace jfw_plugin
36 {
37 
createInstance()38 rtl::Reference<VendorBase> SunInfo::createInstance()
39 {
40     return new SunInfo;
41 }
42 
getJavaExePaths(int * size)43 char const* const* SunInfo::getJavaExePaths(int * size)
44 {
45     static char const * ar[] = {
46 #if defined(WNT) || defined(OS2)
47         "java.exe",
48         "bin/java.exe",
49         "jre/bin/java.exe"
50 #elif UNX
51         "java",
52         "bin/java",
53         "jre/bin/java"
54 #endif
55     };
56         *size = sizeof (ar) / sizeof (char*);
57     return ar;
58 }
59 
getRuntimePaths(int * size)60 char const* const* SunInfo::getRuntimePaths(int * size)
61 {
62     static char const* ar[]= {
63 #if defined(WNT)
64         "/bin/client/jvm.dll",
65         "/bin/hotspot/jvm.dll",
66         "/bin/classic/jvm.dll",
67         "/bin/jrockit/jvm.dll"
68 #elif defined(OS2)
69         "/bin/classic/jvm.dll",
70         "/bin/client/jvm.dll",
71         // TODO add jrockit here
72 #elif defined(MACOSX)
73         "/lib/server/libjvm.dylib"
74 #elif defined(UNX)
75         "/lib/" JFW_PLUGIN_ARCH "/client/libjvm.so",
76         "/lib/" JFW_PLUGIN_ARCH "/server/libjvm.so",
77         "/lib/" JFW_PLUGIN_ARCH "/classic/libjvm.so",
78         "/lib/" JFW_PLUGIN_ARCH "/jrockit/libjvm.so",
79         "/lib/server/libjvm.so" // > 1.8
80 #endif
81     };
82     *size = sizeof(ar) / sizeof (char*);
83     return ar;
84 }
85 
getLibraryPaths(int * size)86 char const* const* SunInfo::getLibraryPaths(int* size)
87 {
88 #ifdef UNX
89     static char const * ar[] = {
90 
91         "/lib/" JFW_PLUGIN_ARCH "/client",
92         "/lib/" JFW_PLUGIN_ARCH "/native_threads",
93         "/lib/" JFW_PLUGIN_ARCH,
94         "/lib" // > 1.8
95 
96     };
97     *size = sizeof(ar) / sizeof (char*);
98     return ar;
99 #else
100     size = 0;
101     return NULL;
102 #endif
103 }
104 
compareVersions(const rtl::OUString & sSecond) const105 int SunInfo::compareVersions(const rtl::OUString& sSecond) const
106 {
107     rtl::OUString sFirst = getVersion();
108 
109     SunVersion version1(sFirst);
110     JFW_ENSURE(version1, OUSTR("[Java framework] sunjavaplugin" SAL_DLLEXTENSION
111                                " does not know the version: ")
112                + sFirst + OUSTR(" as valid for a SUN/Oracle JRE."));
113     SunVersion version2(sSecond);
114     if ( ! version2)
115         throw MalformedVersionException();
116 
117     if(version1 == version2)
118         return 0;
119     if(version1 > version2)
120         return 1;
121     else
122         return -1;
123 }
124 
125 
126 }
127