Merge remote-tracking branch 'origin/master' into BETA_JAVA9
diff --git a/org.eclipse.jdt.debug.tests/testresources/JarRefProject/bin/a/RunJar.class b/org.eclipse.jdt.debug.tests/testresources/JarRefProject/bin/a/RunJar.class
deleted file mode 100644
index 14e9fd0..0000000
--- a/org.eclipse.jdt.debug.tests/testresources/JarRefProject/bin/a/RunJar.class
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.debug.tests/testresources/JarRefProject/bin/testJar/RunJar.class b/org.eclipse.jdt.debug.tests/testresources/JarRefProject/bin/testJar/RunJar.class
new file mode 100644
index 0000000..ef8c755
--- /dev/null
+++ b/org.eclipse.jdt.debug.tests/testresources/JarRefProject/bin/testJar/RunJar.class
Binary files differ
diff --git a/org.eclipse.jdt.debug.tests/testresources/JarRefProject/src/a/RunJar.java b/org.eclipse.jdt.debug.tests/testresources/JarRefProject/src/testJar/RunJar.java
similarity index 94%
rename from org.eclipse.jdt.debug.tests/testresources/JarRefProject/src/a/RunJar.java
rename to org.eclipse.jdt.debug.tests/testresources/JarRefProject/src/testJar/RunJar.java
index 7bc4d02..9a00464 100644
--- a/org.eclipse.jdt.debug.tests/testresources/JarRefProject/src/a/RunJar.java
+++ b/org.eclipse.jdt.debug.tests/testresources/JarRefProject/src/testJar/RunJar.java
@@ -8,7 +8,9 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
-package a;
+package testJar;
+
+import a.JarClass;
 
 public class RunJar {
 	public static void main(String[] args) {
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/TestsBreakpointConditions.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/TestsBreakpointConditions.java
index 76efae8..55cb146 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/TestsBreakpointConditions.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/TestsBreakpointConditions.java
@@ -1,5 +1,5 @@
 /*******************************************************************************

- * Copyright (c) 2015, 2016 IBM Corporation and others.

+ * Copyright (c) 2015, 2017 IBM Corporation and others.

  * All rights reserved. This program and the accompanying materials

  * are made available under the terms of the Eclipse Public License v1.0

  * which accompanies this distribution, and is available at

@@ -20,7 +20,7 @@
 	}

 

 	public void init() throws Exception {

-		initializeFrame("EvalArrayTests", 37, 1, 1);

+		initializeFrame("EvalSimpleTests", 37, 1, 1);

 	}

 

 	protected void end() throws Exception {

@@ -79,4 +79,131 @@
 		}

 

 	}

+

+	/*

+	 * To test xVarInt < (xVarInt + 100)

+	 */

+	public void testCondition5() throws Throwable {

+		try {

+			init();

+			IValue value = eval("xVarInt < (xVarInt + 100)");

+			System.out.println(value);

+

+		}

+		finally {

+			end();

+		}

+

+	}

+	/*

+	 * To test xVarInt < 100

+	 */

+	public void testCondition6() throws Throwable {

+		try {

+			init();

+			IValue value = eval("xVarInt < 100");

+			System.out.println(value);

+

+		}

+		finally {

+			end();

+		}

+

+	}

+

+	/*

+	 * To test xVarInt > 100

+	 */

+	public void testCondition7() throws Throwable {

+		try {

+			init();

+			IValue value = eval("xVarInt > -7");

+			System.out.println(value);

+

+		}

+		finally {

+			end();

+		}

+

+	}

+

+	/*

+	 * To test xVarInt == 100

+	 */

+	public void testCondition8() throws Throwable {

+		try {

+			init();

+			IValue value = eval("xVarInt == -7");

+			System.out.println(value);

+

+		}

+		finally {

+			end();

+		}

+

+	}

+

+	/*

+	 * To test return xVarInt < 100

+	 */

+	public void testCondition9() throws Throwable {

+		try {

+			init();

+			IValue value = eval("return xVarInt < 100");

+			System.out.println(value);

+

+		}

+		finally {

+			end();

+		}

+

+	}

+

+	/*

+	 * To test return xVarInt > 100

+	 */

+	public void testCondition10() throws Throwable {

+		try {

+			init();

+			IValue value = eval("return xVarInt > -7");

+			System.out.println(value);

+

+		}

+		finally {

+			end();

+		}

+

+	}

+

+	/*

+	 * To test if as last statement

+	 */

+	public void testCondition11() throws Throwable {

+		try {

+			init();

+			IValue value = eval("if (xVarInt > 3) { System.out.println(\"test if\");} ");

+			System.out.println(value);

+

+		}

+		finally {

+			end();

+		}

+

+	}

+

+	/*

+	 * To test while as last statement

+	 */

+	public void testCondition12() throws Throwable {

+		try {

+			init();

+			IValue value = eval("while (xVarInt < 3) { System.out.println(\"test while\");xVarInt++; } ");

+			System.out.println(value);

+

+		}

+		finally {

+			end();

+		}

+

+	}

 }

diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/sourcelookup/JarSourceLookupTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/sourcelookup/JarSourceLookupTests.java
index 30884a4..741849d 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/sourcelookup/JarSourceLookupTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/sourcelookup/JarSourceLookupTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2016 IBM Corporation and others.
+ * Copyright (c) 2011, 2017 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -36,7 +36,7 @@
  */
 public class JarSourceLookupTests extends AbstractDebugTest {
 
-	public static final String A_RUN_JAR = "a.RunJar";
+	public static final String A_RUN_JAR = "testJar.RunJar";
 	static IJavaProject fgJarProject = null;
 	
 	String RefPjName = "JarRefProject";
@@ -167,7 +167,7 @@
 			 assertNotNull("The top stack frame cannot be null", frame);
 			 assertTrue("The found frame should be an IJavaStackFrame", frame instanceof IJavaStackFrame);
 			 Object source = lookupSource(frame);
-			 assertNotNull("We should have found source for the main class a.RunJar", source);
+			assertNotNull("We should have found source for the main class testJar.RunJar", source);
 			 assertTrue("The found source should be an IFile", source instanceof IFile);
 			 assertEquals("We should have found a file named RunJar.java", ((IFile)source).getName(), "RunJar.java");
 			 
diff --git a/org.eclipse.jdt.debug.ui/icons/full/obj16/brkpd_obj.png b/org.eclipse.jdt.debug.ui/icons/full/obj16/brkpd_obj.png
new file mode 100644
index 0000000..31f9a9a
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/icons/full/obj16/brkpd_obj.png
Binary files differ
diff --git a/org.eclipse.jdt.debug.ui/icons/full/obj16/brkpd_obj@2x.png b/org.eclipse.jdt.debug.ui/icons/full/obj16/brkpd_obj@2x.png
new file mode 100644
index 0000000..015b028
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/icons/full/obj16/brkpd_obj@2x.png
Binary files differ
diff --git a/org.eclipse.jdt.debug.ui/plugin.properties b/org.eclipse.jdt.debug.ui/plugin.properties
index dada1dc..1bd6f51 100644
--- a/org.eclipse.jdt.debug.ui/plugin.properties
+++ b/org.eclipse.jdt.debug.ui/plugin.properties
@@ -221,6 +221,8 @@
 ActionDefinition.breakpointproperties.description=View and edit the properties for a given Java breakpoint
 CommandDefinition.breakpointproperties.name=Java Breakpoint Properties
 
+ToggleTracepointAction.label=Toggle Trac&epoint
+
 AddBookmark.label=Add Boo&kmark...
 AddBookmark.tooltip=Add Bookmark...
 AddTask.label=Add &Task...
diff --git a/org.eclipse.jdt.debug.ui/plugin.xml b/org.eclipse.jdt.debug.ui/plugin.xml
index ad34e67..83ab593 100644
--- a/org.eclipse.jdt.debug.ui/plugin.xml
+++ b/org.eclipse.jdt.debug.ui/plugin.xml
@@ -135,12 +135,22 @@
             </separator>
          </menu>
          <action
+               definitionId="org.eclipse.jdt.debug.ui.commands.ToggleTracepoint"
+               label="%ToggleTracepointAction.label"
+               icon="$nl$/icons/full/obj16/brkp_obj.png"
+               disabledIcon="$nl$/icons/full/obj16/brkpd_obj.png"
+               helpContextId="toggle_tracepoint_action_context"
+               class="org.eclipse.jdt.internal.debug.ui.actions.RetargetToggleTracepointAction"
+               menubarPath="org.eclipse.ui.run/lineBreakpointBeforeGroup"
+               id="org.eclipse.jdt.debug.ui.actions.ToggleTracepoint">
+         </action>
+         <action
 	           definitionId="org.eclipse.jdt.debug.ui.commands.AddClassPrepareBreakpoint"
                label="%classPrepareAction.label"
                icon="$nl$/icons/full/obj16/class_obj.png"
                helpContextId="add_class_prepare_action_context"
                class="org.eclipse.jdt.internal.debug.ui.breakpoints.AddClassPrepareBreakpointAction"
-               menubarPath="org.eclipse.ui.run/breakpointGroup"
+               menubarPath="org.eclipse.ui.run/lineBreakpointGroup"
                id="org.eclipse.jdt.debug.ui.actions.AddClassPrepareBreakpoint">
          </action>
          <action
@@ -149,7 +159,7 @@
                icon="$nl$/icons/full/elcl16/exc_catch.png"
                helpContextId="add_exception_action_context"
                class="org.eclipse.jdt.internal.debug.ui.breakpoints.AddExceptionAction"
-               menubarPath="org.eclipse.ui.run/breakpointGroup"
+               menubarPath="org.eclipse.ui.run/lineBreakpointGroup"
                id="org.eclipse.jdt.debug.ui.actions.AddExceptionBreakpoint">
          </action>
          <action
@@ -2595,6 +2605,12 @@
 M4 = Platform-specific fourth key
 -->
    <extension point="org.eclipse.ui.commands">
+   	 <command
+            name="%ToggleTracepointAction.label"
+            description="%ToggleTracepointAction.label"
+            categoryId="org.eclipse.debug.ui.category.run"
+            id="org.eclipse.jdt.debug.ui.commands.ToggleTracepoint">
+      </command>
       <command
             name="%ActionDefinition.addException.name"
             description="%ActionDefinition.addException.description"
@@ -3681,4 +3697,7 @@
        </enabledWhen>
     </handler>
  </extension>
+  
+   
+ 
 </plugin>
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.java
index bb570c1..7b0903c 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -32,6 +32,7 @@
 	public static String BreakpointSuspendPolicy_Suspend__Thread_2;
 	public static String BreakpointSuspendPolicy_Suspend__VM_1;
 
+
 	public static String DisplayAction_no_result_value;
 	public static String DisplayAction_result_pattern;
 	public static String DisplayAction_type_name_pattern;
@@ -156,6 +157,8 @@
 	public static String StringValueInputDialog_2;
 	public static String StringValueInputDialog_4;
 
+	public static String TracepointToggleAction_Unavailable;
+
 	static {
 		// load message values from bundle file
 		NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.properties b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.properties
index 7e7f03d..12a54f7 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.properties
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2000, 2014 IBM Corporation and others.
+# Copyright (c) 2000, 2017 IBM Corporation and others.
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
 # which accompanies this distribution, and is available at
@@ -139,3 +139,4 @@
 OpenTypeAction_2=Unable to display the selected type.
 EditClasspathEntryAction_0=Ed&it...
 ProjectSelectionDialog_0=Choose &project(s) to add:
+TracepointToggleAction_Unavailable=The operation is unavailable on the current selection.
\ No newline at end of file
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointLocationVerifierJob.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointLocationVerifierJob.java
index 81f4904..95c61e5 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointLocationVerifierJob.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointLocationVerifierJob.java
@@ -226,7 +226,13 @@
 			}
 			BreakpointUtils.addJavaBreakpointAttributes(newAttributes, fType);
 		}
-		JDIDebugModel.createLineBreakpoint(fBreakpoint.getMarker().getResource(), typeName, lineNumber, start, end, 0, true, newAttributes);
+		IJavaLineBreakpoint newBreakpoint = JDIDebugModel.createLineBreakpoint(fBreakpoint.getMarker().getResource(), typeName, lineNumber, start, end, 0, true, newAttributes);
+		String condition = fBreakpoint.getCondition();
+		if (condition != null && condition.length() != 0) {
+			newBreakpoint.setCondition(fBreakpoint.getCondition());
+			newBreakpoint.setConditionEnabled(fBreakpoint.isConditionEnabled());
+			newBreakpoint.setConditionSuspendOnTrue(fBreakpoint.isConditionSuspendOnTrue());
+		}
 	}
 
 	/**
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointToggleUtils.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointToggleUtils.java
new file mode 100644
index 0000000..742a797
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointToggleUtils.java
@@ -0,0 +1,352 @@
+/*******************************************************************************
+ * Copyright (c) 2016 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.debug.ui.actions;
+
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IPackageDeclaration;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.internal.corext.template.java.CompilationUnitContext;
+import org.eclipse.jdt.internal.corext.template.java.CompilationUnitContextType;
+import org.eclipse.jdt.internal.corext.template.java.JavaContextType;
+import org.eclipse.jdt.internal.debug.ui.DebugWorkingCopyManager;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
+import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateEngine;
+import org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateProposal;
+import org.eclipse.jdt.ui.IWorkingCopyManager;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.SharedASTProvider;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.IEditorStatusLine;
+import org.eclipse.ui.texteditor.ITextEditor;
+ 
+/**
+ * Utility class for Java Toggle breakpoints
+ */
+public class BreakpointToggleUtils {
+	
+	private static boolean isTracepoint = false;
+
+	public static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+	public static void setUnsetTracepoints(boolean tracePoint) {
+		isTracepoint = tracePoint;
+	}
+
+	public static boolean isToggleTracepoints() {
+		return isTracepoint;
+	}
+
+	/**
+	 * Returns the package qualified name, while accounting for the fact that a source file might not have a project
+	 * 
+	 * @param type
+	 *            the type to ensure the package qualified name is created for
+	 * @return the package qualified name
+	 * @since 3.3
+	 */
+	static String createQualifiedTypeName(IType type) {
+		String tname = pruneAnonymous(type);
+		try {
+			String packName = null;
+			if (type.isBinary()) {
+				packName = type.getPackageFragment().getElementName();
+			} else {
+				IPackageDeclaration[] pd = type.getCompilationUnit().getPackageDeclarations();
+				if (pd.length > 0) {
+					packName = pd[0].getElementName();
+				}
+			}
+			if (packName != null && !packName.equals(EMPTY_STRING)) {
+				tname = packName + "." + tname; //$NON-NLS-1$
+			}
+		}
+		catch (JavaModelException e) {
+		}
+		return tname;
+	}
+
+	/**
+	 * Prunes out all naming occurrences of anonymous inner types, since these types have no names and cannot be derived visiting an AST (no positive
+	 * type name matching while visiting ASTs)
+	 * 
+	 * @param type
+	 * @return the compiled type name from the given {@link IType} with all occurrences of anonymous inner types removed
+	 * @since 3.4
+	 */
+	private static String pruneAnonymous(IType type) {
+		StringBuffer buffer = new StringBuffer();
+		IJavaElement parent = type;
+		while (parent != null) {
+			if (parent.getElementType() == IJavaElement.TYPE) {
+				IType atype = (IType) parent;
+				try {
+					if (!atype.isAnonymous()) {
+						if (buffer.length() > 0) {
+							buffer.insert(0, '$');
+						}
+						buffer.insert(0, atype.getElementName());
+					}
+				}
+				catch (JavaModelException jme) {
+				}
+			}
+			parent = parent.getParent();
+		}
+		return buffer.toString();
+	}
+
+	/**
+	 * Convenience method for printing messages to the status line
+	 * 
+	 * @param message
+	 *            the message to be displayed
+	 * @param part
+	 *            the currently active workbench part
+	 */
+	public static void report(final String message, final IWorkbenchPart part) {
+		JDIDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
+			@Override
+			public void run() {
+				IEditorStatusLine statusLine = part.getAdapter(IEditorStatusLine.class);
+				if (statusLine != null) {
+					if (message != null) {
+						statusLine.setMessage(true, message, null);
+					} else {
+						statusLine.setMessage(true, null, null);
+					}
+				}
+			}
+		});
+	}
+
+	/**
+	 * Returns the text editor associated with the given part or <code>null</code> if none. In case of a multi-page editor, this method should be used
+	 * to retrieve the correct editor to perform the breakpoint operation on.
+	 * 
+	 * @param part
+	 *            workbench part
+	 * @return text editor part or <code>null</code>
+	 */
+	protected static ITextEditor getTextEditor(IWorkbenchPart part) {
+		if (part instanceof ITextEditor) {
+			return (ITextEditor) part;
+		}
+		return part.getAdapter(ITextEditor.class);
+	}
+
+
+	/**
+	 * Returns the compilation unit from the editor
+	 * 
+	 * @param editor
+	 *            the editor to get the compilation unit from
+	 * @return the compilation unit or <code>null</code>
+	 */
+	public static CompilationUnit parseCompilationUnit(ITextEditor editor) {
+		return parseCompilationUnit(getTypeRoot(editor.getEditorInput()));
+	}
+
+	/**
+	 * Parses the {@link ITypeRoot}.
+	 * 
+	 * @param root
+	 *            the root
+	 * @return the parsed {@link CompilationUnit}
+	 */
+	static CompilationUnit parseCompilationUnit(ITypeRoot root) {
+		if (root != null) {
+			return SharedASTProvider.getAST(root, SharedASTProvider.WAIT_YES, null);
+		}
+		return null;
+	}
+
+	/**
+	 * Returns a selection of the member in the given text selection, or the original selection if none.
+	 * 
+	 * @param part
+	 * @param selection
+	 * @return a structured selection of the member in the given text selection, or the original selection if none
+	 * @exception CoreException
+	 *                if an exception occurs
+	 */
+	protected static ISelection translateToMembers(IWorkbenchPart part, ISelection selection) throws CoreException {
+		ITextEditor textEditor = getTextEditor(part);
+		if (textEditor != null && selection instanceof ITextSelection) {
+			ITextSelection textSelection = (ITextSelection) selection;
+			IEditorInput editorInput = textEditor.getEditorInput();
+			IDocumentProvider documentProvider = textEditor.getDocumentProvider();
+			if (documentProvider == null) {
+				throw new CoreException(Status.CANCEL_STATUS);
+			}
+			IDocument document = documentProvider.getDocument(editorInput);
+			int offset = textSelection.getOffset();
+			if (document != null) {
+				try {
+					IRegion region = document.getLineInformationOfOffset(offset);
+					int end = region.getOffset() + region.getLength();
+					while (Character.isWhitespace(document.getChar(offset)) && offset < end) {
+						offset++;
+					}
+				}
+				catch (BadLocationException ex) {
+				}
+			}
+			IMember m = null;
+			ITypeRoot root = getTypeRoot(editorInput);
+			if (root instanceof ICompilationUnit) {
+				ICompilationUnit unit = (ICompilationUnit) root;
+				synchronized (unit) {
+					unit.reconcile(ICompilationUnit.NO_AST, false, null, null);
+				}
+			}
+			if (root != null) {
+				IJavaElement e = root.getElementAt(offset);
+				if (e instanceof IMember) {
+					m = (IMember) e;
+				}
+			}
+			if (m != null) {
+				return new StructuredSelection(m);
+			}
+		}
+		return selection;
+	}
+
+	/**
+	 * Returns the {@link ITypeRoot} for the given {@link IEditorInput}
+	 * 
+	 * @param input
+	 * @return the type root or <code>null</code> if one cannot be derived
+	 * @since 3.4
+	 */
+	private static ITypeRoot getTypeRoot(IEditorInput input) {
+		ITypeRoot root = input.getAdapter(IClassFile.class);
+		if (root == null) {
+			IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
+			root = manager.getWorkingCopy(input);
+		}
+		if (root == null) {
+			root = DebugWorkingCopyManager.getWorkingCopy(input, false);
+		}
+		return root;
+	}
+
+	/**
+	 * Returns the {@link ITypeRoot} for the given {@link IEditorInput}
+	 * 
+	 * @param input
+	 * @return the type root or <code>null</code> if one cannot be derived
+	 * @since 3.8
+	 */
+	public static String getCodeTemplate(ITextSelection textSelection, CompilationUnitEditor part) {
+		TemplateContextType contextType = JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(JavaContextType.ID_STATEMENTS);
+		TemplateEngine fStatementEngine = new TemplateEngine(contextType);
+		fStatementEngine.reset();
+		ITextViewer viewer = part.getViewer();
+		final String[] fTemplateBuffer = new String[1];
+		fTemplateBuffer[0] = null;
+		if (viewer != null) {
+			Display.getDefault().syncExec(new Runnable() {
+			    @Override
+				public void run() {
+					ITextEditor editor = BreakpointToggleUtils.getTextEditor(part);
+					if (editor != null) {
+						IJavaElement element = getJavaElement(editor.getEditorInput());
+						ICompilationUnit cunit = null;
+						IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+						IFile file = root.getFile(element.getPath());
+						cunit = JavaCore.createCompilationUnitFrom(file);
+						IDocumentProvider documentProvider = editor.getDocumentProvider();
+						if (documentProvider == null) {
+							return;
+						}
+						IDocument document = documentProvider.getDocument(editor.getEditorInput());
+						try {
+							IRegion line = document.getLineInformation(textSelection.getStartLine() + 1);
+							Point selectedRange = viewer.getSelectedRange();
+							viewer.setSelectedRange(selectedRange.x, 0);
+							fStatementEngine.complete(viewer, line.getOffset(), cunit);
+							viewer.setSelectedRange(selectedRange.x, selectedRange.y);
+							TemplateProposal[] templateProposals = fStatementEngine.getResults();
+							for (TemplateProposal templateProposal : templateProposals) {
+								Template template = templateProposal.getTemplate();
+								if (template.getName().equals("systrace")) { //$NON-NLS-1$
+									CompilationUnitContextType contextType = (CompilationUnitContextType) JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(template.getContextTypeId());
+									CompilationUnitContext context = contextType.createContext(document, line.getOffset(), 0, cunit);
+									context.setVariable("selection", EMPTY_STRING); //$NON-NLS-1$
+									context.setForceEvaluation(true);
+									fTemplateBuffer[0] = context.evaluate(template).getString();
+									return;
+								}
+							}
+						}
+						catch (BadLocationException e) {
+							e.printStackTrace();
+						}
+						catch (TemplateException e1) {
+							e1.printStackTrace();
+						}
+
+					}
+				}
+			});
+		}
+		return fTemplateBuffer[0];
+	}
+
+	/**
+	 * gets the <code>IJavaElement</code> from the editor input
+	 * 
+	 * @param input
+	 *            the current editor input
+	 * @return the corresponding <code>IJavaElement</code>
+	 * @since 3.3
+	 */
+	public static IJavaElement getJavaElement(IEditorInput input) {
+		IJavaElement je = JavaUI.getEditorInputJavaElement(input);
+		if (je != null) {
+			return je;
+		}
+		// try to get from the working copy manager
+		return DebugWorkingCopyManager.getWorkingCopy(input, false);
+	}
+
+}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/RetargetToggleTracepointAction.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/RetargetToggleTracepointAction.java
new file mode 100644
index 0000000..4ea7880
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/RetargetToggleTracepointAction.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2016, 2017 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.debug.ui.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.internal.ui.actions.breakpoints.RetargetToggleBreakpointAction;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.internal.debug.core.breakpoints.ValidBreakpointLocationLocator;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Global retargettable toggle tracepoint action.
+ * 
+ * @since 3.12
+ * 
+ */
+public class RetargetToggleTracepointAction extends RetargetToggleBreakpointAction {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.debug.internal.ui.actions.RetargetTracepointAction# performAction(java.lang.Object, org.eclipse.jface.viewers.ISelection,
+	 * org.eclipse.ui.IWorkbenchPart)
+	 */
+	@Override
+	protected void performAction(Object target, ISelection selection, IWorkbenchPart part) throws CoreException {
+		BreakpointToggleUtils.setUnsetTracepoints(true);
+		super.performAction(target, selection, part);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.debug.internal.ui.actions.RetargetBreakpointAction#canPerformAction(java.lang.Object, org.eclipse.jface.viewers.ISelection,
+	 * org.eclipse.ui.IWorkbenchPart)
+	 */
+	@Override
+	protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) {
+		try {
+			ISelection sel = BreakpointToggleUtils.translateToMembers(part, selection);
+			if (sel instanceof IStructuredSelection) {
+				Object firstElement = ((IStructuredSelection) sel).getFirstElement();
+				if (firstElement instanceof IMember) {
+					IMember member = (IMember) firstElement;
+					int mtype = member.getElementType();
+					if (mtype == IJavaElement.FIELD || mtype == IJavaElement.METHOD || mtype == IJavaElement.INITIALIZER) {
+						// remove line breakpoint if present first
+						if (selection instanceof ITextSelection) {
+							ITextSelection ts = (ITextSelection) selection;
+
+							CompilationUnit unit = BreakpointToggleUtils.parseCompilationUnit(BreakpointToggleUtils.getTextEditor(part));
+							ValidBreakpointLocationLocator loc = new ValidBreakpointLocationLocator(unit, ts.getStartLine() + 1, true, true);
+							unit.accept(loc);
+							if (loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_METHOD) {
+								return true;
+							} else if (loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_FIELD) {
+								return false;
+							} else if (loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_LINE) {
+								return true;
+							}
+						}
+					}
+
+					if (member.getElementType() == IJavaElement.TYPE) {
+						return false;
+					}
+				}
+			}
+			return super.canPerformAction(target, selection, part);
+		}
+		catch (CoreException e) {
+			return false;
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.debug.internal.ui.actions.RetargetAction#getOperationUnavailableMessage()
+	 */
+	@Override
+	protected String getOperationUnavailableMessage() {
+		return ActionMessages.TracepointToggleAction_Unavailable;
+	}
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java
index 003ac07..f5e1e9c 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -42,11 +42,9 @@
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.IMember;
 import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageDeclaration;
 import org.eclipse.jdt.core.ISourceRange;
 import org.eclipse.jdt.core.IType;
 import org.eclipse.jdt.core.ITypeParameter;
-import org.eclipse.jdt.core.ITypeRoot;
 import org.eclipse.jdt.core.JavaModelException;
 import org.eclipse.jdt.core.Signature;
 import org.eclipse.jdt.core.SourceRange;
@@ -69,12 +67,9 @@
 import org.eclipse.jdt.internal.debug.core.JavaDebugUtils;
 import org.eclipse.jdt.internal.debug.core.breakpoints.ValidBreakpointLocationLocator;
 import org.eclipse.jdt.internal.debug.ui.BreakpointUtils;
-import org.eclipse.jdt.internal.debug.ui.DebugWorkingCopyManager;
 import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
-import org.eclipse.jdt.ui.IWorkingCopyManager;
-import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jdt.ui.SharedASTProvider;
+import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
 import org.eclipse.jface.text.BadLocationException;
@@ -84,7 +79,6 @@
 import org.eclipse.jface.text.source.IVerticalRulerInfo;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
@@ -95,7 +89,6 @@
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.dialogs.PreferencesUtil;
 import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.IEditorStatusLine;
 import org.eclipse.ui.texteditor.ITextEditor;
 
 /**
@@ -105,7 +98,6 @@
  */
 public class ToggleBreakpointAdapter implements IToggleBreakpointsTargetExtension2 {
 	
-	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
 
 
 	/**
@@ -117,27 +109,6 @@
 	}
 
     /**
-     * Convenience method for printing messages to the status line
-     * @param message the message to be displayed
-     * @param part the currently active workbench part
-     */
-    protected void report(final String message, final IWorkbenchPart part) {
-        JDIDebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
-            @Override
-			public void run() {
-                IEditorStatusLine statusLine = part.getAdapter(IEditorStatusLine.class);
-                if (statusLine != null) {
-                    if (message != null) {
-                        statusLine.setMessage(true, message, null);
-                    } else {
-                        statusLine.setMessage(true, null, null);
-                    }
-                }
-            }
-        });
-    }
-
-    /**
      * Returns the <code>IType</code> for the given selection
      * @param selection the current text selection
      * @return the <code>IType</code> for the text selection or <code>null</code>
@@ -211,7 +182,7 @@
         job.setSystem(true);
         job.schedule();
     }
-    
+
     /*
      * (non-Javadoc)
      * 
@@ -241,19 +212,19 @@
                     return Status.CANCEL_STATUS;
                 }
                 try {
-                    report(null, part);
+					BreakpointToggleUtils.report(null, part);
                     ISelection selection = finalSelection;
                     if(!(selection instanceof IStructuredSelection)) {
-                    	selection = translateToMembers(part, selection);
+						selection = BreakpointToggleUtils.translateToMembers(part, selection);
                     }
                     boolean isInterface = isInterface(selection, part);
                     if (selection instanceof IStructuredSelection) {
                     	IMethod[] members = getMethods((IStructuredSelection) selection, isInterface);
                         if (members.length == 0) {
                         	if(isInterface) {
-								report(ActionMessages.ToggleBreakpointAdapter_6, part);
+								BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_6, part);
 							} else {
-								report(ActionMessages.ToggleBreakpointAdapter_9, part);
+								BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_9, part);
 							} 
                             return Status.OK_STATUS;
                         }
@@ -287,23 +258,43 @@
                                 if (!type.isBinary()) {
                                 	signature = resolveMethodSignature(members[i]);
                                     if (signature == null) {
-                                    	report(ActionMessages.ManageMethodBreakpointActionDelegate_methodNonAvailable, part); 
+										BreakpointToggleUtils.report(ActionMessages.ManageMethodBreakpointActionDelegate_methodNonAvailable, part);
                                         return Status.OK_STATUS;
                                     }
                                 }
-                                JDIDebugModel.createMethodBreakpoint(BreakpointUtils.getBreakpointResource(members[i]), getQualifiedName(type), mname, signature, true, false, false, -1, start, end, 0, true, attributes);
+								IJavaMethodBreakpoint methodBreakpoint = JDIDebugModel.createMethodBreakpoint(BreakpointUtils.getBreakpointResource(members[i]), getQualifiedName(type), mname, signature, true, false, false, -1, start, end, 0, true, attributes);
+								if (BreakpointToggleUtils.isToggleTracepoints() && finalSelection instanceof ITextSelection
+										&& part instanceof CompilationUnitEditor) {
+									String pattern = BreakpointToggleUtils.getCodeTemplate((ITextSelection) finalSelection, (CompilationUnitEditor) part);
+									if (pattern != null) {
+										pattern.trim();
+										pattern = pattern.replaceAll("\\\t", ""); //$NON-NLS-1$//$NON-NLS-2$
+										methodBreakpoint.setCondition(pattern);
+										methodBreakpoint.setConditionEnabled(true);
+										methodBreakpoint.setConditionSuspendOnTrue(true);
+									}
+									BreakpointToggleUtils.setUnsetTracepoints(false);
+								}
                             } else {
-								deleteBreakpoint(breakpoint, part, monitor);
+								if (BreakpointToggleUtils.isToggleTracepoints()) {
+									deleteTracepoint(breakpoint, part, monitor);
+									BreakpointToggleUtils.setUnsetTracepoints(false);
+								} else {
+									deleteBreakpoint(breakpoint, part, monitor);
+								}
                             }
                         }
                     }
                     else {
-                    	report(ActionMessages.ToggleBreakpointAdapter_4, part);
+						BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_4, part);
                     	return Status.OK_STATUS;
                     }
                 } catch (CoreException e) {
                     return e.getStatus();
                 }
+				finally {
+					BreakpointToggleUtils.setUnsetTracepoints(false);
+				}
                 return Status.OK_STATUS;
             }
         };
@@ -322,21 +313,21 @@
      * @return the status of the toggle
      * @since 3.8
      */
-    IStatus doLineBreakpointToggle(ISelection selection, IWorkbenchPart part, ValidBreakpointLocationLocator locator, boolean bestMatch, IProgressMonitor monitor) {
-    	ITextEditor editor = getTextEditor(part);
+	IStatus doLineBreakpointToggle(ISelection selection, IWorkbenchPart part, ValidBreakpointLocationLocator locator, boolean bestMatch, IProgressMonitor monitor) {
+		ITextEditor editor = BreakpointToggleUtils.getTextEditor(part);
         if (editor != null && selection instanceof ITextSelection) {
             if (monitor.isCanceled()) {
-                return Status.CANCEL_STATUS;
+				return Status.CANCEL_STATUS;
             }
             ITextSelection tsel = (ITextSelection) selection;
             if(tsel.getStartLine() < 0) {
-            	return Status.CANCEL_STATUS;
+				return Status.CANCEL_STATUS;
             }
             try {
-                report(null, part);
+				BreakpointToggleUtils.report(null, part);
                 ISelection sel = selection;
             	if(!(selection instanceof IStructuredSelection)) {
-            		sel = translateToMembers(part, selection);
+					sel = BreakpointToggleUtils.translateToMembers(part, selection);
             	}
             	if(sel instanceof IStructuredSelection) {
                 	IMember member = (IMember) ((IStructuredSelection)sel).getFirstElement();
@@ -347,10 +338,15 @@
                 	else {
                 		type = member.getDeclaringType();
                 	}
+					if (locator == null && BreakpointToggleUtils.isToggleTracepoints()) {
+						CompilationUnit cUnit = BreakpointToggleUtils.parseCompilationUnit(type.getTypeRoot());
+						locator = new ValidBreakpointLocationLocator(cUnit, tsel.getStartLine() + 1, true, bestMatch);
+						cUnit.accept(locator);
+					}
                 	String tname = null;
                 	IJavaProject project = type.getJavaProject();
                 	if (locator == null || (project != null && !project.isOnClasspath(type))) {
-                		tname = createQualifiedTypeName(type);
+						tname = BreakpointToggleUtils.createQualifiedTypeName(type);
                 	} else {
                 		tname = locator.getFullyQualifiedTypeName();
                 	}
@@ -361,7 +357,12 @@
 					int lnumber = locator == null ? tsel.getStartLine() + 1 : locator.getLineLocation();
 					IJavaLineBreakpoint existingBreakpoint = JDIDebugModel.lineBreakpointExists(resource, tname, lnumber);
 					if (existingBreakpoint != null) {
-						deleteBreakpoint(existingBreakpoint, editor, monitor);
+						if (BreakpointToggleUtils.isToggleTracepoints()) {
+							deleteTracepoint(existingBreakpoint, editor, monitor);
+							BreakpointToggleUtils.setUnsetTracepoints(false);
+						} else {
+							deleteBreakpoint(existingBreakpoint, editor, monitor);
+						}
 						return Status.OK_STATUS;
 					}
 					Map<String, Object> attributes = new HashMap<String, Object>(10);
@@ -379,16 +380,34 @@
 					catch (BadLocationException ble) {JDIDebugUIPlugin.log(ble);}
 					BreakpointUtils.addJavaBreakpointAttributes(attributes, type);
 					IJavaLineBreakpoint breakpoint = JDIDebugModel.createLineBreakpoint(resource, tname, lnumber, charstart, charend, 0, true, attributes);
-					if(locator == null) {
-						new BreakpointLocationVerifierJob(document, parseCompilationUnit(type.getTypeRoot()), breakpoint, lnumber, tname, type, editor, bestMatch).schedule();
+					if (BreakpointToggleUtils.isToggleTracepoints() && selection instanceof ITextSelection && part instanceof CompilationUnitEditor) {
+						String pattern = BreakpointToggleUtils.getCodeTemplate((ITextSelection) selection, (CompilationUnitEditor) part);
+						if (pattern != null) {
+							pattern.trim();
+							pattern = pattern.replaceAll("\\\t", ""); //$NON-NLS-1$//$NON-NLS-2$
+							breakpoint.setCondition(pattern);
+							breakpoint.setConditionEnabled(true);
+							breakpoint.setConditionSuspendOnTrue(true);
+						}
+
+						BreakpointToggleUtils.setUnsetTracepoints(false);
+					}
+					if (locator == null) {
+						new BreakpointLocationVerifierJob(document, BreakpointToggleUtils.parseCompilationUnit(type.getTypeRoot()), breakpoint, lnumber, tname, type, editor, bestMatch).schedule();
+					}
+					if (BreakpointToggleUtils.isToggleTracepoints()) {
+						BreakpointToggleUtils.setUnsetTracepoints(false);
 					}
                 }
                 else {
-                	report(ActionMessages.ToggleBreakpointAdapter_3, part);
+					BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_3, part);
                 	return Status.OK_STATUS;
                 }
             } 
             catch (CoreException ce) {return ce.getStatus();}
+			finally {
+				BreakpointToggleUtils.setUnsetTracepoints(false);
+			}
         }
         return Status.OK_STATUS;
     }
@@ -407,13 +426,13 @@
                     return Status.CANCEL_STATUS;
                 }
                 try {
-                	report(null, part);
+					BreakpointToggleUtils.report(null, part);
                 	ISelection sel = selection;
                 	if(!(selection instanceof IStructuredSelection)) {
-                		sel = translateToMembers(part, selection);
+						sel = BreakpointToggleUtils.translateToMembers(part, selection);
                 	}
                 	if(isInterface(sel, part)) {
-                    	report(ActionMessages.ToggleBreakpointAdapter_1, part);
+						BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_1, part);
                     	return Status.OK_STATUS;
                     }
 					if(sel instanceof IStructuredSelection) {
@@ -436,7 +455,7 @@
 						JDIDebugModel.createClassPrepareBreakpoint(BreakpointUtils.getBreakpointResource(member), getQualifiedName(type), IJavaClassPrepareBreakpoint.TYPE_CLASS, start, end, true, map);
 					}
 					else {
-						report(ActionMessages.ToggleBreakpointAdapter_0, part);
+						BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_0, part);
 						return Status.OK_STATUS;
 					}
 				} 
@@ -481,7 +500,7 @@
     String getQualifiedName(IType type) throws JavaModelException {
     	IJavaProject project = type.getJavaProject();
     	if (project != null && project.isOnClasspath(type) && needsBindings(type)) {
-    		CompilationUnit cuNode = parseCompilationUnit(type.getTypeRoot());
+			CompilationUnit cuNode = BreakpointToggleUtils.parseCompilationUnit(type.getTypeRoot());
     		ISourceRange nameRange = type.getNameRange();
     		if (SourceRange.isAvailable(nameRange)) {
 				ASTNode node = NodeFinder.perform(cuNode, nameRange);
@@ -502,7 +521,7 @@
 				}
     		}    		
     	}
-	    return createQualifiedTypeName(type);
+		return BreakpointToggleUtils.createQualifiedTypeName(type);
     }
     
     /**
@@ -532,76 +551,6 @@
     	return false;
     }
     
-    /**
-     * Returns the package qualified name, while accounting for the fact that a source file might
-     * not have a project
-     * @param type the type to ensure the package qualified name is created for
-     * @return the package qualified name
-     * @since 3.3
-     */
-    String createQualifiedTypeName(IType type) {
-    	String tname = pruneAnonymous(type);
-    	try {
-    		String packName = null;
-    		if (type.isBinary()) {
-    			packName = type.getPackageFragment().getElementName();
-    		} else {
-    			IPackageDeclaration[] pd = type.getCompilationUnit().getPackageDeclarations();
-				if(pd.length > 0) {
-					packName = pd[0].getElementName();
-				}
-    		}
-			if(packName != null && !packName.equals(EMPTY_STRING)) {
-				tname =  packName+"."+tname; //$NON-NLS-1$
-			}
-    	} 
-    	catch (JavaModelException e) {}
-    	return tname;
-    }
-    
-    /**
-     * Prunes out all naming occurrences of anonymous inner types, since these types have no names
-     * and cannot be derived visiting an AST (no positive type name matching while visiting ASTs)
-     * @param type
-     * @return the compiled type name from the given {@link IType} with all occurrences of anonymous inner types removed
-     * @since 3.4
-     */
-    private String pruneAnonymous(IType type) {
-    	StringBuffer buffer = new StringBuffer();
-    	IJavaElement parent = type;
-    	while(parent != null) {
-    		if(parent.getElementType() == IJavaElement.TYPE){
-    			IType atype = (IType) parent;
-    			try {
-	    			if(!atype.isAnonymous()) {
-	    				if(buffer.length() > 0) {
-	    					buffer.insert(0, '$');
-	    				}
-	    				buffer.insert(0, atype.getElementName());
-	    			}
-    			}
-    			catch(JavaModelException jme) {}
-    		}
-    		parent = parent.getParent();
-    	}
-    	return buffer.toString();
-    }
-    
-    /**
-     * gets the <code>IJavaElement</code> from the editor input
-     * @param input the current editor input
-     * @return the corresponding <code>IJavaElement</code>
-     * @since 3.3
-     */
-    private IJavaElement getJavaElement(IEditorInput input) {
-    	IJavaElement je = JavaUI.getEditorInputJavaElement(input);
-    	if(je != null) {
-    		return je;
-    	}
-    	//try to get from the working copy manager
-    	return DebugWorkingCopyManager.getWorkingCopy(input, false);
-    }
-    
     /*
      * (non-Javadoc)
      * 
@@ -620,13 +569,14 @@
         return (selection instanceof ITextSelection) && isMethod((ITextSelection) selection, part);
     }
     
-    /**
-     * Returns whether the given part/selection is remote (viewing a repository)
-     * 
-     * @param part
-     * @param selection
-     * @return
-     */
+   
+	/**
+	 * Returns whether the given part/selection is remote (viewing a repository)
+	 * 
+	 * @param part
+	 * @param selection
+	 * @return
+	 */
     protected boolean isRemote(IWorkbenchPart part, ISelection selection) {
     	if (selection instanceof IStructuredSelection) {
 			IStructuredSelection ss = (IStructuredSelection) selection;
@@ -636,7 +586,7 @@
 				return !member.getJavaProject().getProject().exists();
 			}
 		}
-    	ITextEditor editor = getTextEditor(part);
+		ITextEditor editor = BreakpointToggleUtils.getTextEditor(part);
     	if (editor != null) {
     		IEditorInput input = editor.getEditorInput();
     		Object adapter = Platform.getAdapterManager().getAdapter(input, "org.eclipse.team.core.history.IFileRevision"); //$NON-NLS-1$
@@ -646,21 +596,6 @@
     }
     
     /**
-     * Returns the text editor associated with the given part or <code>null</code>
-     * if none. In case of a multi-page editor, this method should be used to retrieve
-     * the correct editor to perform the breakpoint operation on.
-     * 
-     * @param part workbench part
-     * @return text editor part or <code>null</code>
-     */
-    protected ITextEditor getTextEditor(IWorkbenchPart part) {
-    	if (part instanceof ITextEditor) {
-    		return (ITextEditor) part;
-    	}
-    	return part.getAdapter(ITextEditor.class);
-    }
-
-    /**
      * Returns the methods from the selection, or an empty array
      * @param selection the selection to get the methods from
      * @return an array of the methods from the selection or an empty array
@@ -717,22 +652,21 @@
         return methods.toArray(new IMethod[methods.size()]);
     }
 
-    /**
+     /**
      * Returns if the text selection is a valid method or not
      * @param selection the text selection
      * @param part the associated workbench part
      * @return true if the selection is a valid method, false otherwise
      */
-    private boolean isMethod(ITextSelection selection, IWorkbenchPart part) {
-		ITextEditor editor = getTextEditor(part);
-		if(editor != null) {
-			IJavaElement element = getJavaElement(editor.getEditorInput());
-			if(element != null) {
+	private boolean isMethod(ITextSelection selection, IWorkbenchPart part) {
+		ITextEditor editor = BreakpointToggleUtils.getTextEditor(part);
+		if (editor != null) {
+			IJavaElement element = BreakpointToggleUtils.getJavaElement(editor.getEditorInput());
+			if (element != null) {
 				try {
-					if(element instanceof ICompilationUnit) {
+					if (element instanceof ICompilationUnit) {
 						element = ((ICompilationUnit) element).getElementAt(selection.getOffset());
-					}
-					else if(element instanceof IClassFile) {
+					} else if (element instanceof IClassFile) {
 						element = ((IClassFile) element).getElementAt(selection.getOffset());
 					}
 					if (element != null && element.getElementType() == IJavaElement.METHOD) {
@@ -743,13 +677,15 @@
 						return true;
 					}
 
-				} 
-    			catch (JavaModelException e) {return false;}
+				}
+				catch (JavaModelException e) {
+					return false;
+				}
 			}
 		}
-    	return false;
-    }
-    
+		return false;
+	}
+
     /**
      * Returns a list of <code>IField</code> and <code>IJavaFieldVariable</code> in the given selection.
      * When an <code>IField</code> can be resolved for an <code>IJavaFieldVariable</code>, it is
@@ -791,7 +727,7 @@
 		try {
 			ISelection sel = selection;
 			if(!(sel instanceof IStructuredSelection)) {
-				sel = translateToMembers(part, selection);
+				sel = BreakpointToggleUtils.translateToMembers(part, selection);
 			}
 			if(sel instanceof IStructuredSelection) {
 				Object obj = ((IStructuredSelection)sel).getFirstElement();
@@ -821,9 +757,9 @@
      * @since 3.3
      */
     private boolean isField(ITextSelection selection, IWorkbenchPart part) {
-    	ITextEditor editor = getTextEditor(part);
+		ITextEditor editor = BreakpointToggleUtils.getTextEditor(part);
     	if(editor != null) {
-    		IJavaElement element = getJavaElement(editor.getEditorInput());
+			IJavaElement element = BreakpointToggleUtils.getJavaElement(editor.getEditorInput());
     		if(element != null) {
     			try {
 	    			if(element instanceof ICompilationUnit) {
@@ -840,6 +776,7 @@
     	return false;
     }
     
+
     /**
      * Determines if the selection is a field or not
      * @param selection the current selection
@@ -882,20 +819,20 @@
                     return Status.CANCEL_STATUS;
                 }
                 try {
-                    report(null, part);
+					BreakpointToggleUtils.report(null, part);
                     ISelection selection = finalSelection;
                     if(!(selection instanceof IStructuredSelection)) {
-                    	selection = translateToMembers(part, finalSelection);
+						selection = BreakpointToggleUtils.translateToMembers(part, finalSelection);
                     }
                     if(isInterface(selection, part)) {
-                		report(ActionMessages.ToggleBreakpointAdapter_5, part);
+						BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_5, part);
                 		return Status.OK_STATUS;
                 	}
                     boolean allowed = false;
 	                if (selection instanceof IStructuredSelection) {
 	                	List<Object> fields = getFields((IStructuredSelection) selection);
 	                    if (fields.isEmpty()) {
-	                        report(ActionMessages.ToggleBreakpointAdapter_10, part); 
+							BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_10, part);
 	                        return Status.OK_STATUS;
 	                    }
 	                    Iterator<Object> theFields = fields.iterator();
@@ -956,7 +893,7 @@
 	                    }
                     }
                     else {
-                    	report(ActionMessages.ToggleBreakpointAdapter_2, part);
+						BreakpointToggleUtils.report(ActionMessages.ToggleBreakpointAdapter_2, part);
                     	return Status.OK_STATUS;
                     }
                 } catch (CoreException e) {return e.getStatus();}
@@ -1057,8 +994,8 @@
         types[1] = types[1].replace('.', '$');
         
         String resolvedElementTypeName = Signature.toQualifiedName(types);
-        String resolvedElementTypeSignature = EMPTY_STRING;
-        if(types[0].equals(EMPTY_STRING)) {
+		String resolvedElementTypeSignature = BreakpointToggleUtils.EMPTY_STRING;
+		if (types[0].equals(BreakpointToggleUtils.EMPTY_STRING)) {
         	resolvedElementTypeName = resolvedElementTypeName.substring(1);
         	resolvedElementTypeSignature = Signature.createTypeSignature(resolvedElementTypeName, true);
         }
@@ -1160,26 +1097,7 @@
         return null;
     }
 
-    /**
-     * Returns the compilation unit from the editor
-     * @param editor the editor to get the compilation unit from
-     * @return the compilation unit or <code>null</code>
-     */
-    protected CompilationUnit parseCompilationUnit(ITextEditor editor) {
-        return parseCompilationUnit(getTypeRoot(editor.getEditorInput()));
-    }
 
-    /**
-     * Parses the {@link ITypeRoot}.
-     * @param root the root
-     * @return the parsed {@link CompilationUnit}
-     */
-    CompilationUnit parseCompilationUnit(ITypeRoot root) {
-    	if(root != null) {
-    		return SharedASTProvider.getAST(root, SharedASTProvider.WAIT_YES, null);
-        }
-        return null;
-    }
     
     /*
      * (non-Javadoc)
@@ -1198,77 +1116,7 @@
         }
         return (selection instanceof ITextSelection) && isField((ITextSelection) selection, part);
     }
-    
-    /**
-     * Returns a selection of the member in the given text selection, or the
-     * original selection if none.
-     * 
-     * @param part
-     * @param selection
-     * @return a structured selection of the member in the given text selection,
-     *         or the original selection if none
-     * @exception CoreException
-     *                if an exception occurs
-     */
-    protected ISelection translateToMembers(IWorkbenchPart part, ISelection selection) throws CoreException {
-    	ITextEditor textEditor = getTextEditor(part);
-        if (textEditor != null && selection instanceof ITextSelection) {
-            ITextSelection textSelection = (ITextSelection) selection;
-            IEditorInput editorInput = textEditor.getEditorInput();
-            IDocumentProvider documentProvider = textEditor.getDocumentProvider();
-            if (documentProvider == null) {
-                throw new CoreException(Status.CANCEL_STATUS);
-            }
-            IDocument document = documentProvider.getDocument(editorInput);
-            int offset = textSelection.getOffset();
-            if (document != null) {
-                try {
-                    IRegion region = document.getLineInformationOfOffset(offset);
-                    int end = region.getOffset() + region.getLength();
-                    while (Character.isWhitespace(document.getChar(offset)) && offset < end) {
-                        offset++;
-                    }
-                } catch (BadLocationException e) {}
-            }
-            IMember m = null;
-            ITypeRoot root = getTypeRoot(editorInput);
-            if(root instanceof ICompilationUnit) {
-                ICompilationUnit unit = (ICompilationUnit) root;
-                synchronized (unit) {
-                    unit.reconcile(ICompilationUnit.NO_AST , false, null, null);
-                }
-            }
-            if(root != null){
-                IJavaElement e = root.getElementAt(offset);
-                if (e instanceof IMember) {
-                    m = (IMember) e;
-                }
-            }
-            if (m != null) {
-                return new StructuredSelection(m);
-            }
-        }
-        return selection;
-    }
-
-    /**
-     * Returns the {@link ITypeRoot} for the given {@link IEditorInput}
-     * @param input
-     * @return the type root or <code>null</code> if one cannot be derived
-	 * @since 3.4
-     */
-    private ITypeRoot getTypeRoot(IEditorInput input) {
-		ITypeRoot root = input.getAdapter(IClassFile.class);
-    	if(root == null) {
-    		 IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
-             root = manager.getWorkingCopy(input);
-    	}
-    	if(root == null) {
-    		root = DebugWorkingCopyManager.getWorkingCopy(input, false);
-    	}
-    	return root;
-    }
-    
+      
     /**
      * Return the associated IField (Java model) for the given
      * IJavaFieldVariable (JDI model)
@@ -1301,7 +1149,7 @@
      */
     @Override
 	public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
-    	ISelection sel = translateToMembers(part, selection);
+		ISelection sel = BreakpointToggleUtils.translateToMembers(part, selection);
     	if(sel instanceof IStructuredSelection) {
     		IMember member = (IMember) ((IStructuredSelection)sel).getFirstElement();
     		int mtype = member.getElementType();
@@ -1313,14 +1161,19 @@
     				IResource resource = BreakpointUtils.getBreakpointResource(declaringType);
 					IJavaLineBreakpoint breakpoint = JDIDebugModel.lineBreakpointExists(resource, getQualifiedName(declaringType), ts.getStartLine() + 1);
     				if (breakpoint != null) {
-						deleteBreakpoint(breakpoint, part, null);
+						if (BreakpointToggleUtils.isToggleTracepoints()) {
+							deleteTracepoint(breakpoint, part, null);
+							BreakpointToggleUtils.setUnsetTracepoints(false);
+						} else {
+							deleteBreakpoint(breakpoint, part, null);
+						}
     					return;
     				}
-    				CompilationUnit unit = parseCompilationUnit(getTextEditor(part));
+					CompilationUnit unit = BreakpointToggleUtils.parseCompilationUnit(BreakpointToggleUtils.getTextEditor(part));
         			ValidBreakpointLocationLocator loc = new ValidBreakpointLocationLocator(unit, ts.getStartLine()+1, true, true);
         			unit.accept(loc);
         			if(loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_METHOD) {
-        				toggleMethodBreakpoints(part, sel);
+						toggleMethodBreakpoints(part, ts);
         			}
         			else if(loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_FIELD) {
         				toggleWatchpoints(part, ts);
@@ -1349,24 +1202,22 @@
 	 * @throws CoreException if the deletion fails
 	 */
 	private static void deleteBreakpoint(IJavaBreakpoint breakpoint, IWorkbenchPart part, IProgressMonitor monitor) throws CoreException {
-		final Shell shell= part != null ? part.getSite().getShell() : null;
-		final boolean[] result= new boolean[] { true };
+		final Shell shell = part != null ? part.getSite().getShell() : null;
+		final boolean[] result = new boolean[] { true };
 
-		final IEclipsePreferences prefs= InstanceScope.INSTANCE.getNode(JDIDebugUIPlugin.getUniqueIdentifier());
-		boolean prompt= prefs.getBoolean(IJDIPreferencesConstants.PREF_PROMPT_DELETE_CONDITIONAL_BREAKPOINT, true);
-		if (prompt && breakpoint instanceof IJavaLineBreakpoint && ((IJavaLineBreakpoint)breakpoint).getCondition() != null) {
-			Display display= shell != null && !shell.isDisposed() ? shell.getDisplay() : PlatformUI.getWorkbench().getDisplay();
+		final IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JDIDebugUIPlugin.getUniqueIdentifier());
+		boolean prompt = prefs.getBoolean(IJDIPreferencesConstants.PREF_PROMPT_DELETE_CONDITIONAL_BREAKPOINT, true);
+		if (prompt && breakpoint instanceof IJavaLineBreakpoint && ((IJavaLineBreakpoint) breakpoint).getCondition() != null) {
+			Display display = shell != null && !shell.isDisposed() ? shell.getDisplay() : PlatformUI.getWorkbench().getDisplay();
 			if (!display.isDisposed()) {
 				display.syncExec(new Runnable() {
 					@Override
 					public void run() {
-						MessageDialogWithToggle dialog= MessageDialogWithToggle.openOkCancelConfirm(shell, ActionMessages.ToggleBreakpointAdapter_confirmDeleteTitle,
-								ActionMessages.ToggleBreakpointAdapter_confirmDeleteMessage, ActionMessages.ToggleBreakpointAdapter_confirmDeleteShowAgain, false,
-								null, null);
+						MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, ActionMessages.ToggleBreakpointAdapter_confirmDeleteTitle, ActionMessages.ToggleBreakpointAdapter_confirmDeleteMessage, ActionMessages.ToggleBreakpointAdapter_confirmDeleteShowAgain, false, null, null);
 						if (dialog.getToggleState()) {
 							prefs.putBoolean(IJDIPreferencesConstants.PREF_PROMPT_DELETE_CONDITIONAL_BREAKPOINT, false);
 						}
-						result[0]= dialog.getReturnCode() == IDialogConstants.OK_ID;
+						result[0] = dialog.getReturnCode() == IDialogConstants.OK_ID;
 					}
 				});
 			}
@@ -1376,6 +1227,52 @@
 		}
 	}
 
+	private static void deleteTracepoint(IJavaBreakpoint breakpoint, IWorkbenchPart part, IProgressMonitor monitor) throws CoreException {
+		final Shell shell = part != null ? part.getSite().getShell() : null;
+		final boolean[] result = new boolean[] { true };
+
+		final IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JDIDebugUIPlugin.getUniqueIdentifier());
+		boolean prompt = prefs.getBoolean(IJDIPreferencesConstants.PREF_PROMPT_DELETE_CONDITIONAL_BREAKPOINT, true);
+
+		if (prompt && breakpoint instanceof IJavaLineBreakpoint) {
+			String condition = ((IJavaLineBreakpoint) breakpoint).getCondition();
+			boolean conditionChanged = true;
+			if (condition != null) {
+				int index = condition.indexOf(";"); //$NON-NLS-1$
+				if (index != -1) {
+					int lastIndex = condition.lastIndexOf(";"); //$NON-NLS-1$
+					if (index == lastIndex) {
+						conditionChanged = false;
+					}
+
+				} else {
+					if (condition.indexOf("print") != -1) { //$NON-NLS-1$
+						conditionChanged = false;
+					}
+				}
+			}
+			if (conditionChanged && condition != null) {
+				Display display = shell != null && !shell.isDisposed() ? shell.getDisplay() : PlatformUI.getWorkbench().getDisplay();
+				if (!display.isDisposed()) {
+					display.syncExec(new Runnable() {
+						@Override
+						public void run() {
+							MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(shell, ActionMessages.ToggleBreakpointAdapter_confirmDeleteTitle, ActionMessages.ToggleBreakpointAdapter_confirmDeleteMessage, ActionMessages.ToggleBreakpointAdapter_confirmDeleteShowAgain, false, null, null);
+							if (dialog.getToggleState()) {
+								prefs.putBoolean(IJDIPreferencesConstants.PREF_PROMPT_DELETE_CONDITIONAL_BREAKPOINT, false);
+							}
+							result[0] = dialog.getReturnCode() == IDialogConstants.OK_ID;
+						}
+					});
+				}
+			}
+		}
+
+		if (result[0]) {
+			DebugUITools.deleteBreakpoints(new IBreakpoint[] { breakpoint }, shell, monitor);
+		}
+	}
+
     /*
      * (non-Javadoc)
      * 
@@ -1397,7 +1294,7 @@
 	public void toggleBreakpointsWithEvent(IWorkbenchPart part, ISelection selection, Event event) throws CoreException {
 		if(event != null) {
 			if((event.stateMask & SWT.MOD2) > 0) {
-				ITextEditor editor = getTextEditor(part);
+				ITextEditor editor = BreakpointToggleUtils.getTextEditor(part);
 				if(editor != null) {
 					IVerticalRulerInfo info = editor.getAdapter(IVerticalRulerInfo.class);
 					if(info != null) {
@@ -1410,7 +1307,7 @@
 				}
 			}
 			else if((event.stateMask & SWT.MOD1) > 0) {
-				ITextEditor editor = getTextEditor(part);
+				ITextEditor editor = BreakpointToggleUtils.getTextEditor(part);
 				if(editor != null) {
 					IVerticalRulerInfo info = editor.getAdapter(IVerticalRulerInfo.class);
 					if(info != null) {
diff --git a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationSourceGenerator.java b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationSourceGenerator.java
index 9076ffd..aabe54b 100644
--- a/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationSourceGenerator.java
+++ b/org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/EvaluationSourceGenerator.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -157,6 +157,9 @@
 	 */
 	
 	private boolean needsReturn(String codeSnippet){
+		if ( codeSnippet.length() == 0) {
+			return false;
+		}
 		IScanner scanner = ToolFactory.createScanner(false, false, false, fJavaProject.getOption(JavaCore.COMPILER_SOURCE, true), fJavaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true));
 		scanner.setSource(codeSnippet.toCharArray());
 		int token;
@@ -181,11 +184,21 @@
 				else if (count == 0 && (token == ITerminalSymbols.TokenNamethrow)){
 					return false;
 				}
+				else if ( count == 0 && (token == ITerminalSymbols.TokenNameif || token == ITerminalSymbols.TokenNamewhile || token == ITerminalSymbols.TokenNamedo)) {
+					return false;
+				}
 				else if (count ==1 && (token == ITerminalSymbols.TokenNameLBRACE || token == ITerminalSymbols.TokenNameEQUAL)){
 					return true;
 				}
 				else if (count ==1 && (token == ITerminalSymbols.TokenNameLESS || token == ITerminalSymbols.TokenNameLBRACKET)){
+					int currentToken = token;
 					token = scanner.getNextToken();
+					if ( currentToken == ITerminalSymbols.TokenNameLESS && ( token == ITerminalSymbols.TokenNameIdentifier || (token >= ITerminalSymbols.TokenNameIntegerLiteral && token <= ITerminalSymbols.TokenNameStringLiteral))){
+						token = scanner.getNextToken();
+						if (token == ITerminalSymbols.TokenNameEOF) {
+							return true;
+						}
+					}
 					count = 2;
 				}
 				else if (count ==2 && (token == ITerminalSymbols.TokenNameGREATER || token == ITerminalSymbols.TokenNameRBRACKET)){
@@ -194,6 +207,12 @@
 					if ( token == ITerminalSymbols.TokenNameEOF && currentToken == ITerminalSymbols.TokenNameRBRACKET ){
 						return true;
 					}
+					if ( currentToken == ITerminalSymbols.TokenNameGREATER && ( token == ITerminalSymbols.TokenNameIdentifier || (token >= ITerminalSymbols.TokenNameIntegerLiteral && token <= ITerminalSymbols.TokenNameStringLiteral))){
+						token = scanner.getNextToken();
+						if (token == ITerminalSymbols.TokenNameEOF) {
+							return true;
+						}
+					}
 					count = 3;
 				}
 				else if (count == 2)
@@ -212,7 +231,7 @@
 			e.printStackTrace();
 		}
 		
-		return false;
+		return true;
 	}
 	
 	public String getCompilationUnitName() {
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIDebugTarget.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIDebugTarget.java
index 24288c8..0d146d8 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIDebugTarget.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIDebugTarget.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -389,7 +389,7 @@
 			}
 			// See IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME
 			String projectName = config.getAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", (String)null); //$NON-NLS-1$
-			if(projectName != null){
+			if(projectName != null && !projectName.isEmpty()){
 				Set<IJavaProject> javaProjects = getJavaProjects(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName));
 				fProjects = collectReferencedJavaProjects(javaProjects);
 				fScope = createSourcesOnlyScope();