alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (Which.scala)

This example Scala source code file (Which.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

array, array, could, global, global, settings, some, some, unit, unit, which

The Scala Which.scala source code

/* NSC -- new Scala compiler
 * Copyright 2005-2011 LAMP/EPFL
 * @author  Paul Phillips
 */

package scala.tools
package util

import scala.tools.nsc._

/** A tool for identifying which classfile is being used.
 *  under the given conditions.
 */
object Which {
  def main(args: Array[String]): Unit = {
    val settings = new Settings()
    val names = settings.processArguments(args.toList, true)._2
    val global = new Global(settings)
    val cp = global.classPath

    import cp._
    
    for (name <- names) {
      def fail() = println("Could not find: %s".format(name))
      (cp findClass name) match {
        case Some(classRep) => classRep.binary match {
          case Some(f)  => println("%s is %s".format(name, f))
          case _        => fail
        }
        case _ => fail
      }
    }
  }
}




Other Scala examples (source code examples)

Here is a short list of links related to this Scala Which.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.