usage of reflection is not needed anymore (#140)

* usage of reflection is not needed anymore
* fix possible NPE for test...

Signed-off-by: Olivier Lamy <olamy@apache.org>
diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
index cf6b86c..6f27504 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -48,6 +48,7 @@
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
 import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecution;
@@ -1496,7 +1497,7 @@
             catch ( InclusionScanException e )
             {
                 throw new MojoExecutionException(
-                    "Error scanning source root: \'" + sourceRoot + "\' for stale files to recompile.", e );
+                    "Error scanning source root: '" + sourceRoot + "' for stale files to recompile.", e );
             }
         }
 
@@ -1536,42 +1537,14 @@
      */
     protected int getRequestThreadCount()
     {
-        try
-        {
-            Method getRequestMethod = session.getClass().getMethod( "getRequest" );
-            Object mavenExecutionRequest = getRequestMethod.invoke( this.session );
-            Method getThreadCountMethod = mavenExecutionRequest.getClass().getMethod( "getThreadCount" );
-            String threadCount = (String) getThreadCountMethod.invoke( mavenExecutionRequest );
-            return Integer.parseInt( threadCount );
-        }
-        catch ( Exception e )
-        {
-            getLog().debug( "unable to get threadCount for the current build: " + e.getMessage() );
-        }
-        return 1;
+        return session.getRequest().getDegreeOfConcurrency();
     }
 
     protected Date getBuildStartTime()
     {
-        Date buildStartTime = null;
-        try
-        {
-            Method getRequestMethod = session.getClass().getMethod( "getRequest" );
-            Object mavenExecutionRequest = getRequestMethod.invoke( session );
-            Method getStartTimeMethod = mavenExecutionRequest.getClass().getMethod( "getStartTime" );
-            buildStartTime = (Date) getStartTimeMethod.invoke( mavenExecutionRequest );
-        }
-        catch ( Exception e )
-        {
-            getLog().debug( "unable to get start time for the current build: " + e.getMessage() );
-        }
-
-        if ( buildStartTime == null )
-        {
-            return new Date();
-        }
-
-        return buildStartTime;
+        MavenExecutionRequest request = session.getRequest();
+        Date buildStartTime = request == null ? new Date() : request.getStartTime();
+        return buildStartTime == null ? new Date() : buildStartTime;
     }
 
 
diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
index 9d9469f..4368304 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
@@ -306,7 +306,7 @@
 
         if ( release != null )
         {
-            if ( Integer.valueOf( release ) < 9 )
+            if ( Integer.parseInt( release ) < 9 )
             {
                 pathElements = Collections.emptyMap();
                 modulepathElements = Collections.emptyList();
@@ -314,7 +314,7 @@
                 return;
             }
         }
-        else if ( Double.valueOf( getTarget() ) < Double.valueOf( MODULE_INFO_TARGET ) )
+        else if ( Double.parseDouble( getTarget() ) < Double.parseDouble( MODULE_INFO_TARGET ) )
         {
             pathElements = Collections.emptyMap();
             modulepathElements = Collections.emptyList();
@@ -440,7 +440,7 @@
         if ( testIncludes.isEmpty() && testExcludes.isEmpty() )
         {
             testIncludes = Collections.singleton( defaultIncludePattern );
-            scanner = new SimpleSourceInclusionScanner( testIncludes, Collections.<String>emptySet() );
+            scanner = new SimpleSourceInclusionScanner( testIncludes, Collections.emptySet() );
         }
         else
         {