Apache Mesos
lang.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __JAVA_LANG_HPP__
18 #define __JAVA_LANG_HPP__
19 
20 #include <jvm/jvm.hpp>
21 
22 namespace java {
23 namespace lang {
24 
25 class Throwable : public Jvm::Object
26 {
27 public:
28  explicit Throwable(const std::string& message)
29  {
30  static Jvm::Constructor constructor = Jvm::get()->findConstructor(
31  Jvm::Class::named("java/lang/Throwable")
32  .constructor()
33  .parameter(Jvm::get()->stringClass));
34 
35  object = Jvm::get()->invoke(constructor, Jvm::get()->string(message));
36  }
37 
38 private:
39  friend void Jvm::check(JNIEnv* env); // For constructing default instances.
40 
41  Throwable() {}
42 };
43 
44 } // namespace lang {
45 } // namespace java {
46 
47 #endif // __JAVA_LANG_HPP__
Definition: lang.hpp:25
void check(JNIEnv *env)
Constructor findConstructor(const ConstructorFinder &finder)
Definition: jvm.hpp:144
Definition: jvm.hpp:244
static Jvm * get()
Definition: io.hpp:22
jobject invoke(const Constructor ctor,...)
Throwable(const std::string &message)
Definition: lang.hpp:28
static const Class named(const std::string &name)