test/tools/javac/TryWithResources/DuplicateResource.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 21,33 ****
* questions.
*/
/*
* @test
! * @bug 6911256 6964740 6965277
* @author Maurizio Cimadamore
! * @summary Check that lowered arm block does not end up creating resource twice
*/
import java.util.ArrayList;
public class DuplicateResource {
--- 21,33 ----
* questions.
*/
/*
* @test
! * @bug 6911256 6964740 6965277 7013420
* @author Maurizio Cimadamore
! * @summary Check that lowered try-with-resources block does not end up creating resource twice
*/
import java.util.ArrayList;
public class DuplicateResource {
*** 43,53 ****
}
static ArrayList<TestResource> resources = new ArrayList<TestResource>();
public static void main(String[] args) {
! try(new TestResource()) {
//do something
} catch (Exception e) {
throw new AssertionError("Shouldn't reach here", e);
}
check();
--- 43,53 ----
}
static ArrayList<TestResource> resources = new ArrayList<TestResource>();
public static void main(String[] args) {
! try(TestResource tr = new TestResource()) {
//do something
} catch (Exception e) {
throw new AssertionError("Shouldn't reach here", e);
}
check();
*** 57,65 ****
if (resources.size() != 1) {
throw new AssertionError("Expected one resource, found: " + resources.size());
}
TestResource resource = resources.get(0);
if (!resource.isClosed) {
! throw new AssertionError("Resource used in ARM block has not been automatically closed");
}
}
}
--- 57,65 ----
if (resources.size() != 1) {
throw new AssertionError("Expected one resource, found: " + resources.size());
}
TestResource resource = resources.get(0);
if (!resource.isClosed) {
! throw new AssertionError("Resource used in try-with-resources block has not been automatically closed");
}
}
}