Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.foo;
- public class SomeClass {
- public static volatile SomeClass leak = null;
- public final String string;
- public SomeClass(final boolean tru3) {
- leak = this;
- if (tru3)// always true!
- throw new RuntimeException();
- // This is the only place where something is assigned to "string":
- this.string = "something";
- }
- @Override
- public String toString() {
- return this.string;
- }
- public static void main(final String[] args) throws Exception {
- Object object = "nothing";
- try {
- object = new SomeClass(true);
- } catch (final Exception e) {
- }
- System.out.printf("object = %s (%s)\n", object, object.getClass().getSimpleName());
- try {
- System.out.printf("leak = %s (%s)\n", leak, leak.getClass().getSimpleName());
- } catch (final Exception e) {
- System.out.println("" + e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement