This repository was archived by the owner on Sep 21, 2019. It is now read-only.
Description Attaching a sample Java program run via
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y com.example.Main
Attaching resumes the JVM immediately (should it?).
Setting breakpoints on the first two lines in main via
bp "com/example/Main.java" 58
bp "com/example/Main.java" 59
does not trigger an actual breakpoint.
package com .example ;
import java .util .List ;
import java .util .ArrayList ;
public class Main {
private static enum Gender {
MALE , FEMALE , OTHER
}
private static class Person {
public final String firstName ;
public final String lastName ;
public final int age ;
public final Gender gender ;
public Person (
final String firstName ,
final String lastName ,
final int age ,
final Gender gender
) {
this .firstName = firstName ;
this .lastName = lastName ;
this .age = age ;
this .gender = gender ;
}
@ Override
public String toString () {
final StringBuilder sb = new StringBuilder ();
sb .append ("==PERSON==" );
sb .append ("\n " );
sb .append ("Name: " );
sb .append (this .firstName );
sb .append (" " );
sb .append (this .lastName );
sb .append ("\n " );
sb .append ("Age: " );
sb .append (this .age );
sb .append ("\n " );
sb .append ("Gender: " );
sb .append (this .gender .toString ());
sb .append ("\n " );
sb .append ("==========" );
sb .append ("\n " );
return sb .toString ();
}
}
public static void main (String [] args ) {
System .out .println ("Building person records..." );
final List <Person > people = new ArrayList <Person >();
final Person p1 = new Person ("John" , "Doe" , 37 , Gender .MALE );
people .add (p1 );
System .out .println (p1 );
final Person p2 = new Person ("Jane" , "Roe" , 41 , Gender .FEMALE );
people .add (p2 );
System .out .println (p2 );
final Person p3 = new Person ("Ryon" , "Mere" , 11 , Gender .MALE );
people .add (p3 );
System .out .println (p3 );
System .out .println ("==SUMMARY==" );
int averageAge = 0 ;
int totalMales = 0 ;
int totalFemales = 0 ;
int totalOther = 0 ;
for (final Person p : people ) {
averageAge += p .age ;
switch (p .gender ) {
case MALE :
++totalMales ;
break ;
case FEMALE :
++totalFemales ;
break ;
case OTHER :
default :
++totalOther ;
break ;
}
}
averageAge /= people .size ();
System .out .println ("Average age: " + averageAge );
System .out .println ("Total males: " + totalMales );
System .out .println ("Total females: " + totalFemales );
System .out .println ("Total other: " + totalOther );
System .out .println ("===========" );
}
}Reactions are currently unavailable
Attaching a sample Java program run via
Attaching resumes the JVM immediately (should it?).
Setting breakpoints on the first two lines in
mainviadoes not trigger an actual breakpoint.