Apache Mesos
io.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_IO_HPP__
18 #define __JAVA_IO_HPP__
19 
20 #include <jvm/jvm.hpp>
21 
22 namespace java {
23 namespace io {
24 
25 class File : public Jvm::Object
26 {
27 public:
28  explicit File(const std::string& pathname)
29  {
30  static Jvm::Constructor constructor = Jvm::get()->findConstructor(
31  Jvm::Class::named("java/io/File")
32  .constructor()
33  .parameter(Jvm::get()->stringClass));
34 
35  object = Jvm::get()->invoke(constructor, Jvm::get()->string(pathname));
36  }
37 
38  void deleteOnExit()
39  {
40  static Jvm::Method method = Jvm::get()->findMethod(
41  Jvm::Class::named("java/io/File")
42  .method("deleteOnExit")
43  .returns(Jvm::get()->voidClass));
44 
45  Jvm::get()->invoke<void>(object, method);
46  }
47 };
48 
49 } // namespace io {
50 } // namespace java {
51 
52 #endif // __JAVA_IO_HPP__
Constructor findConstructor(const ConstructorFinder &finder)
void deleteOnExit()
Definition: io.hpp:38
Method findMethod(const MethodSignature &signature)
Definition: jvm.hpp:144
Definition: jvm.hpp:208
Definition: jvm.hpp:244
static Jvm * get()
jobject object
Definition: jvm.hpp:287
File(const std::string &pathname)
Definition: io.hpp:28
Definition: io.hpp:22
Definition: io.hpp:25
jobject invoke(const Constructor ctor,...)
static const Class named(const std::string &name)