test/tools/javac/linenumbers/FinallyLineNumberTest.java

changeset 3497
08a21473de54
parent 3371
7220be8747f0
     1.1 --- a/test/tools/javac/linenumbers/FinallyLineNumberTest.java	Tue May 23 08:07:26 2017 -0700
     1.2 +++ b/test/tools/javac/linenumbers/FinallyLineNumberTest.java	Wed Jun 07 00:04:12 2017 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -36,7 +36,6 @@
    1.11  import com.sun.tools.classfile.LineNumberTable_attribute;
    1.12  import com.sun.tools.classfile.LineNumberTable_attribute.Entry;
    1.13  
    1.14 -import java.io.File;
    1.15  import java.io.IOException;
    1.16  
    1.17  public class FinallyLineNumberTest {
    1.18 @@ -46,13 +45,13 @@
    1.19          if (lines == null) {
    1.20              throw new Exception("finally line number table could not be loaded");
    1.21          }
    1.22 -        if (lines.length != 4) {
    1.23 +        if (lines.length != 5) {
    1.24              // Help debug
    1.25              System.err.println("LineTable error, got lines:");
    1.26              for (Entry e : lines) {
    1.27                  System.err.println(e.line_number);
    1.28              }
    1.29 -            throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=4");
    1.30 +            throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=5");
    1.31          }
    1.32  
    1.33          // return null line, for the load null operation
    1.34 @@ -71,11 +70,17 @@
    1.35              throw new Exception("finally line number table incorrect: got=" + current + " expected=" + first);
    1.36          }
    1.37  
    1.38 -        // finally line, for when exception is thrown
    1.39 +        // for when exception is thrown
    1.40          current = lines[3].line_number;
    1.41          if (current != first + 2) {
    1.42              throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 2));
    1.43          }
    1.44 +
    1.45 +        // the '}' closing the finally block
    1.46 +        current = lines[4].line_number;
    1.47 +        if (current != first + 3) {
    1.48 +            throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 3));
    1.49 +        }
    1.50      }
    1.51  
    1.52      static Entry[] findEntries() throws IOException, ConstantPoolException {

mercurial