[java] use plain strings instead of mangled for JavaClassName

Summary: The way `Mangled.t` is used in `JavaClassName` means that it's always a plain string (we never have a "mangled" part).  Remove the indirection and extra allocation.  Also, simplify the API by throwing away one function that was used just once and wastefully.

Reviewed By: artempyanykh

Differential Revision: D19950672

fbshipit-source-id: b61fcba6e
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent a85dfe6af4
commit ace23a1670

@ -6,4 +6,11 @@
*)
open! IStd
include Mangled
type t = string [@@deriving compare]
let from_string str = str
let to_string str = str
let pp = String.pp

@ -486,11 +486,6 @@ module Name = struct
let from_string name_str = JavaClass (JavaClassName.from_string name_str)
let from_package_class package_name class_name =
if String.equal package_name "" then from_string class_name
else from_string (package_name ^ "." ^ class_name)
let is_class = function JavaClass _ -> true | _ -> false
let java_io_serializable = from_string "java.io.Serializable"

@ -239,9 +239,6 @@ module Name : sig
val from_string : string -> t
(** Create a typename from a Java classname in the form "package.class" *)
val from_package_class : string -> string -> t
(** Create a typename from a package name and a class name *)
val is_class : t -> bool
(** [is_class name] holds if [name] names a Java class *)

@ -25,15 +25,14 @@ let is_destroy_method pname =
false
let is_subtype_package_class tenv tname package classname =
PatternMatch.is_subtype tenv tname (Typ.Name.Java.from_package_class package classname)
let is_autocloseable tenv tname =
PatternMatch.is_subtype_of_str tenv tname "java.lang.AutoCloseable"
let is_autocloseable tenv tname = is_subtype_package_class tenv tname "java.lang" "AutoCloseable"
let is_view tenv tname = PatternMatch.is_subtype_of_str tenv tname "android.view.View"
let is_view tenv tname = is_subtype_package_class tenv tname "android.view" "View"
let is_fragment tenv tname =
is_subtype_package_class tenv tname "androidx.fragment.app" "Fragment"
|| is_subtype_package_class tenv tname "android.app" "Fragment"
|| is_subtype_package_class tenv tname "android.support.v4.app" "Fragment"
let is_fragment =
let fragments =
["androidx.fragment.app.Fragment"; "android.app.Fragment"; "android.support.v4.app.Fragment"]
in
fun tenv tname -> List.exists fragments ~f:(PatternMatch.is_subtype_of_str tenv tname)

@ -86,7 +86,7 @@ codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.
codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.writeToNotOwnedInCalleeBad1(codetoanalyze.java.checkers.Obj):void, 157, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [call to void Ownership.writeToFormal(Obj),access to `o.f`]
codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.writeToNotOwnedInCalleeBad2():void, 162, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [call to void Ownership.writeToFormal(Obj),access to `o.f`]
codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.writeToNotOwnedInCalleeBad3(codetoanalyze.java.checkers.Obj):void, 166, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [call to void Ownership.callWriteToFormal(Obj),call to void Ownership.writeToFormal(Obj),access to `o.f`]
codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.writeToOwnedInCalleeOk2():void, 183, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [<Read trace>,access to `this.field`,<Write trace>,access to `this.field`]
codetoanalyze/java/racerd/Ownership.java, codetoanalyze.java.checkers.Ownership.writeToOwnedInCalleeOk2():void, 183, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [<Read trace>,access to `this.field`,<Write trace>,call to void Ownership.setField(Obj),access to `this.field`]
codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional2_bad(boolean):void, 130, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [access to `this.ff`]
codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditionalMainThreadWriteBad():void, 219, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [call to void RaceWithMainThread.conditionalMainThreadWrite2(boolean),access to `this.mOnlyWrittenOnMain`]
codetoanalyze/java/racerd/RaceWithMainThread.java, codetoanalyze.java.checkers.RaceWithMainThread.conditional_isMainThread_ElseBranch_Bad():void, 152, THREAD_SAFETY_VIOLATION, no_bucket, WARNING, [access to `this.ff`]

Loading…
Cancel
Save