Goran Jakovljevic | 73a4265 | 2015-11-20 17:22:57 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | public class Main { |
| 18 | |
| 19 | private class Inner { |
| 20 | private long i1; |
Alexey Frunze | 2923db7 | 2016-08-20 01:55:47 -0700 | [diff] [blame] | 21 | private double i2; |
Goran Jakovljevic | 73a4265 | 2015-11-20 17:22:57 +0100 | [diff] [blame] | 22 | } |
| 23 | private Inner inst; |
| 24 | |
| 25 | public static void main(String args[]) throws Exception { |
| 26 | Main m = new Main(); |
| 27 | try { |
| 28 | m.$opt$noinline$testGetLong(); |
| 29 | } catch (NullPointerException ex) { |
Alexey Frunze | 2923db7 | 2016-08-20 01:55:47 -0700 | [diff] [blame] | 30 | System.out.println("NPE from GetLong"); |
Goran Jakovljevic | 73a4265 | 2015-11-20 17:22:57 +0100 | [diff] [blame] | 31 | } |
| 32 | try { |
| 33 | m.$opt$noinline$testPutLong(778899112233L); |
| 34 | } catch (NullPointerException ex) { |
Alexey Frunze | 2923db7 | 2016-08-20 01:55:47 -0700 | [diff] [blame] | 35 | System.out.println("NPE from PutLong"); |
| 36 | } |
| 37 | try { |
| 38 | m.$opt$noinline$testGetDouble(); |
| 39 | } catch (NullPointerException ex) { |
| 40 | System.out.println("NPE from GetDouble"); |
| 41 | } |
| 42 | try { |
| 43 | m.$opt$noinline$testPutDouble(1.0); |
| 44 | } catch (NullPointerException ex) { |
| 45 | System.out.println("NPE from PutDouble"); |
Goran Jakovljevic | 73a4265 | 2015-11-20 17:22:57 +0100 | [diff] [blame] | 46 | } |
| 47 | } |
| 48 | |
| 49 | public void $opt$noinline$testGetLong() throws Exception { |
| 50 | long result = inst.i1; |
| 51 | throw new Exception(); // prevent inline |
| 52 | } |
| 53 | |
| 54 | public void $opt$noinline$testPutLong(long a) throws Exception { |
| 55 | inst.i1 = a; |
| 56 | throw new Exception(); // prevent inline |
| 57 | } |
Alexey Frunze | 2923db7 | 2016-08-20 01:55:47 -0700 | [diff] [blame] | 58 | |
| 59 | public void $opt$noinline$testGetDouble() throws Exception { |
| 60 | double result = inst.i2; |
| 61 | throw new Exception(); // prevent inline |
| 62 | } |
| 63 | |
| 64 | public void $opt$noinline$testPutDouble(double a) throws Exception { |
| 65 | inst.i2 = a; |
| 66 | throw new Exception(); // prevent inline |
| 67 | } |
Goran Jakovljevic | 73a4265 | 2015-11-20 17:22:57 +0100 | [diff] [blame] | 68 | } |